Skip to content

Commit

Permalink
feat(bracket): add support of brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
pandatix committed Apr 17, 2024
1 parent f54416f commit e2e6b27
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
26 changes: 26 additions & 0 deletions api/bracket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package api

type GetBracketsParams struct{}

func (client *Client) GetBrackets(params *GetBracketsParams, opts ...Option) ([]*Bracket, error) {
bks := []*Bracket{}
if err := get(client, "/brackets", params, &bks, opts...); err != nil {
return nil, err
}
return bks, nil
}

type PostBracketsParams struct {
ID float64 `json:"id"` // XXX Why is that a float64 ?? Why is it even sent by the client as CTFd will return a new one ?
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"`
}

func (client *Client) PostBrackets(params *PostBracketsParams, opts ...Option) (*Bracket, error) {
bk := &Bracket{}
if err := post(client, "/brackets", params, bk, opts...); err != nil {
return nil, err
}
return bk, nil
}
7 changes: 7 additions & 0 deletions api/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ type (
SolvedByMe bool `json:"solved_by_me"`
}

Bracket struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"`
}

Type struct {
ID *string `json:"id,omitempty"`
Name string `json:"name"`
Expand Down

0 comments on commit e2e6b27

Please sign in to comment.