Documentation ¶
Overview ¶
Package twist provides functions to work with Twist API.
It relies on Twist API v3 documented at https://developer.twist.com/v3/
Index ¶
- type Channel
- type Client
- func (c *Client) Channels(ctx context.Context, workspaceID uint64) ([]Channel, error)
- func (c *Client) CommentsPaginator(threadID uint64) *CommentsPaginator
- func (c *Client) NewCommentsPaginator(threadID uint64, since time.Time) *CommentsPaginator
- func (c *Client) NewThreadsPaginator(channelID uint64, since time.Time) *ThreadsPaginator
- func (c *Client) Thread(ctx context.Context, threadID uint64) (*Thread, error)
- func (c *Client) ThreadsPaginator(channelID uint64) *ThreadsPaginator
- func (c *Client) Users(ctx context.Context, workspaceID uint64) ([]User, error)
- func (c *Client) Workspaces(ctx context.Context) ([]Workspace, error)
- type Comment
- type CommentsPaginator
- type Thread
- type ThreadsPaginator
- type User
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { Id uint64 `json:"id"` Name string `json:"name"` Archived bool `json:"archived"` }
Channel is a Twist channel. Channels organize threads around broad topics like team, project, location, or area of interest. Channel contains threads.
See https://developer.twist.com/v3/#channels for details.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Twist API client.
func New ¶
New returns Client that calls Twist API using provided token for authentication.
See https://developer.twist.com/v3/#authentication for details.
func (*Client) CommentsPaginator ¶
func (c *Client) CommentsPaginator(threadID uint64) *CommentsPaginator
CommentsPaginator returns CommentsPaginator that fetches all comments of a thread.
func (*Client) NewCommentsPaginator ¶
func (c *Client) NewCommentsPaginator(threadID uint64, since time.Time) *CommentsPaginator
NewCommentsPaginator returns CommentsPaginator that fetches only thread comments that were posted since given time.
Only use it to update thread comments you already have on a best-effort basis. Twist API logic is racy and may miss some comments that were updated between per-page API calls. If you need to fetch all comments of a thread, use CommentsPaginator method instead.
func (*Client) NewThreadsPaginator ¶
func (c *Client) NewThreadsPaginator(channelID uint64, since time.Time) *ThreadsPaginator
NewThreadsPaginator returns ThreadsPaginator that fetches only threads updated since given time.
Only use it to update channel thread list that you already have on a best-effort basis. Twist API logic is racy and may miss some threads that were updated between per-page API calls. If you need to fetch all threads of a channel, use ThreadsPaginator method instead.
func (*Client) Thread ¶
Thread returns a single thread. Use ThreadsPaginator to get all threads of a channel.
func (*Client) ThreadsPaginator ¶
func (c *Client) ThreadsPaginator(channelID uint64) *ThreadsPaginator
ThreadsPaginator returns ThreadsPaginator that fetches all threads of a channel.
type Comment ¶
type Comment struct { Id uint64 `json:"id"` Text string `json:"content"` Creator uint64 `json:"creator"` OrderIndex int `json:"obj_index"` TsPosted uint64 `json:"posted_ts"` }
Comment is a message posted to a thread.
See https://developer.twist.com/v3/#comments for details.
type CommentsPaginator ¶
type CommentsPaginator struct {
// contains filtered or unexported fields
}
CommentsPaginator fetches comments of a thread.
Typical usage:
p := client.CommentsPaginator(3456) // get comments for thread with id=3456 for p.Next() { comments, err := p.Page(ctx) if err != nil { return err } doSomethingWithComments(comments) }
func (*CommentsPaginator) Next ¶
func (tp *CommentsPaginator) Next() bool
Next reports whether there's another page to load. It only returns false once all channels are fetched with the Page method.
type Thread ¶
type Thread struct { Id uint64 `json:"id"` TsPosted uint64 `json:"posted_ts"` TsUpdated uint64 `json:"last_updated_ts"` Title string `json:"title"` Text string `json:"content"` Creator uint64 `json:"creator"` Archived bool `json:"is_archived"` }
Thread is a Twist thread. Threads keep team's conversations organized by specific topics. Thread contains comments.
See https://developer.twist.com/v3/#threads for details.
type ThreadsPaginator ¶
type ThreadsPaginator struct {
// contains filtered or unexported fields
}
ThreadsPaginator fetches threads of a channel.
Typical usage:
p := client.ThreadsPaginator(1234) // get threads for channel with id=1234 for p.Next() { threads, err := p.Page(ctx) if err != nil { return err } doSomethingWithThreads(threads) }
func (*ThreadsPaginator) Next ¶
func (cp *ThreadsPaginator) Next() bool
Next reports whether there's another page to load. It only returns false once all threads are fetched with the Page method.
type Workspace ¶
Workspace is a Twist workspace. A workspace is a shared place between different users. Workspace contains channels.
See https://developer.twist.com/v3/#workspaces for details.