in internal/provider/person_api/api.go [60:100]
func (client *Client) GetPersonByEmail(ctx context.Context, email string) (*Person, error) {
person := Person{}
httpReq, err := http.NewRequest("GET", client.personEndpoint+"/v2/user/primary_email/"+email, nil)
if err != nil {
return nil, err
}
httpReq.Header.Add("Authorization", "Bearer "+client.auth0AccessToken)
httpResp, err := client.httpClient.Do(httpReq)
tflog.Info(ctx, fmt.Sprintf("HTTP Request: %#v", httpReq))
if err != nil {
return nil, err
}
if httpResp.StatusCode >= 400 {
return nil, fmt.Errorf("Person API responded with status code %d", httpResp.StatusCode)
}
defer httpResp.Body.Close()
respBody, err := io.ReadAll(httpResp.Body)
if err != nil {
return nil, err
}
err = json.Unmarshal(respBody, &person)
if err != nil {
return nil, err
}
// Convert map keys into a list of strings
keys := make([]string, 0, len(person.AccessInformation.Mozilliansorg.Values))
for key := range person.AccessInformation.Mozilliansorg.Values {
keys = append(keys, key)
}
person.AccessInformation.Mozilliansorg.List = keys
return &person, nil
}