-
Notifications
You must be signed in to change notification settings - Fork 1
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
2 changed files
with
55 additions
and
4 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,51 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"net/http" | ||
"time" | ||
) | ||
|
||
type UpsertArticleTopicParams struct { | ||
// ID is the identifier that the company uses for this topic | ||
ID string `json:"id"` | ||
|
||
// ParentID is the identifier for this topic's parent topic (if any). | ||
ParentID string `json:"parent_id"` | ||
|
||
// Name is the topic's name. | ||
Name string `json:"title"` | ||
|
||
// Description is an topic's tagline. It may be empty. | ||
Description string `json:"description"` | ||
|
||
// Visibility describes who can see this topic, ranging from the | ||
// whole world (public) through to employees only (internal). | ||
Visibility Visibility `json:"visibility"` | ||
|
||
// Status describes whether this article is published or not. | ||
Status PublicationStatus `json:"status"` | ||
|
||
// Data optionally gives additional meta-data about the topic. | ||
Data json.RawMessage `json:"data"` | ||
|
||
// Created is when the topic was first created. | ||
Created time.Time `json:"created"` | ||
|
||
// Updated is when the topic was last changed. | ||
Updated time.Time `json:"updated"` | ||
} | ||
|
||
func (c *Client) UpsertArticleTopic(ctx context.Context, p *UpsertArticleTopicParams) error { | ||
rsp, err := c.makeRequest(ctx, http.MethodPost, "topics", p) | ||
if err != nil { | ||
return err | ||
} | ||
defer rsp.Body.Close() | ||
|
||
if err := responseError(rsp); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |