Skip to content

Commit

Permalink
Add article topic upsert (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlathia committed Aug 12, 2024
2 parents 983d90b + 5981f36 commit c03acad
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
8 changes: 4 additions & 4 deletions article.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const (
type PublicationStatus string

const (
// StatusDraft means that the article is being written or
// PublicationStatusDraft means that the article is being written or
// edited and is not published.
StatusDraft PublicationStatus = "draft"
PublicationStatusDraft PublicationStatus = "draft"

// StatusPublished means that the article is published.
StatusPublished PublicationStatus = "published"
// PublicationStatusPublished means that the article is published.
PublicationStatusPublished PublicationStatus = "published"
)
51 changes: 51 additions & 0 deletions article_topic_upsert.go
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
}

0 comments on commit c03acad

Please sign in to comment.