| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package client |
||
| 2 | |||
| 3 | import ( |
||
| 4 | "context" |
||
| 5 | "encoding/json" |
||
| 6 | "net/http" |
||
| 7 | ) |
||
| 8 | |||
| 9 | // UsersService is the API client for the `/v1/users` endpoint |
||
| 10 | type UsersService service |
||
| 11 | |||
| 12 | // Me retrieves the currently authenticated user. |
||
| 13 | // https://docs.lemonsqueezy.com/api/users#retrieve-the-authenticated-user |
||
| 14 | func (service *UsersService) Me(ctx context.Context) (*UserApiResponse, *Response, error) { |
||
| 15 | response, err := service.client.do(ctx, http.MethodGet, "/v1/users/me") |
||
| 16 | if err != nil { |
||
| 17 | return nil, response, err |
||
| 18 | } |
||
| 19 | |||
| 20 | user := new(UserApiResponse) |
||
| 21 | if err = json.Unmarshal(*response.Body, user); err != nil { |
||
| 22 | return nil, response, err |
||
| 23 | } |
||
| 24 | |||
| 25 | return user, response, nil |
||
| 26 | } |
||
| 27 |