Skip to content

Commit

Permalink
add GetTeamsByMeeting to client
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad2002 committed Nov 29, 2023
1 parent b276cd2 commit fc31de8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions client/team_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,28 @@ func (c *TeamClient) GetTeamByName(name string) (*model.Team, bool, error) {

return team, true, nil
}

func (c *TeamClient) GetTeamsByMeeting(meeting string) (*[]model.Team, bool, error) {
fmt.Printf("request '%s'\n", c.apiUrl+"team/meet/"+meeting)

res, err := client.Get(c.apiUrl, "team/meet/"+meeting, nil)
if err != nil {
return nil, false, err
}
defer res.Body.Close()

if res.StatusCode != http.StatusOK {
if res.StatusCode == http.StatusNotFound {
return nil, false, nil
}
return nil, false, fmt.Errorf("GetTeamsByMeeting received error: %d\n", res.StatusCode)
}

teams := &[]model.Team{}
err = json.NewDecoder(res.Body).Decode(teams)
if err != nil {
return nil, false, err
}

return teams, true, nil
}

0 comments on commit fc31de8

Please sign in to comment.