Skip to content

Commit

Permalink
revert WebResponse to SlackResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
James Lawrence authored and james-lawrence committed May 9, 2018
1 parent 2b8f4d3 commit 8e0186d
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion bots.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Bot struct {

type botResponseFull struct {
Bot `json:"bot,omitempty"` // GetBotInfo
WebResponse
SlackResponse
}

func botRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*botResponseFull, error) {
Expand Down
2 changes: 1 addition & 1 deletion channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type channelResponseFull struct {
Topic string `json:"topic"`
NotInChannel bool `json:"not_in_channel"`
History
WebResponse
SlackResponse
}

// Channel contains information about the channel
Expand Down
2 changes: 1 addition & 1 deletion chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type chatResponseFull struct {
Channel string `json:"channel"`
Timestamp string `json:"ts"`
Text string `json:"text"`
WebResponse
SlackResponse
}

// PostMessageParameters contains all the parameters necessary (including the optional ones) for a PostMessage() request
Expand Down
2 changes: 1 addition & 1 deletion chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func postMessageInvalidChannelHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(chatResponseFull{
WebResponse: WebResponse{Ok: false, Error: "channel_not_found"},
SlackResponse: SlackResponse{Ok: false, Error: "channel_not_found"},
})
rw.Write(response)
}
Expand Down
28 changes: 14 additions & 14 deletions conversation.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (api *Client) GetUsersInConversationContext(ctx context.Context, params *Ge
response := struct {
Members []string `json:"members"`
ResponseMetaData responseMetaData `json:"response_metadata"`
WebResponse
SlackResponse
}{}
err := post(ctx, api.httpclient, "conversations.members", values, &response, api.debug)
if err != nil {
Expand All @@ -111,7 +111,7 @@ func (api *Client) ArchiveConversationContext(ctx context.Context, channelID str
"token": {api.token},
"channel": {channelID},
}
response := WebResponse{}
response := SlackResponse{}
err := post(ctx, api.httpclient, "conversations.archive", values, &response, api.debug)
if err != nil {
return err
Expand All @@ -131,7 +131,7 @@ func (api *Client) UnArchiveConversationContext(ctx context.Context, channelID s
"token": {api.token},
"channel": {channelID},
}
response := WebResponse{}
response := SlackResponse{}
err := post(ctx, api.httpclient, "conversations.unarchive", values, &response, api.debug)
if err != nil {
return err
Expand All @@ -153,7 +153,7 @@ func (api *Client) SetTopicOfConversationContext(ctx context.Context, channelID,
"topic": {topic},
}
response := struct {
WebResponse
SlackResponse
Channel *Channel `json:"channel"`
}{}
err := post(ctx, api.httpclient, "conversations.setTopic", values, &response, api.debug)
Expand All @@ -177,7 +177,7 @@ func (api *Client) SetPurposeOfConversationContext(ctx context.Context, channelI
"purpose": {purpose},
}
response := struct {
WebResponse
SlackResponse
Channel *Channel `json:"channel"`
}{}
err := post(ctx, api.httpclient, "conversations.setPurpose", values, &response, api.debug)
Expand All @@ -201,7 +201,7 @@ func (api *Client) RenameConversationContext(ctx context.Context, channelID, cha
"name": {channelName},
}
response := struct {
WebResponse
SlackResponse
Channel *Channel `json:"channel"`
}{}
err := post(ctx, api.httpclient, "conversations.rename", values, &response, api.debug)
Expand All @@ -225,7 +225,7 @@ func (api *Client) InviteUsersToConversationContext(ctx context.Context, channel
"users": {strings.Join(users, ",")},
}
response := struct {
WebResponse
SlackResponse
Channel *Channel `json:"channel"`
}{}
err := post(ctx, api.httpclient, "conversations.invite", values, &response, api.debug)
Expand All @@ -248,7 +248,7 @@ func (api *Client) KickUserFromConversationContext(ctx context.Context, channelI
"channel": {channelID},
"user": {user},
}
response := WebResponse{}
response := SlackResponse{}
err := post(ctx, api.httpclient, "conversations.kick", values, &response, api.debug)
if err != nil {
return err
Expand All @@ -269,7 +269,7 @@ func (api *Client) CloseConversationContext(ctx context.Context, channelID strin
"channel": {channelID},
}
response := struct {
WebResponse
SlackResponse
NoOp bool `json:"no_op"`
AlreadyClosed bool `json:"already_closed"`
}{}
Expand Down Expand Up @@ -380,7 +380,7 @@ func (api *Client) GetConversationRepliesContext(ctx context.Context, params *Ge
values.Add("inclusive", "0")
}
response := struct {
WebResponse
SlackResponse
HasMore bool `json:"has_more"`
ResponseMetaData struct {
NextCursor string `json:"next_cursor"`
Expand Down Expand Up @@ -426,7 +426,7 @@ func (api *Client) GetConversationsContext(ctx context.Context, params *GetConve
response := struct {
Channels []Channel `json:"channels"`
ResponseMetaData responseMetaData `json:"response_metadata"`
WebResponse
SlackResponse
}{}
err = post(ctx, api.httpclient, "conversations.list", values, &response, api.debug)
if err != nil {
Expand Down Expand Up @@ -463,7 +463,7 @@ func (api *Client) OpenConversationContext(ctx context.Context, params *OpenConv
Channel *Channel `json:"channel"`
NoOp bool `json:"no_op"`
AlreadyOpen bool `json:"already_open"`
WebResponse
SlackResponse
}{}
err := post(ctx, api.httpclient, "conversations.open", values, &response, api.debug)
if err != nil {
Expand All @@ -487,7 +487,7 @@ func (api *Client) JoinConversationContext(ctx context.Context, channelID string
ResponseMetaData *struct {
Warnings []string `json:"warnings"`
} `json:"response_metadata"`
WebResponse
SlackResponse
}{}
err := post(ctx, api.httpclient, "conversations.join", values, &response, api.debug)
if err != nil {
Expand All @@ -513,7 +513,7 @@ type GetConversationHistoryParameters struct {
}

type GetConversationHistoryResponse struct {
WebResponse
SlackResponse
HasMore bool `json:"has_more"`
PinCount int `json:"pin_count"`
Latest string `json:"latest"`
Expand Down
40 changes: 20 additions & 20 deletions conversation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ func getTestMembers() []string {
func getUsersInConversation(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
WebResponse
SlackResponse
Members []string `json:"members"`
ResponseMetaData responseMetaData `json:"response_metadata"`
}{
WebResponse: WebResponse{Ok: true},
SlackResponse: SlackResponse{Ok: true},
Members: getTestMembers(),
ResponseMetaData: responseMetaData{NextCursor: ""},
})
Expand Down Expand Up @@ -279,11 +279,11 @@ func getTestChannel() *Channel {
func okChannelJsonHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
WebResponse
SlackResponse
Channel *Channel `json:"channel"`
}{
WebResponse: WebResponse{Ok: true},
Channel: getTestChannel(),
SlackResponse: SlackResponse{Ok: true},
Channel: getTestChannel(),
})
rw.Write(response)
}
Expand Down Expand Up @@ -368,11 +368,11 @@ func TestKickUserFromConversation(t *testing.T) {
func closeConversationHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
WebResponse
SlackResponse
NoOp bool `json:"no_op"`
AlreadyClosed bool `json:"already_closed"`
}{
WebResponse: WebResponse{Ok: true}})
SlackResponse: SlackResponse{Ok: true}})
rw.Write(response)
}

Expand Down Expand Up @@ -423,10 +423,10 @@ func TestGetConversationInfo(t *testing.T) {
func leaveConversationHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
WebResponse
SlackResponse
NotInChannel bool `json:"not_in_channel"`
}{
WebResponse: WebResponse{Ok: true}})
SlackResponse: SlackResponse{Ok: true}})
rw.Write(response)
}

Expand All @@ -445,15 +445,15 @@ func TestLeaveConversation(t *testing.T) {
func getConversationRepliesHander(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
WebResponse
SlackResponse
HasMore bool `json:"has_more"`
ResponseMetaData struct {
NextCursor string `json:"next_cursor"`
} `json:"response_metadata"`
Messages []Message `json:"messages"`
}{
WebResponse: WebResponse{Ok: true},
Messages: []Message{}})
SlackResponse: SlackResponse{Ok: true},
Messages: []Message{}})
rw.Write(response)
}

