diff --git a/api/bracket.go b/api/bracket.go new file mode 100644 index 0000000..a5e8a15 --- /dev/null +++ b/api/bracket.go @@ -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 +} diff --git a/api/model.go b/api/model.go index c0cda72..4de6ad8 100644 --- a/api/model.go +++ b/api/model.go @@ -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"`