MCPcopy Create free account
hub / github.com/algolia/cli / GetUser

Method GetUser

api/dashboard/client.go:437–464  ·  view source on GitHub ↗

GetUser returns account-level information for the authenticated user

(accessToken string)

Source from the content-addressed store, hash-verified

435
436// GetUser returns account-level information for the authenticated user
437func (c *Client) GetUser(accessToken string) (*DashboardUser, error) {
438 req, err := http.NewRequest(http.MethodGet, c.APIURL+"/1/user", nil)
439 if err != nil {
440 return nil, err
441 }
442 c.setAPIHeaders(req, accessToken)
443
444 resp, err := c.client.Do(req)
445 if err != nil {
446 return nil, fmt.Errorf("Couldn't get your account details: %w", err)
447 }
448 defer resp.Body.Close()
449
450 if resp.StatusCode == http.StatusUnauthorized {
451 return nil, ErrSessionExpired
452 }
453 if resp.StatusCode != http.StatusOK {
454 return nil, fmt.Errorf("Couldn't get your account details: %d", resp.StatusCode)
455 }
456
457 var userResp userResponse
458 if err := json.NewDecoder(resp.Body).Decode(&userResp); err != nil {
459 return nil, fmt.Errorf("Couldn't get your account details: %w", err)
460 }
461
462 user := userResp.toUser()
463 return &user, nil
464}
465
466// ChangeApplicationPlan changes the plan of an application
467func (c *Client) ChangeApplicationPlan(accessToken, appID, plan string) (*Application, error) {

Callers 4

changePlanFunction · 0.80
createApplicationFunction · 0.80
TestGetUser_TopLevelFunction · 0.80

Calls 4

setAPIHeadersMethod · 0.95
toUserMethod · 0.95
ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by 2

TestGetUser_TopLevelFunction · 0.64