Expand All @@ -476,14 +476,14 @@ func TestGetConversationReplies(t *testing.T) {
func getConversationsHander(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
WebResponse
SlackResponse
ResponseMetaData struct {
NextCursor string `json:"next_cursor"`
} `json:"response_metadata"`
Channels []Channel `json:"channels"`
}{
WebResponse: WebResponse{Ok: true},
Channels: []Channel{}})
SlackResponse: SlackResponse{Ok: true},
Channels: []Channel{}})
rw.Write(response)
}

Expand All @@ -503,12 +503,12 @@ func TestGetConversations(t *testing.T) {
func openConversationHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(struct {
WebResponse
SlackResponse
NoOp bool `json:"no_op"`
AlreadyOpen bool `json:"already_open"`
Channel *Channel `json:"channel"`
}{
WebResponse: WebResponse{Ok: true}})
SlackResponse: SlackResponse{Ok: true}})
rw.Write(response)
}

Expand All @@ -533,9 +533,9 @@ func joinConversationHandler(rw http.ResponseWriter, r *http.Request) {
ResponseMetaData *struct {
Warnings []string `json:"warnings"`
} `json:"response_metadata"`
WebResponse
SlackResponse
}{
WebResponse: WebResponse{Ok: true}})
SlackResponse: SlackResponse{Ok: true}})
rw.Write(response)
}

