Change the data structure of chat response according to the updates from Ozon (#102)
This commit is contained in:
@@ -39,7 +39,7 @@ type ListChatsResponse struct {
|
|||||||
core.CommonResponse
|
core.CommonResponse
|
||||||
|
|
||||||
// Chats data
|
// Chats data
|
||||||
Chats []ListChatsChat `json:"chats"`
|
Chats []ListChatsChatData `json:"chats"`
|
||||||
|
|
||||||
// Total number of chats
|
// Total number of chats
|
||||||
TotalChatsCount int64 `json:"total_chats_count"`
|
TotalChatsCount int64 `json:"total_chats_count"`
|
||||||
@@ -48,20 +48,6 @@ type ListChatsResponse struct {
|
|||||||
TotalUnreadCount int64 `json:"total_unread_count"`
|
TotalUnreadCount int64 `json:"total_unread_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListChatsChat struct {
|
|
||||||
// Chat data
|
|
||||||
Chat ListChatsChatData `json:"chat"`
|
|
||||||
|
|
||||||
// Identifier of the first unread chat message
|
|
||||||
FirstUnreadMessageId uint64 `json:"first_unread_message_id"`
|
|
||||||
|
|
||||||
// Identifier of the last message in the chat
|
|
||||||
LastMessageId uint64 `json:"last_message_id"`
|
|
||||||
|
|
||||||
// Number of unread messages in the chat
|
|
||||||
UnreadCount int64 `json:"unread_count"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListChatsChatData struct {
|
type ListChatsChatData struct {
|
||||||
// Chat identifier
|
// Chat identifier
|
||||||
ChatId string `json:"chat_id"`
|
ChatId string `json:"chat_id"`
|
||||||
@@ -79,6 +65,15 @@ type ListChatsChatData struct {
|
|||||||
|
|
||||||
// Chat creation date
|
// Chat creation date
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
|
|
||||||
|
// Identifier of the first unread chat message
|
||||||
|
FirstUnreadMessageId uint64 `json:"first_unread_message_id"`
|
||||||
|
|
||||||
|
// Identifier of the last message in the chat
|
||||||
|
LastMessageId uint64 `json:"last_message_id"`
|
||||||
|
|
||||||
|
// Number of unread messages in the chat
|
||||||
|
UnreadCount int64 `json:"unread_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns information about chats by specified filters
|
// Returns information about chats by specified filters
|
||||||
|
|||||||
@@ -32,15 +32,13 @@ func TestListChats(t *testing.T) {
|
|||||||
`{
|
`{
|
||||||
"chats": [
|
"chats": [
|
||||||
{
|
{
|
||||||
"chat": {
|
"chat_id": "5e767w03-b400-4y1b-a841-75319ca8a5c8",
|
||||||
"created_at": "2022-07-22T08:07:19.581Z",
|
"chat_status": "Opened",
|
||||||
"chat_id": "5e767w03-b400-4y1b-a841-75319ca8a5c8",
|
"chat_type": "Seller_Support",
|
||||||
"chat_status": "Opened",
|
"created_at": "2022-07-22T08:07:19.581Z",
|
||||||
"chat_type": "Seller_Support"
|
"unread_count": 1,
|
||||||
},
|
"last_message_id": 3000000000128004274,
|
||||||
"first_unread_message_id": 3000000000118021931,
|
"first_unread_message_id": 3000000000118021931
|
||||||
"last_message_id": 3000000000128004274,
|
|
||||||
"unread_count": 1
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"total_chats_count": 25,
|
"total_chats_count": 25,
|
||||||
@@ -77,10 +75,10 @@ func TestListChats(t *testing.T) {
|
|||||||
|
|
||||||
if resp.StatusCode == http.StatusOK {
|
if resp.StatusCode == http.StatusOK {
|
||||||
if len(resp.Chats) > 0 {
|
if len(resp.Chats) > 0 {
|
||||||
if resp.Chats[0].Chat.ChatStatus == "" {
|
if resp.Chats[0].ChatStatus == "" {
|
||||||
t.Errorf("Chat status cannot be empty")
|
t.Errorf("Chat status cannot be empty")
|
||||||
}
|
}
|
||||||
if resp.Chats[0].Chat.ChatType == "" {
|
if resp.Chats[0].ChatType == "" {
|
||||||
t.Errorf("Chat type cannot be empty")
|
t.Errorf("Chat type cannot be empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user