Skip to content

Commit

Permalink
add team search
Browse files Browse the repository at this point in the history
  • Loading branch information
STLVRTX committed Sep 4, 2022
1 parent 5e53cab commit adfa9d9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
examples/test

# Test binary, built with `go test -c`
*.test
Expand Down
38 changes: 38 additions & 0 deletions team.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,44 @@ func (c *Client) GetTeams(input *GetTeamsInput) (*GetTeamsOutput, error) {
return &GetTeamsOutput{Teams: teams}, nil
}

// SearchTeamInput represents the input of a SearchTeam operation.
type SearchTeamInput struct {
_ struct{}
TeamName *string
}

// SearchTeamOutput represents the output of a SearchTeam operation.
type SearchTeamOutput struct {
_ struct{}
Team *Team
}

// SearchTeam gets the team with specified name.
func (c *Client) SearchTeam(input *SearchTeamInput) (*SearchTeamOutput, error) {
if input == nil {
return nil, errors.New("input is required")
}
if input.TeamName == nil {
return nil, errors.New("Team name is required")
}

resp, err := c.httpClient.R().Get(fmt.Sprintf("%s/name/%s", apiRoutes.teams, *input.TeamName))
if err != nil {
return nil, err
}
if apiErr := getGenericAPIError(resp, 200); apiErr != nil {
return nil, apiErr
}

team := &Team{}
err = json.Unmarshal(resp.Body(), team)
if err != nil {
return nil, err
}

return &SearchTeamOutput{Team: team}, nil
}

// UpdateTeamInput represents the input of a UpdateTeam operation.
type UpdateTeamInput struct {
_ struct{}
Expand Down

0 comments on commit adfa9d9

Please sign in to comment.