-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
144 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type Challenge struct { | ||
CreatedAt string `json:"createdAt"` | ||
UpdatedAt string `json:"updatedAt"` | ||
|
||
Name string `json:"name"` | ||
|
||
PageURL string `json:"pageUrl"` | ||
} | ||
|
||
type CreateChallengeRequest struct { | ||
Name string `json:"name"` | ||
} | ||
|
||
func (c *Client) CreateChallenge(ctx context.Context, req CreateChallengeRequest) (*Challenge, error) { | ||
body, err := toJSONBody(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var ch Challenge | ||
return &ch, c.PostInto(ctx, "/challenges", nil, nil, body, &ch) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type PutMarkdownRequest struct { | ||
Kind string `json:"kind"` | ||
Name string `json:"name"` | ||
Content string `json:"content"` | ||
} | ||
|
||
func (c *Client) PutMarkdown(ctx context.Context, req PutMarkdownRequest) error { | ||
body, err := toJSONBody(req) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
resp, err := c.Put(ctx, "/content/markdown", nil, nil, body) | ||
if err != nil { | ||
return err | ||
} | ||
resp.Body.Close() | ||
return nil | ||
} |