From 0c1f70a79670fb635af170fda70ea70e055586f2 Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Wed, 19 Sep 2018 18:12:37 +0300 Subject: [PATCH 1/4] add delivery & payment data for order struct --- README.md | 8 ++++++++ v1/client.go | 16 ++++++++++++++++ v1/client_test.go | 24 ++++++++++++++++++++++++ v1/types.go | 31 +++++++++++++++++++++++++------ 4 files changed, 73 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8ff63ad..576934e 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,14 @@ func main() { Quoting: ChannelFeatureReceive, Deleting: ChannelFeatureBoth, }, + Product: Product{ + Creating: ChannelFeatureSend, + Deleting: ChannelFeatureSend, + }, + Order: Order{ + Creating: ChannelFeatureBoth, + Deleting: ChannelFeatureSend, + }, }, } diff --git a/v1/client.go b/v1/client.go index 3dbe78e..6e94b0d 100644 --- a/v1/client.go +++ b/v1/client.go @@ -39,6 +39,14 @@ func New(url string, token string) *MgClient { // Quoting: ChannelFeatureReceive, // Deleting: ChannelFeatureSend, // }, +// Product: Product{ +// Creating: ChannelFeatureSend, +// Deleting: ChannelFeatureSend, +// }, +// Order: Order{ +// Creating: ChannelFeatureBoth, +// Deleting: ChannelFeatureSend, +// }, // }, // } // @@ -91,6 +99,14 @@ func (c *MgClient) ActivateTransportChannel(request Channel) (ActivateResponse, // Quoting: ChannelFeatureReceive, // Deleting: ChannelFeatureBoth, // }, +// Product: Product{ +// Creating: ChannelFeatureSend, +// Deleting: ChannelFeatureSend, +// }, +// Order: Order{ +// Creating: ChannelFeatureBoth, +// Deleting: ChannelFeatureSend, +// }, // }, // } // diff --git a/v1/client_test.go b/v1/client_test.go index 91a4870..0a52dc1 100644 --- a/v1/client_test.go +++ b/v1/client_test.go @@ -37,6 +37,14 @@ func TestMgClient_ActivateTransportChannel(t *testing.T) { Quoting: ChannelFeatureReceive, Deleting: ChannelFeatureBoth, }, + Product: Product{ + Creating: ChannelFeatureSend, + Deleting: ChannelFeatureSend, + }, + Order: Order{ + Creating: ChannelFeatureBoth, + Deleting: ChannelFeatureSend, + }, }, } @@ -66,6 +74,14 @@ func TestMgClient_ActivateNewTransportChannel(t *testing.T) { Quoting: ChannelFeatureBoth, Deleting: ChannelFeatureSend, }, + Product: Product{ + Creating: ChannelFeatureSend, + Deleting: ChannelFeatureSend, + }, + Order: Order{ + Creating: ChannelFeatureBoth, + Deleting: ChannelFeatureSend, + }, }, } @@ -107,6 +123,14 @@ func TestMgClient_UpdateTransportChannel(t *testing.T) { Quoting: ChannelFeatureBoth, Deleting: ChannelFeatureBoth, }, + Product: Product{ + Creating: ChannelFeatureSend, + Deleting: ChannelFeatureSend, + }, + Order: Order{ + Creating: ChannelFeatureBoth, + Deleting: ChannelFeatureSend, + }, }, } diff --git a/v1/types.go b/v1/types.go index 02c0014..f5196f7 100644 --- a/v1/types.go +++ b/v1/types.go @@ -204,12 +204,14 @@ type MessageDataProduct struct { // MessageDataOrder order data from webhook type MessageDataOrder struct { - Number string `json:"number"` - Url string `json:"url,omitempty"` - Date string `json:"date,omitempty"` - Cost *MessageDataOrderCost `json:"cost,omitempty"` - Status *MessageDataOrderStatus `json:"status,omitempty"` - Items []MessageDataOrderItem `json:"items,omitempty"` + Number string `json:"number"` + Url string `json:"url,omitempty"` + Date string `json:"date,omitempty"` + Cost *MessageDataOrderCost `json:"cost,omitempty"` + Status *MessageDataOrderStatus `json:"status,omitempty"` + Delivery *MessageDataOrderDelivery `json:"delivery"` + Payments []MessageDataOrderPayment `json:"payment"` + Items []MessageDataOrderItem `json:"items,omitempty"` } type MessageDataOrderStatus struct { @@ -234,6 +236,23 @@ type MessageDataOrderQuantity struct { Unit string `json:"unit"` } +type MessageDataOrderPayment struct { + Name string `json:"name"` + Status *MessageDataOrderPaymentStatus `json:"status"` + Amount *MessageDataOrderCost `json:"amount"` +} + +type MessageDataOrderPaymentStatus struct { + Name string `json:"name"` + Payed bool `json:"payed"` +} + +type MessageDataOrderDelivery struct { + Name string `json:"name"` + Amount *MessageDataOrderCost `json:"amount"` + Address string `json:"address"` +} + // TransportRequestMeta request metadata type TransportRequestMeta struct { ID uint64 `json:"id"` From 9df3b5a659d9980133b3c47d5fcfe045fb65ed7c Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Wed, 19 Sep 2018 18:14:28 +0300 Subject: [PATCH 2/4] fix README formatting --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 576934e..0147d4f 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,11 @@ func main() { }, Product: Product{ Creating: ChannelFeatureSend, - Deleting: ChannelFeatureSend, + Deleting: ChannelFeatureSend, }, Order: Order{ - Creating: ChannelFeatureBoth, - Deleting: ChannelFeatureSend, + Creating: ChannelFeatureBoth, + Deleting: ChannelFeatureSend, }, }, } From 4c882fa250f1b8f83e5583534fc636f82c487f5d Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Thu, 20 Sep 2018 11:26:02 +0300 Subject: [PATCH 3/4] add oneof for order status --- v1/types.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/v1/types.go b/v1/types.go index f5196f7..0bfe8bc 100644 --- a/v1/types.go +++ b/v1/types.go @@ -20,6 +20,13 @@ const ( MsgTypeCommand string = "command" MsgTypeOrder string = "order" MsgTypeProduct string = "product" + + MsgOrderStatusCodeNew = "new" + MsgOrderStatusCodeApproval = "approval" + MsgOrderStatusCodeAssembling = "assembling" + MsgOrderStatusCodeDelivery = "delivery" + MsgOrderStatusCodeComplete = "complete" + MsgOrderStatusCodeCancel = "cancel" ) // MgClient type From af3a3f86ee29b532e552d3817d5c390bcffa9214 Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Thu, 20 Sep 2018 11:37:16 +0300 Subject: [PATCH 4/4] add currency codes --- v1/types.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/v1/types.go b/v1/types.go index 0bfe8bc..3bdfb22 100644 --- a/v1/types.go +++ b/v1/types.go @@ -27,6 +27,13 @@ const ( MsgOrderStatusCodeDelivery = "delivery" MsgOrderStatusCodeComplete = "complete" MsgOrderStatusCodeCancel = "cancel" + + MsgCurrencyRub = "rub" + MsgCurrencyUah = "uah" + MsgCurrencyByr = "byr" + MsgCurrencyKzt = "kzt" + MsgCurrencyUsd = "usd" + MsgCurrencyEur = "eur" ) // MgClient type