Change the data structure of chat response according to the updates from Ozon (#102)

This commit is contained in:
Pireirik
2024-09-09 21:09:31 +02:00
committed by GitHub
parent ccd3610c76
commit 895ef8be52
2 changed files with 19 additions and 26 deletions

View File

@@ -39,7 +39,7 @@ type ListChatsResponse struct {
core.CommonResponse
// Chats data
Chats []ListChatsChat `json:"chats"`
Chats []ListChatsChatData `json:"chats"`
// Total number of chats
TotalChatsCount int64 `json:"total_chats_count"`
@@ -48,20 +48,6 @@ type ListChatsResponse struct {
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 {
// Chat identifier
ChatId string `json:"chat_id"`
@@ -79,6 +65,15 @@ type ListChatsChatData struct {
// Chat creation date
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

View File

@@ -32,15 +32,13 @@ func TestListChats(t *testing.T) {
`{
"chats": [
{
"chat": {
"created_at": "2022-07-22T08:07:19.581Z",
"chat_id": "5e767w03-b400-4y1b-a841-75319ca8a5c8",
"chat_status": "Opened",
"chat_type": "Seller_Support"
},
"first_unread_message_id": 3000000000118021931,
"last_message_id": 3000000000128004274,
"unread_count": 1
"chat_id": "5e767w03-b400-4y1b-a841-75319ca8a5c8",
"chat_status": "Opened",
"chat_type": "Seller_Support",
"created_at": "2022-07-22T08:07:19.581Z",
"unread_count": 1,
"last_message_id": 3000000000128004274,
"first_unread_message_id": 3000000000118021931
}
],
"total_chats_count": 25,
@@ -77,10 +75,10 @@ func TestListChats(t *testing.T) {
if resp.StatusCode == http.StatusOK {
if len(resp.Chats) > 0 {
if resp.Chats[0].Chat.ChatStatus == "" {
if resp.Chats[0].ChatStatus == "" {
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")
}
}