From 6ec32f47916923204cc707f630864f42c2330ceb Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Wed, 12 Sep 2018 00:33:51 +0300 Subject: [PATCH 1/2] add prouct & order messages structs --- v1/types.go | 88 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/v1/types.go b/v1/types.go index ca68a36..d339d9c 100644 --- a/v1/types.go +++ b/v1/types.go @@ -308,29 +308,31 @@ type ( // Single entity types type ( Message struct { - ID uint64 `json:"id"` - Time string `json:"time"` - Type string `json:"type"` - ChatID uint64 `json:"chat_id"` - IsRead bool `json:"is_read"` - Status string `json:"status"` - TextMessage - SystemMessage + ID uint64 `json:"id"` + Time string `json:"time"` + Type string `json:"type"` + Scope string `json:"scope"` + ChatID uint64 `json:"chat_id"` + IsRead bool `json:"is_read"` + IsEdit bool `json:"is_edit"` + Status string `json:"status"` + From *UserRef `json:"from"` + Product *MessageProduct `json:"product,omitempty"` + Order *MessageOrder `json:"order,omitempty"` + *TextMessage + *SystemMessage } TextMessage struct { - Scope string `json:"scope"` - Content string `json:"content"` - From UserRef `json:"from"` - Quote QuoteMessage `json:"quote"` - IsEdit bool `json:"is_edit"` - Actions []string `json:"actions"` + Content string `json:"content"` + Quote *QuoteMessage `json:"quote"` + Actions []string `json:"actions"` } SystemMessage struct { - Action string `json:"action"` - Dialog SystemMessageDialog `json:"dialog,omitempty"` - User UserRef `json:"user,omitempty"` + Action string `json:"action"` + Dialog *SystemMessageDialog `json:"dialog,omitempty"` + User *UserRef `json:"user,omitempty"` } SystemMessageDialog struct { @@ -338,19 +340,51 @@ type ( } QuoteMessage struct { - ID uint64 `json:"id"` - Content string `json:"content"` - Time string `json:"time"` - From UserRef `json:"from"` + ID uint64 `json:"id"` + Content string `json:"content"` + Time string `json:"time"` + From *UserRef `json:"from"` + } + + MessageProduct struct { + ID uint64 `json:"id"` + Name string `json:"name"` + Article string `json:"article,omitempty"` + Url string `json:"url,omitempty"` + Img string `json:"img,omitempty"` + Cost string `json:"cost,omitempty"` + Quantity string `json:"quantity,omitempty"` + } + + MessageOrder struct { + Number string `json:"number"` + Url string `json:"url,omitempty"` + Date string `json:"date,omitempty"` + Cost string `json:"cost,omitempty"` + Status *MessageOrderStatus `json:"status,omitempty"` + Items []MessageOrderItem `json:"items,omitempty"` + } + + MessageOrderStatus struct { + Code string `json:"code,omitempty"` + Name string `json:"name,omitempty"` + } + + MessageOrderItem struct { + Name string `json:"name,omitempty"` + Url string `json:"url,omitempty"` + Quantity string `json:"quantity,omitempty"` + Price string `json:"price,omitempty"` } UserRef struct { - ID uint64 `json:"id"` - Avatar string `json:"avatar"` - Type string `json:"type"` - Name string `json:"name"` - Phone string `json:"phone,omitempty"` - Email string `json:"email,omitempty"` + ID uint64 `json:"id"` + Avatar string `json:"avatar"` + Type string `json:"type"` + FirstName string `json:"first_name,omitempty"` + LastName string `json:"last_name,omitempty"` + Phone string `json:"phone,omitempty"` + Email string `json:"email,omitempty"` } Channel struct { From 5f509e4f2cb35aaea48c4c8c6051464c70a7081e Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Wed, 12 Sep 2018 10:36:19 +0300 Subject: [PATCH 2/2] update order & product structs --- v1/types.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/v1/types.go b/v1/types.go index d339d9c..1df5a2c 100644 --- a/v1/types.go +++ b/v1/types.go @@ -347,20 +347,20 @@ type ( } MessageProduct struct { - ID uint64 `json:"id"` - Name string `json:"name"` - Article string `json:"article,omitempty"` - Url string `json:"url,omitempty"` - Img string `json:"img,omitempty"` - Cost string `json:"cost,omitempty"` - Quantity string `json:"quantity,omitempty"` + ID uint64 `json:"id"` + Name string `json:"name"` + Article string `json:"article,omitempty"` + Url string `json:"url,omitempty"` + Img string `json:"img,omitempty"` + Cost *MessageOrderCost `json:"cost,omitempty"` + Quantity *MessageOrderQuantity `json:"quantity,omitempty"` } MessageOrder struct { Number string `json:"number"` Url string `json:"url,omitempty"` Date string `json:"date,omitempty"` - Cost string `json:"cost,omitempty"` + Cost *MessageOrderCost `json:"cost,omitempty"` Status *MessageOrderStatus `json:"status,omitempty"` Items []MessageOrderItem `json:"items,omitempty"` } @@ -377,6 +377,16 @@ type ( Price string `json:"price,omitempty"` } + MessageOrderCost struct { + Value float32 `json:"value,omitempty"` + Currency string `json:"currency"` + } + + MessageOrderQuantity struct { + Value float32 `json:"value"` + Unit string `json:"unit"` + } + UserRef struct { ID uint64 `json:"id"` Avatar string `json:"avatar"`