Skip to content

Commit

Permalink
Merge pull request #18 from dmnemec/set_topic
Browse files Browse the repository at this point in the history
SetTopic
  • Loading branch information
daniellockard authored Dec 6, 2018
2 parents 783ee1f + c057207 commit 00e7d60
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
15 changes: 14 additions & 1 deletion conversations/conversations.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,20 @@ func (c *ConvoClient) SetPurpose(name, purpose string) (res structs.SetPurposeRe

// SetTopic sets the topic for a conversation.
// https://api.slack.com/methods/conversations.setTopic
func (c *ConvoClient) SetTopic() {
func (c *ConvoClient) SetTopic(name string, topic string) (res structs.SetTopicResponse, err error) {
valid, err := validChannel(name)
check(err)
if !valid {
return res, errors.New("Invalid Channel Name")
}
reqBod := setTopicStruct{
Token: c.token,
Channel: name,
Topic: topic,
}
err = jsonRequest(convURL, "setTopic", c.token, reqBod, &res)
check(err)
return res, err
}

// Unarchive reverses conversation archival.
Expand Down
6 changes: 5 additions & 1 deletion conversations/conversations_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ type setPurposeStruct struct {
Channel string `json:"channel"`
Purpose string `json:"purpose"`
}

type setTopicStruct struct {
Token string `json:"token"`
Channel string `json:"channel"`
Topic string `json:"topic"`
}
type inviteStruct struct {
Token string `json:"token"`
Channel string `json:"channel"`
Expand Down
6 changes: 6 additions & 0 deletions structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ type SetPurposeResponse struct {
Error string `json:"error"`
}

type SetTopicResponse struct {
Topic string `json:"topic"`
Ok bool `json:"ok"`
Error string `json:"error"`
}

//UnfurlResponse is returned from the Unfurl method
type UnfurlResponse struct {
Ok bool `json:"ok"`
Expand Down

0 comments on commit 00e7d60

Please sign in to comment.