diff --git a/chat/chat.go b/chat/chat.go index 00a2cda..9d25925 100644 --- a/chat/chat.go +++ b/chat/chat.go @@ -9,7 +9,7 @@ import ( type Chat interface { // user - GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (UserUnreadMessages, *errors.Error) + GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (UserUnreadMessagesResponse, *errors.Error) GetUserJoinedChannelCount(ctx context.Context, params UserJoinedChannelCountParams) (resp UserJoinedChannelCountResponse, err *errors.Error) CreateUser(ctx context.Context, request CreateUserRequest) (resp CreateUserResponse, err *errors.Error) diff --git a/chat/chat_user.go b/chat/chat_user.go index defc80d..741e63a 100644 --- a/chat/chat_user.go +++ b/chat/chat_user.go @@ -17,7 +17,7 @@ func (c *ChatImpl) CreateUser(ctx context.Context, request CreateUserRequest) (r return } -func (c *ChatImpl) GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (resp UserUnreadMessages, err *errors.Error) { +func (c *ChatImpl) GetUserUnreadMessages(ctx context.Context, params UserUnreadMessagesParams) (resp UserUnreadMessagesResponse, err *errors.Error) { url := fmt.Sprintf("/v3/users/%s/unread_message_count", params.UserID) err = c.Client.Call(ctx, http.MethodGet, url, nil, nil, &resp) if err != nil { diff --git a/chat/chat_user_test.go b/chat/chat_user_test.go index 52a9712..8e8a131 100644 --- a/chat/chat_user_test.go +++ b/chat/chat_user_test.go @@ -21,7 +21,7 @@ func (m *mockGetUserUnreadMessages) Call(ctx context.Context, method string, url return args.Get(0).(*errors.Error) } - result.(*UserUnreadMessages).UnreadCount = 10 + result.(*UserUnreadMessagesResponse).UnreadCount = 10 return nil } @@ -38,7 +38,7 @@ func TestGetUserUnreadMessages(t *testing.T) { name string args args setupMock func(m *mockGetUserUnreadMessages) - wantExpected UserUnreadMessages + wantExpected UserUnreadMessagesResponse wantError *errors.Error }{ { @@ -52,10 +52,10 @@ func TestGetUserUnreadMessages(t *testing.T) { fmt.Sprintf("/v3/users/%s/unread_message_count", "111001100"), http.Header(nil), nil, - &UserUnreadMessages{}, + &UserUnreadMessagesResponse{}, ).Return(nil) }, - wantExpected: UserUnreadMessages{UnreadCount: 10}, + wantExpected: UserUnreadMessagesResponse{UnreadCount: 10}, wantError: nil, }, { @@ -69,7 +69,7 @@ func TestGetUserUnreadMessages(t *testing.T) { fmt.Sprintf("/v3/users/%s/unread_message_count", "000000000"), http.Header(nil), nil, - &UserUnreadMessages{}, + &UserUnreadMessagesResponse{}, ).Return(errors.FromHTTPErr(400, []byte(` { "message": "\"User\" not found.", @@ -78,7 +78,7 @@ func TestGetUserUnreadMessages(t *testing.T) { } `))) }, - wantExpected: UserUnreadMessages{}, + wantExpected: UserUnreadMessagesResponse{}, wantError: errors.FromHTTPErr(400, []byte(` { "message": "\"User\" not found.", diff --git a/chat/model_user.go b/chat/model_user.go index d0e9a47..89b0654 100644 --- a/chat/model_user.go +++ b/chat/model_user.go @@ -1,6 +1,6 @@ package chat -type UserUnreadMessages struct { +type UserUnreadMessagesResponse struct { UnreadCount int `json:"unread_count"` }