Expand All @@ -554,7 +554,7 @@ func TestJoinConversation(t *testing.T) {
func getConversationHistoryHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(GetConversationHistoryResponse{
WebResponse: WebResponse{Ok: true}})
SlackResponse: SlackResponse{Ok: true}})
rw.Write(response)
}

Expand Down
6 changes: 3 additions & 3 deletions dnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ type DNDStatus struct {

type dndResponseFull struct {
DNDStatus
WebResponse
SlackResponse
}

type dndTeamInfoResponse struct {
Users map[string]DNDStatus `json:"users"`
WebResponse
SlackResponse
}

func dndRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*dndResponseFull, error) {
Expand All @@ -59,7 +59,7 @@ func (api *Client) EndDNDContext(ctx context.Context) error {
"token": {api.token},
}

response := &WebResponse{}
response := &SlackResponse{}

if err := post(ctx, api.httpclient, "dnd.endDnd", values, response, api.debug); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type emojiResponseFull struct {
Emoji map[string]string `json:"emoji"`
WebResponse
SlackResponse
}

// GetEmoji retrieves all the emojis
Expand Down
2 changes: 1 addition & 1 deletion files.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ type fileResponseFull struct {
Comments []Comment `json:"comments"`
Files []File `json:"files"`

WebResponse
SlackResponse
}

// NewGetFilesParameters provides an instance of GetFilesParameters with all the sane default values set
Expand Down
4 changes: 2 additions & 2 deletions files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ func TestSlack_DeleteFileComment(t *testing.T) {
func authTestHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(authTestResponseFull{
WebResponse: WebResponse{Ok: true}})
SlackResponse: SlackResponse{Ok: true}})
rw.Write(response)
}

func uploadFileHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
response, _ := json.Marshal(fileResponseFull{
WebResponse: WebResponse{Ok: true}})
SlackResponse: SlackResponse{Ok: true}})
rw.Write(response)
}

Expand Down
2 changes: 1 addition & 1 deletion groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type groupResponseFull struct {
AlreadyInGroup bool `json:"already_in_group"`
Channel Channel `json:"channel"`
History
WebResponse
SlackResponse
}

func groupRequest(ctx context.Context, client HTTPRequester, path string, values url.Values, debug bool) (*groupResponseFull, error) {
Expand Down
2 changes: 1 addition & 1 deletion im.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type imResponseFull struct {
Channel imChannel `json:"channel"`
IMs []IM `json:"ims"`
History
WebResponse
SlackResponse
}

// IM contains information related to the Direct Message channel
Expand Down
2 changes: 1 addition & 1 deletion info.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type Info struct {

type infoResponseFull struct {
Info
WebResponse
SlackResponse
}

// GetBotByID returns a bot given a bot id
Expand Down
Loading

0 comments on commit 8e0186d

Please sign in to comment.