-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_profile.go
47 lines (42 loc) · 2.18 KB
/
update_profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package authorizer
import (
"encoding/json"
)
// UpdateProfileInput defines attributes for signup request
type UpdateProfileInput struct {
Email *string `json:"email,omitempty"`
NewPassword *string `json:"new_password,omitempty"`
ConfirmNewPassword *string `json:"confirm_new_password,omitempty"`
OldPassword *string `json:"old_password,omitempty"`
GivenName *string `json:"given_name,omitempty"`
FamilyName *string `json:"family_name,omitempty"`
MiddleName *string `json:"middle_name,omitempty"`
NickName *string `json:"nick_name,omitempty"`
Picture *string `json:"picture,omitempty"`
Gender *string `json:"gender,omitempty"`
BirthDate *string `json:"birthdate,omitempty"`
PhoneNumber *string `json:"phone_number,omitempty"`
Roles []*string `json:"roles,omitempty"`
Scope []*string `json:"scope,omitempty"`
RedirectURI *string `json:"redirect_uri,omitempty"`
IsMultiFactorAuthEnabled *bool `json:"is_multi_factor_auth_enabled,omitempty"`
AppData map[string]interface{} `json:"app_data,omitempty"`
}
// UpdateProfile is method attached to AuthorizerClient.
// It performs update_profile mutation on authorizer instance.
// It returns User reference or error.
// For implementation details check UpdateProfileExample examples/update_profile.go
func (c *AuthorizerClient) UpdateProfile(req *UpdateProfileInput, headers map[string]string) (*Response, error) {
bytesData, err := c.ExecuteGraphQL(&GraphQLRequest{
Query: `mutation updateProfile($data: UpdateProfileInput!) { update_profile(params: $data) { message } }`,
Variables: map[string]interface{}{
"data": req,
},
}, headers)
if err != nil {
return nil, err
}
var res map[string]*Response
json.Unmarshal(bytesData, &res)
return res["update_profile"], nil
}