From 5b3c22ab9d196cd749fa1a53f577bdc99b69bad1 Mon Sep 17 00:00:00 2001 From: daisukefunase Date: Wed, 31 Jan 2024 13:03:02 +0900 Subject: [PATCH 1/6] feat: add customer response property marketing --- customer.go | 58 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/customer.go b/customer.go index d3071c5c..89e4cf75 100644 --- a/customer.go +++ b/customer.go @@ -40,27 +40,30 @@ type CustomerServiceOp struct { // Customer represents a Shopify customer type Customer struct { - ID int64 `json:"id,omitempty"` - Email string `json:"email,omitempty"` - FirstName string `json:"first_name,omitempty"` - LastName string `json:"last_name,omitempty"` - State string `json:"state,omitempty"` - Note string `json:"note,omitempty"` - VerifiedEmail bool `json:"verified_email,omitempty"` - MultipassIdentifier string `json:"multipass_identifier,omitempty"` - OrdersCount int `json:"orders_count,omitempty"` - TaxExempt bool `json:"tax_exempt,omitempty"` - TotalSpent *decimal.Decimal `json:"total_spent,omitempty"` - Phone string `json:"phone,omitempty"` - Tags string `json:"tags,omitempty"` - LastOrderId int64 `json:"last_order_id,omitempty"` - LastOrderName string `json:"last_order_name,omitempty"` - AcceptsMarketing bool `json:"accepts_marketing,omitempty"` - DefaultAddress *CustomerAddress `json:"default_address,omitempty"` - Addresses []*CustomerAddress `json:"addresses,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - Metafields []Metafield `json:"metafields,omitempty"` + ID int64 `json:"id,omitempty"` + Email string `json:"email,omitempty"` + FirstName string `json:"first_name,omitempty"` + LastName string `json:"last_name,omitempty"` + State string `json:"state,omitempty"` + Note string `json:"note,omitempty"` + VerifiedEmail bool `json:"verified_email,omitempty"` + MultipassIdentifier string `json:"multipass_identifier,omitempty"` + OrdersCount int `json:"orders_count,omitempty"` + TaxExempt bool `json:"tax_exempt,omitempty"` + TotalSpent *decimal.Decimal `json:"total_spent,omitempty"` + Phone string `json:"phone,omitempty"` + Tags string `json:"tags,omitempty"` + LastOrderId int64 `json:"last_order_id,omitempty"` + LastOrderName string `json:"last_order_name,omitempty"` + AcceptsMarketing bool `json:"accepts_marketing,omitempty"` + AcceptsMarketingUpdatedAt *time.Time `json:"accepts_marketing_updated_at,omitempty"` + EmailMarketingConsent *EmailMarketingConsent `json:"email_marketing_consent"` + SMSMarketingConsent *SMSMarketingConsent `json:"sms_marketing_consent"` + DefaultAddress *CustomerAddress `json:"default_address,omitempty"` + Addresses []*CustomerAddress `json:"addresses,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + Metafields []Metafield `json:"metafields,omitempty"` } // Represents the result from the customers/X.json endpoint @@ -87,6 +90,19 @@ type CustomerSearchOptions struct { Query string `url:"query,omitempty"` } +type EmailMarketingConsent struct { + State string `json:"state"` + OptInLevel string `json:"opt_in_level"` + ConsentUpdatedAt time.Time `json:"consent_updated_at"` +} + +type SMSMarketingConsent struct { + State string `json:"state"` + OptInLevel string `json:"opt_in_level"` + ConsentUpdatedAt time.Time `json:"consent_updated_at"` + ConsentCollectedFrom string `json:"consent_collected_from"` +} + // List customers func (s *CustomerServiceOp) List(ctx context.Context, options interface{}) ([]Customer, error) { path := fmt.Sprintf("%s.json", customersBasePath) From fdc6c46ed720519e17a5ed816937608e0ebc33e0 Mon Sep 17 00:00:00 2001 From: daisukefunase Date: Wed, 31 Jan 2024 13:03:09 +0900 Subject: [PATCH 2/6] add:test --- customer_test.go | 81 +++++++++++++++++++++++++++++++++--------- fixtures/customer.json | 12 +++++++ 2 files changed, 76 insertions(+), 17 deletions(-) diff --git a/customer_test.go b/customer_test.go index c6722d60..a67403b3 100644 --- a/customer_test.go +++ b/customer_test.go @@ -227,25 +227,40 @@ func TestCustomerGet(t *testing.T) { createdAt := time.Date(2017, time.September, 23, 18, 15, 47, 0, time.UTC) updatedAt := time.Date(2017, time.September, 23, 18, 15, 47, 0, time.UTC) totalSpent := decimal.NewFromFloat(278.60) + emailMarketingConsent1 := EmailMarketingConsent{ + State: "not_subscribed", + OptInLevel: "single_opt_in", + ConsentUpdatedAt: updatedAt, + } + + smsMarketingConsent1 := SMSMarketingConsent{ + State: "not_subscribed", + OptInLevel: "single_opt_in", + ConsentUpdatedAt: updatedAt, + ConsentCollectedFrom: "OTHER", + } expectation := &Customer{ - ID: 1, - Email: "test@example.com", - FirstName: "Test", - LastName: "Citizen", - AcceptsMarketing: true, - VerifiedEmail: true, - TaxExempt: false, - OrdersCount: 4, - State: "enabled", - TotalSpent: &totalSpent, - LastOrderId: 123, - Note: "", - Phone: "", - DefaultAddress: address1, - Addresses: []*CustomerAddress{address1}, - CreatedAt: &createdAt, - UpdatedAt: &updatedAt, + ID: 1, + Email: "test@example.com", + FirstName: "Test", + LastName: "Citizen", + AcceptsMarketing: true, + VerifiedEmail: true, + TaxExempt: false, + OrdersCount: 4, + State: "enabled", + TotalSpent: &totalSpent, + LastOrderId: 123, + Note: "", + Phone: "", + AcceptsMarketingUpdatedAt: &updatedAt, + EmailMarketingConsent: &emailMarketingConsent1, + SMSMarketingConsent: &smsMarketingConsent1, + DefaultAddress: address1, + Addresses: []*CustomerAddress{address1}, + CreatedAt: &createdAt, + UpdatedAt: &updatedAt, } if customer.ID != expectation.ID { @@ -354,6 +369,38 @@ func TestCustomerGet(t *testing.T) { if len(customer.Addresses) != len(expectation.Addresses) { t.Errorf("Customer.Addresses count returned %d, expected %d", len(customer.Addresses), len(expectation.Addresses)) } + if !customer.AcceptsMarketingUpdatedAt.Equal(*expectation.AcceptsMarketingUpdatedAt) { + t.Errorf("Customer.AcceptsMarketingUpdatedAt returned %+v, expected %+v", customer.AcceptsMarketingUpdatedAt, expectation.AcceptsMarketingUpdatedAt) + } + if customer.EmailMarketingConsent == nil { + t.Errorf("Customer.EmailMarketingConsent is nil, expected not nil") + } else { + if !customer.EmailMarketingConsent.ConsentUpdatedAt.Equal(expectation.EmailMarketingConsent.ConsentUpdatedAt) { + t.Errorf("Customer.EmailMarketingConsent.ConsentUpdatedAt returned %+v, expected %+v", customer.EmailMarketingConsent.ConsentUpdatedAt, expectation.EmailMarketingConsent.ConsentUpdatedAt) + } + if customer.EmailMarketingConsent.State != expectation.EmailMarketingConsent.State { + t.Errorf("Customer.EmailMarketingConsent.State returned %+v, expected %+v", customer.EmailMarketingConsent.State, expectation.EmailMarketingConsent.State) + } + if customer.EmailMarketingConsent.OptInLevel != expectation.EmailMarketingConsent.OptInLevel { + t.Errorf("Customer.EmailMarketingConsent.OptInLevel returned %+v, expected %+v", customer.EmailMarketingConsent.OptInLevel, expectation.EmailMarketingConsent.OptInLevel) + } + } + if customer.SMSMarketingConsent == nil { + t.Errorf("Customer.SMSMarketingConsent is nil, expected not nil") + } else { + if !customer.SMSMarketingConsent.ConsentUpdatedAt.Equal(expectation.SMSMarketingConsent.ConsentUpdatedAt) { + t.Errorf("Customer.SMSMarketingConsent.ConsentUpdatedAt returned %+v, expected %+v", customer.SMSMarketingConsent.ConsentUpdatedAt, expectation.SMSMarketingConsent.ConsentUpdatedAt) + } + if customer.SMSMarketingConsent.State != expectation.SMSMarketingConsent.State { + t.Errorf("Customer.SMSMarketingConsent.State returned %+v, expected %+v", customer.SMSMarketingConsent.State, expectation.SMSMarketingConsent.State) + } + if customer.SMSMarketingConsent.OptInLevel != expectation.SMSMarketingConsent.OptInLevel { + t.Errorf("Customer.SMSMarketingConsent.OptInLevel returned %+v, expected %+v", customer.SMSMarketingConsent.OptInLevel, expectation.SMSMarketingConsent.OptInLevel) + } + if customer.SMSMarketingConsent.ConsentCollectedFrom != expectation.SMSMarketingConsent.ConsentCollectedFrom { + t.Errorf("Customer.SMSMarketingConsent.ConsentCollectedFrom returned %+v, expected %+v", customer.SMSMarketingConsent.ConsentCollectedFrom, expectation.SMSMarketingConsent.ConsentCollectedFrom) + } + } } func TestCustomerUpdate(t *testing.T) { diff --git a/fixtures/customer.json b/fixtures/customer.json index 5a22b6db..c0a99749 100644 --- a/fixtures/customer.json +++ b/fixtures/customer.json @@ -39,6 +39,18 @@ "default": true } ], + "accepts_marketing_updated_at": "2017-09-23T18:15:47-00:00", + "email_marketing_consent": { + "state": "not_subscribed", + "opt_in_level": "single_opt_in", + "consent_updated_at": "2017-09-23T18:15:47-00:00" + }, + "sms_marketing_consent": { + "state": "not_subscribed", + "opt_in_level": "single_opt_in", + "consent_updated_at": "2017-09-23T18:15:47-00:00", + "consent_collected_from": "OTHER" + }, "default_address": { "id": 1, "customer_id": 1, From fccafb839c5ee5f58b4a113b45052bc7c0c50d04 Mon Sep 17 00:00:00 2001 From: daisukefunase Date: Wed, 31 Jan 2024 18:50:20 +0900 Subject: [PATCH 3/6] bugfix/updatedAt in Marketing is not pointer type --- customer.go | 14 +++++++------- customer_test.go | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/customer.go b/customer.go index 89e4cf75..81f3c915 100644 --- a/customer.go +++ b/customer.go @@ -91,16 +91,16 @@ type CustomerSearchOptions struct { } type EmailMarketingConsent struct { - State string `json:"state"` - OptInLevel string `json:"opt_in_level"` - ConsentUpdatedAt time.Time `json:"consent_updated_at"` + State string `json:"state"` + OptInLevel string `json:"opt_in_level"` + ConsentUpdatedAt *time.Time `json:"consent_updated_at"` } type SMSMarketingConsent struct { - State string `json:"state"` - OptInLevel string `json:"opt_in_level"` - ConsentUpdatedAt time.Time `json:"consent_updated_at"` - ConsentCollectedFrom string `json:"consent_collected_from"` + State string `json:"state"` + OptInLevel string `json:"opt_in_level"` + ConsentUpdatedAt *time.Time `json:"consent_updated_at"` + ConsentCollectedFrom string `json:"consent_collected_from"` } // List customers diff --git a/customer_test.go b/customer_test.go index a67403b3..11d8d957 100644 --- a/customer_test.go +++ b/customer_test.go @@ -230,13 +230,13 @@ func TestCustomerGet(t *testing.T) { emailMarketingConsent1 := EmailMarketingConsent{ State: "not_subscribed", OptInLevel: "single_opt_in", - ConsentUpdatedAt: updatedAt, + ConsentUpdatedAt: &updatedAt, } smsMarketingConsent1 := SMSMarketingConsent{ State: "not_subscribed", OptInLevel: "single_opt_in", - ConsentUpdatedAt: updatedAt, + ConsentUpdatedAt: &updatedAt, ConsentCollectedFrom: "OTHER", } @@ -375,7 +375,7 @@ func TestCustomerGet(t *testing.T) { if customer.EmailMarketingConsent == nil { t.Errorf("Customer.EmailMarketingConsent is nil, expected not nil") } else { - if !customer.EmailMarketingConsent.ConsentUpdatedAt.Equal(expectation.EmailMarketingConsent.ConsentUpdatedAt) { + if !customer.EmailMarketingConsent.ConsentUpdatedAt.Equal(*expectation.EmailMarketingConsent.ConsentUpdatedAt) { t.Errorf("Customer.EmailMarketingConsent.ConsentUpdatedAt returned %+v, expected %+v", customer.EmailMarketingConsent.ConsentUpdatedAt, expectation.EmailMarketingConsent.ConsentUpdatedAt) } if customer.EmailMarketingConsent.State != expectation.EmailMarketingConsent.State { @@ -388,7 +388,7 @@ func TestCustomerGet(t *testing.T) { if customer.SMSMarketingConsent == nil { t.Errorf("Customer.SMSMarketingConsent is nil, expected not nil") } else { - if !customer.SMSMarketingConsent.ConsentUpdatedAt.Equal(expectation.SMSMarketingConsent.ConsentUpdatedAt) { + if !customer.SMSMarketingConsent.ConsentUpdatedAt.Equal(*expectation.SMSMarketingConsent.ConsentUpdatedAt) { t.Errorf("Customer.SMSMarketingConsent.ConsentUpdatedAt returned %+v, expected %+v", customer.SMSMarketingConsent.ConsentUpdatedAt, expectation.SMSMarketingConsent.ConsentUpdatedAt) } if customer.SMSMarketingConsent.State != expectation.SMSMarketingConsent.State { From 75c49588cf1bc369c50983b9a0a1ff7b55a23c72 Mon Sep 17 00:00:00 2001 From: daisukefunase Date: Mon, 26 Feb 2024 09:42:56 +0900 Subject: [PATCH 4/6] update:add following feilds in order - TotalTaxSet - CurrentTotalTaxSet - TotalDiscountSet - CurrentTotalDiscountSet --- order.go | 149 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/order.go b/order.go index 46ad9b7c..33bd3f3a 100644 --- a/order.go +++ b/order.go @@ -190,79 +190,82 @@ const ( // Order represents a Shopify order type Order struct { - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Email string `json:"email,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - CancelledAt *time.Time `json:"cancelled_at,omitempty"` - ClosedAt *time.Time `json:"closed_at,omitempty"` - ProcessedAt *time.Time `json:"processed_at,omitempty"` - Customer *Customer `json:"customer,omitempty"` - BillingAddress *Address `json:"billing_address,omitempty"` - ShippingAddress *Address `json:"shipping_address,omitempty"` - Currency string `json:"currency,omitempty"` - TotalPrice *decimal.Decimal `json:"total_price,omitempty"` - TotalPriceSet *AmountSet `json:"total_price_set,omitempty"` - TotalShippingPriceSet *AmountSet `json:"total_shipping_price_set,omitempty"` - CurrentTotalPrice *decimal.Decimal `json:"current_total_price,omitempty"` - SubtotalPrice *decimal.Decimal `json:"subtotal_price,omitempty"` - CurrentSubtotalPrice *decimal.Decimal `json:"current_subtotal_price,omitempty"` - TotalDiscounts *decimal.Decimal `json:"total_discounts,omitempty"` - CurrentTotalDiscounts *decimal.Decimal `json:"current_total_discounts,omitempty"` - TotalLineItemsPrice *decimal.Decimal `json:"total_line_items_price,omitempty"` - TaxesIncluded bool `json:"taxes_included,omitempty"` - TotalTax *decimal.Decimal `json:"total_tax,omitempty"` - TotalTaxSet *AmountSet `json:"total_tax_set,omitempty"` - CurrentTotalTax *decimal.Decimal `json:"current_total_tax,omitempty"` - TaxLines []TaxLine `json:"tax_lines,omitempty"` - TotalWeight int `json:"total_weight,omitempty"` - FinancialStatus orderFinancialStatus `json:"financial_status,omitempty"` - Fulfillments []Fulfillment `json:"fulfillments,omitempty"` - FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` - Token string `json:"token,omitempty"` - CartToken string `json:"cart_token,omitempty"` - Number int `json:"number,omitempty"` - OrderNumber int `json:"order_number,omitempty"` - Note string `json:"note,omitempty"` - Test bool `json:"test,omitempty"` - BrowserIp string `json:"browser_ip,omitempty"` - BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing,omitempty"` - CancelReason orderCancelReason `json:"cancel_reason,omitempty"` - NoteAttributes []NoteAttribute `json:"note_attributes,omitempty"` - DiscountCodes []DiscountCode `json:"discount_codes,omitempty"` - LineItems []LineItem `json:"line_items,omitempty"` - ShippingLines []ShippingLines `json:"shipping_lines,omitempty"` - Transactions []Transaction `json:"transactions,omitempty"` - AppID int `json:"app_id,omitempty"` - CustomerLocale string `json:"customer_locale,omitempty"` - LandingSite string `json:"landing_site,omitempty"` - ReferringSite string `json:"referring_site,omitempty"` - SourceName string `json:"source_name,omitempty"` - ClientDetails *ClientDetails `json:"client_details,omitempty"` - Tags string `json:"tags,omitempty"` - LocationId int64 `json:"location_id,omitempty"` - PaymentGatewayNames []string `json:"payment_gateway_names,omitempty"` - ProcessingMethod string `json:"processing_method,omitempty"` - Refunds []Refund `json:"refunds,omitempty"` - UserId int64 `json:"user_id,omitempty"` - OrderStatusUrl string `json:"order_status_url,omitempty"` - Gateway string `json:"gateway,omitempty"` - Confirmed bool `json:"confirmed,omitempty"` - CheckoutToken string `json:"checkout_token,omitempty"` - Reference string `json:"reference,omitempty"` - SourceIdentifier string `json:"source_identifier,omitempty"` - SourceURL string `json:"source_url,omitempty"` - DeviceID int64 `json:"device_id,omitempty"` - Phone string `json:"phone,omitempty"` - LandingSiteRef string `json:"landing_site_ref,omitempty"` - CheckoutID int64 `json:"checkout_id,omitempty"` - ContactEmail string `json:"contact_email,omitempty"` - Metafields []Metafield `json:"metafields,omitempty"` - SendReceipt bool `json:"send_receipt,omitempty"` - SendFulfillmentReceipt bool `json:"send_fulfillment_receipt,omitempty"` - PresentmentCurrency string `json:"presentment_currency,omitempty"` - InventoryBehaviour orderInventoryBehaviour `json:"inventory_behaviour,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + CancelledAt *time.Time `json:"cancelled_at,omitempty"` + ClosedAt *time.Time `json:"closed_at,omitempty"` + ProcessedAt *time.Time `json:"processed_at,omitempty"` + Customer *Customer `json:"customer,omitempty"` + BillingAddress *Address `json:"billing_address,omitempty"` + ShippingAddress *Address `json:"shipping_address,omitempty"` + Currency string `json:"currency,omitempty"` + TotalPrice *decimal.Decimal `json:"total_price,omitempty"` + TotalPriceSet *AmountSet `json:"total_price_set,omitempty"` + TotalShippingPriceSet *AmountSet `json:"total_shipping_price_set,omitempty"` + CurrentTotalPrice *decimal.Decimal `json:"current_total_price,omitempty"` + SubtotalPrice *decimal.Decimal `json:"subtotal_price,omitempty"` + CurrentSubtotalPrice *decimal.Decimal `json:"current_subtotal_price,omitempty"` + TotalDiscount *decimal.Decimal `json:"total_discount,omitempty"` + TotalDiscountSet *decimal.Decimal `json:"total_discount_set,omitempty"` + CurrentTotalDiscount *decimal.Decimal `json:"current_total_discount,omitempty"` + CurrentTotalDiscountSet *AmountSet `json:"current_total_discount_set,omitempty"` + TotalLineItemsPrice *decimal.Decimal `json:"total_line_items_price,omitempty"` + TaxesIncluded bool `json:"taxes_included,omitempty"` + TotalTax *decimal.Decimal `json:"total_tax,omitempty"` + TotalTaxSet *AmountSet `json:"total_tax_set,omitempty"` + CurrentTotalTax *decimal.Decimal `json:"current_total_tax,omitempty"` + CurrentTotalTaxSet *AmountSet `json:"current_total_tax_set,omitempty"` + TaxLines []TaxLine `json:"tax_lines,omitempty"` + TotalWeight int `json:"total_weight,omitempty"` + FinancialStatus orderFinancialStatus `json:"financial_status,omitempty"` + Fulfillments []Fulfillment `json:"fulfillments,omitempty"` + FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` + Token string `json:"token,omitempty"` + CartToken string `json:"cart_token,omitempty"` + Number int `json:"number,omitempty"` + OrderNumber int `json:"order_number,omitempty"` + Note string `json:"note,omitempty"` + Test bool `json:"test,omitempty"` + BrowserIp string `json:"browser_ip,omitempty"` + BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing,omitempty"` + CancelReason orderCancelReason `json:"cancel_reason,omitempty"` + NoteAttributes []NoteAttribute `json:"note_attributes,omitempty"` + DiscountCodes []DiscountCode `json:"discount_codes,omitempty"` + LineItems []LineItem `json:"line_items,omitempty"` + ShippingLines []ShippingLines `json:"shipping_lines,omitempty"` + Transactions []Transaction `json:"transactions,omitempty"` + AppID int `json:"app_id,omitempty"` + CustomerLocale string `json:"customer_locale,omitempty"` + LandingSite string `json:"landing_site,omitempty"` + ReferringSite string `json:"referring_site,omitempty"` + SourceName string `json:"source_name,omitempty"` + ClientDetails *ClientDetails `json:"client_details,omitempty"` + Tags string `json:"tags,omitempty"` + LocationId int64 `json:"location_id,omitempty"` + PaymentGatewayNames []string `json:"payment_gateway_names,omitempty"` + ProcessingMethod string `json:"processing_method,omitempty"` + Refunds []Refund `json:"refunds,omitempty"` + UserId int64 `json:"user_id,omitempty"` + OrderStatusUrl string `json:"order_status_url,omitempty"` + Gateway string `json:"gateway,omitempty"` + Confirmed bool `json:"confirmed,omitempty"` + CheckoutToken string `json:"checkout_token,omitempty"` + Reference string `json:"reference,omitempty"` + SourceIdentifier string `json:"source_identifier,omitempty"` + SourceURL string `json:"source_url,omitempty"` + DeviceID int64 `json:"device_id,omitempty"` + Phone string `json:"phone,omitempty"` + LandingSiteRef string `json:"landing_site_ref,omitempty"` + CheckoutID int64 `json:"checkout_id,omitempty"` + ContactEmail string `json:"contact_email,omitempty"` + Metafields []Metafield `json:"metafields,omitempty"` + SendReceipt bool `json:"send_receipt,omitempty"` + SendFulfillmentReceipt bool `json:"send_fulfillment_receipt,omitempty"` + PresentmentCurrency string `json:"presentment_currency,omitempty"` + InventoryBehaviour orderInventoryBehaviour `json:"inventory_behaviour,omitempty"` } type Address struct { From 210a4845c19699a60d7d209d421d2a6bb0cc03ec Mon Sep 17 00:00:00 2001 From: daisukefunase Date: Mon, 26 Feb 2024 09:52:57 +0900 Subject: [PATCH 5/6] Revert "update:add following feilds in order" This reverts commit 75c49588cf1bc369c50983b9a0a1ff7b55a23c72. --- order.go | 149 +++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 76 deletions(-) diff --git a/order.go b/order.go index 33bd3f3a..46ad9b7c 100644 --- a/order.go +++ b/order.go @@ -190,82 +190,79 @@ const ( // Order represents a Shopify order type Order struct { - ID int64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Email string `json:"email,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - CancelledAt *time.Time `json:"cancelled_at,omitempty"` - ClosedAt *time.Time `json:"closed_at,omitempty"` - ProcessedAt *time.Time `json:"processed_at,omitempty"` - Customer *Customer `json:"customer,omitempty"` - BillingAddress *Address `json:"billing_address,omitempty"` - ShippingAddress *Address `json:"shipping_address,omitempty"` - Currency string `json:"currency,omitempty"` - TotalPrice *decimal.Decimal `json:"total_price,omitempty"` - TotalPriceSet *AmountSet `json:"total_price_set,omitempty"` - TotalShippingPriceSet *AmountSet `json:"total_shipping_price_set,omitempty"` - CurrentTotalPrice *decimal.Decimal `json:"current_total_price,omitempty"` - SubtotalPrice *decimal.Decimal `json:"subtotal_price,omitempty"` - CurrentSubtotalPrice *decimal.Decimal `json:"current_subtotal_price,omitempty"` - TotalDiscount *decimal.Decimal `json:"total_discount,omitempty"` - TotalDiscountSet *decimal.Decimal `json:"total_discount_set,omitempty"` - CurrentTotalDiscount *decimal.Decimal `json:"current_total_discount,omitempty"` - CurrentTotalDiscountSet *AmountSet `json:"current_total_discount_set,omitempty"` - TotalLineItemsPrice *decimal.Decimal `json:"total_line_items_price,omitempty"` - TaxesIncluded bool `json:"taxes_included,omitempty"` - TotalTax *decimal.Decimal `json:"total_tax,omitempty"` - TotalTaxSet *AmountSet `json:"total_tax_set,omitempty"` - CurrentTotalTax *decimal.Decimal `json:"current_total_tax,omitempty"` - CurrentTotalTaxSet *AmountSet `json:"current_total_tax_set,omitempty"` - TaxLines []TaxLine `json:"tax_lines,omitempty"` - TotalWeight int `json:"total_weight,omitempty"` - FinancialStatus orderFinancialStatus `json:"financial_status,omitempty"` - Fulfillments []Fulfillment `json:"fulfillments,omitempty"` - FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` - Token string `json:"token,omitempty"` - CartToken string `json:"cart_token,omitempty"` - Number int `json:"number,omitempty"` - OrderNumber int `json:"order_number,omitempty"` - Note string `json:"note,omitempty"` - Test bool `json:"test,omitempty"` - BrowserIp string `json:"browser_ip,omitempty"` - BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing,omitempty"` - CancelReason orderCancelReason `json:"cancel_reason,omitempty"` - NoteAttributes []NoteAttribute `json:"note_attributes,omitempty"` - DiscountCodes []DiscountCode `json:"discount_codes,omitempty"` - LineItems []LineItem `json:"line_items,omitempty"` - ShippingLines []ShippingLines `json:"shipping_lines,omitempty"` - Transactions []Transaction `json:"transactions,omitempty"` - AppID int `json:"app_id,omitempty"` - CustomerLocale string `json:"customer_locale,omitempty"` - LandingSite string `json:"landing_site,omitempty"` - ReferringSite string `json:"referring_site,omitempty"` - SourceName string `json:"source_name,omitempty"` - ClientDetails *ClientDetails `json:"client_details,omitempty"` - Tags string `json:"tags,omitempty"` - LocationId int64 `json:"location_id,omitempty"` - PaymentGatewayNames []string `json:"payment_gateway_names,omitempty"` - ProcessingMethod string `json:"processing_method,omitempty"` - Refunds []Refund `json:"refunds,omitempty"` - UserId int64 `json:"user_id,omitempty"` - OrderStatusUrl string `json:"order_status_url,omitempty"` - Gateway string `json:"gateway,omitempty"` - Confirmed bool `json:"confirmed,omitempty"` - CheckoutToken string `json:"checkout_token,omitempty"` - Reference string `json:"reference,omitempty"` - SourceIdentifier string `json:"source_identifier,omitempty"` - SourceURL string `json:"source_url,omitempty"` - DeviceID int64 `json:"device_id,omitempty"` - Phone string `json:"phone,omitempty"` - LandingSiteRef string `json:"landing_site_ref,omitempty"` - CheckoutID int64 `json:"checkout_id,omitempty"` - ContactEmail string `json:"contact_email,omitempty"` - Metafields []Metafield `json:"metafields,omitempty"` - SendReceipt bool `json:"send_receipt,omitempty"` - SendFulfillmentReceipt bool `json:"send_fulfillment_receipt,omitempty"` - PresentmentCurrency string `json:"presentment_currency,omitempty"` - InventoryBehaviour orderInventoryBehaviour `json:"inventory_behaviour,omitempty"` + ID int64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + CancelledAt *time.Time `json:"cancelled_at,omitempty"` + ClosedAt *time.Time `json:"closed_at,omitempty"` + ProcessedAt *time.Time `json:"processed_at,omitempty"` + Customer *Customer `json:"customer,omitempty"` + BillingAddress *Address `json:"billing_address,omitempty"` + ShippingAddress *Address `json:"shipping_address,omitempty"` + Currency string `json:"currency,omitempty"` + TotalPrice *decimal.Decimal `json:"total_price,omitempty"` + TotalPriceSet *AmountSet `json:"total_price_set,omitempty"` + TotalShippingPriceSet *AmountSet `json:"total_shipping_price_set,omitempty"` + CurrentTotalPrice *decimal.Decimal `json:"current_total_price,omitempty"` + SubtotalPrice *decimal.Decimal `json:"subtotal_price,omitempty"` + CurrentSubtotalPrice *decimal.Decimal `json:"current_subtotal_price,omitempty"` + TotalDiscounts *decimal.Decimal `json:"total_discounts,omitempty"` + CurrentTotalDiscounts *decimal.Decimal `json:"current_total_discounts,omitempty"` + TotalLineItemsPrice *decimal.Decimal `json:"total_line_items_price,omitempty"` + TaxesIncluded bool `json:"taxes_included,omitempty"` + TotalTax *decimal.Decimal `json:"total_tax,omitempty"` + TotalTaxSet *AmountSet `json:"total_tax_set,omitempty"` + CurrentTotalTax *decimal.Decimal `json:"current_total_tax,omitempty"` + TaxLines []TaxLine `json:"tax_lines,omitempty"` + TotalWeight int `json:"total_weight,omitempty"` + FinancialStatus orderFinancialStatus `json:"financial_status,omitempty"` + Fulfillments []Fulfillment `json:"fulfillments,omitempty"` + FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` + Token string `json:"token,omitempty"` + CartToken string `json:"cart_token,omitempty"` + Number int `json:"number,omitempty"` + OrderNumber int `json:"order_number,omitempty"` + Note string `json:"note,omitempty"` + Test bool `json:"test,omitempty"` + BrowserIp string `json:"browser_ip,omitempty"` + BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing,omitempty"` + CancelReason orderCancelReason `json:"cancel_reason,omitempty"` + NoteAttributes []NoteAttribute `json:"note_attributes,omitempty"` + DiscountCodes []DiscountCode `json:"discount_codes,omitempty"` + LineItems []LineItem `json:"line_items,omitempty"` + ShippingLines []ShippingLines `json:"shipping_lines,omitempty"` + Transactions []Transaction `json:"transactions,omitempty"` + AppID int `json:"app_id,omitempty"` + CustomerLocale string `json:"customer_locale,omitempty"` + LandingSite string `json:"landing_site,omitempty"` + ReferringSite string `json:"referring_site,omitempty"` + SourceName string `json:"source_name,omitempty"` + ClientDetails *ClientDetails `json:"client_details,omitempty"` + Tags string `json:"tags,omitempty"` + LocationId int64 `json:"location_id,omitempty"` + PaymentGatewayNames []string `json:"payment_gateway_names,omitempty"` + ProcessingMethod string `json:"processing_method,omitempty"` + Refunds []Refund `json:"refunds,omitempty"` + UserId int64 `json:"user_id,omitempty"` + OrderStatusUrl string `json:"order_status_url,omitempty"` + Gateway string `json:"gateway,omitempty"` + Confirmed bool `json:"confirmed,omitempty"` + CheckoutToken string `json:"checkout_token,omitempty"` + Reference string `json:"reference,omitempty"` + SourceIdentifier string `json:"source_identifier,omitempty"` + SourceURL string `json:"source_url,omitempty"` + DeviceID int64 `json:"device_id,omitempty"` + Phone string `json:"phone,omitempty"` + LandingSiteRef string `json:"landing_site_ref,omitempty"` + CheckoutID int64 `json:"checkout_id,omitempty"` + ContactEmail string `json:"contact_email,omitempty"` + Metafields []Metafield `json:"metafields,omitempty"` + SendReceipt bool `json:"send_receipt,omitempty"` + SendFulfillmentReceipt bool `json:"send_fulfillment_receipt,omitempty"` + PresentmentCurrency string `json:"presentment_currency,omitempty"` + InventoryBehaviour orderInventoryBehaviour `json:"inventory_behaviour,omitempty"` } type Address struct { From 6bb07a3b056b2793b5650a693e4e61f46036bbdb Mon Sep 17 00:00:00 2001 From: daisukefunase Date: Mon, 26 Feb 2024 10:03:28 +0900 Subject: [PATCH 6/6] add following fields in order - CurrentTotalDiscountsSet - TotalTaxSet - CurrentTotalTaxSet --- order.go | 149 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 76 insertions(+), 73 deletions(-) diff --git a/order.go b/order.go index 11af3270..818514b8 100644 --- a/order.go +++ b/order.go @@ -190,79 +190,82 @@ const ( // Order represents a Shopify order type Order struct { - Id uint64 `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Email string `json:"email,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - CancelledAt *time.Time `json:"cancelled_at,omitempty"` - ClosedAt *time.Time `json:"closed_at,omitempty"` - ProcessedAt *time.Time `json:"processed_at,omitempty"` - Customer *Customer `json:"customer,omitempty"` - BillingAddress *Address `json:"billing_address,omitempty"` - ShippingAddress *Address `json:"shipping_address,omitempty"` - Currency string `json:"currency,omitempty"` - TotalPrice *decimal.Decimal `json:"total_price,omitempty"` - TotalPriceSet *AmountSet `json:"total_price_set,omitempty"` - TotalShippingPriceSet *AmountSet `json:"total_shipping_price_set,omitempty"` - CurrentTotalPrice *decimal.Decimal `json:"current_total_price,omitempty"` - SubtotalPrice *decimal.Decimal `json:"subtotal_price,omitempty"` - CurrentSubtotalPrice *decimal.Decimal `json:"current_subtotal_price,omitempty"` - TotalDiscounts *decimal.Decimal `json:"total_discounts,omitempty"` - CurrentTotalDiscounts *decimal.Decimal `json:"current_total_discounts,omitempty"` - TotalLineItemsPrice *decimal.Decimal `json:"total_line_items_price,omitempty"` - TaxesIncluded bool `json:"taxes_included,omitempty"` - TotalTax *decimal.Decimal `json:"total_tax,omitempty"` - TotalTaxSet *AmountSet `json:"total_tax_set,omitempty"` - CurrentTotalTax *decimal.Decimal `json:"current_total_tax,omitempty"` - TaxLines []TaxLine `json:"tax_lines,omitempty"` - TotalWeight int `json:"total_weight,omitempty"` - FinancialStatus orderFinancialStatus `json:"financial_status,omitempty"` - Fulfillments []Fulfillment `json:"fulfillments,omitempty"` - FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` - Token string `json:"token,omitempty"` - CartToken string `json:"cart_token,omitempty"` - Number int `json:"number,omitempty"` - OrderNumber int `json:"order_number,omitempty"` - Note string `json:"note,omitempty"` - Test bool `json:"test,omitempty"` - BrowserIp string `json:"browser_ip,omitempty"` - BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing,omitempty"` - CancelReason orderCancelReason `json:"cancel_reason,omitempty"` - NoteAttributes []NoteAttribute `json:"note_attributes,omitempty"` - DiscountCodes []DiscountCode `json:"discount_codes,omitempty"` - LineItems []LineItem `json:"line_items,omitempty"` - ShippingLines []ShippingLines `json:"shipping_lines,omitempty"` - Transactions []Transaction `json:"transactions,omitempty"` - AppId int `json:"app_id,omitempty"` - CustomerLocale string `json:"customer_locale,omitempty"` - LandingSite string `json:"landing_site,omitempty"` - ReferringSite string `json:"referring_site,omitempty"` - SourceName string `json:"source_name,omitempty"` - ClientDetails *ClientDetails `json:"client_details,omitempty"` - Tags string `json:"tags,omitempty"` - LocationId uint64 `json:"location_id,omitempty"` - PaymentGatewayNames []string `json:"payment_gateway_names,omitempty"` - ProcessingMethod string `json:"processing_method,omitempty"` - Refunds []Refund `json:"refunds,omitempty"` - UserId uint64 `json:"user_id,omitempty"` - OrderStatusUrl string `json:"order_status_url,omitempty"` - Gateway string `json:"gateway,omitempty"` - Confirmed bool `json:"confirmed,omitempty"` - CheckoutToken string `json:"checkout_token,omitempty"` - Reference string `json:"reference,omitempty"` - SourceIdentifier string `json:"source_identifier,omitempty"` - SourceURL string `json:"source_url,omitempty"` - DeviceId uint64 `json:"device_id,omitempty"` - Phone string `json:"phone,omitempty"` - LandingSiteRef string `json:"landing_site_ref,omitempty"` - CheckoutId uint64 `json:"checkout_id,omitempty"` - ContactEmail string `json:"contact_email,omitempty"` - Metafields []Metafield `json:"metafields,omitempty"` - SendReceipt bool `json:"send_receipt,omitempty"` - SendFulfillmentReceipt bool `json:"send_fulfillment_receipt,omitempty"` - PresentmentCurrency string `json:"presentment_currency,omitempty"` - InventoryBehaviour orderInventoryBehaviour `json:"inventory_behaviour,omitempty"` + Id uint64 `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Email string `json:"email,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + CancelledAt *time.Time `json:"cancelled_at,omitempty"` + ClosedAt *time.Time `json:"closed_at,omitempty"` + ProcessedAt *time.Time `json:"processed_at,omitempty"` + Customer *Customer `json:"customer,omitempty"` + BillingAddress *Address `json:"billing_address,omitempty"` + ShippingAddress *Address `json:"shipping_address,omitempty"` + Currency string `json:"currency,omitempty"` + TotalPrice *decimal.Decimal `json:"total_price,omitempty"` + TotalPriceSet *AmountSet `json:"total_price_set,omitempty"` + TotalShippingPriceSet *AmountSet `json:"total_shipping_price_set,omitempty"` + CurrentTotalPrice *decimal.Decimal `json:"current_total_price,omitempty"` + SubtotalPrice *decimal.Decimal `json:"subtotal_price,omitempty"` + CurrentSubtotalPrice *decimal.Decimal `json:"current_subtotal_price,omitempty"` + TotalDiscounts *decimal.Decimal `json:"total_discounts,omitempty"` + TotalDiscountSet *AmountSet `json:"total_discount_set,omitempty"` + CurrentTotalDiscounts *decimal.Decimal `json:"current_total_discounts,omitempty"` + CurrentTotalDiscountsSet *AmountSet `json:"current_total_discounts_set,omitempty"` + TotalLineItemsPrice *decimal.Decimal `json:"total_line_items_price,omitempty"` + TaxesIncluded bool `json:"taxes_included,omitempty"` + TotalTax *decimal.Decimal `json:"total_tax,omitempty"` + TotalTaxSet *AmountSet `json:"total_tax_set,omitempty"` + CurrentTotalTax *decimal.Decimal `json:"current_total_tax,omitempty"` + CurrentTotalTaxSet *AmountSet `json:"current_total_tax_set,omitempty"` + TaxLines []TaxLine `json:"tax_lines,omitempty"` + TotalWeight int `json:"total_weight,omitempty"` + FinancialStatus orderFinancialStatus `json:"financial_status,omitempty"` + Fulfillments []Fulfillment `json:"fulfillments,omitempty"` + FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` + Token string `json:"token,omitempty"` + CartToken string `json:"cart_token,omitempty"` + Number int `json:"number,omitempty"` + OrderNumber int `json:"order_number,omitempty"` + Note string `json:"note,omitempty"` + Test bool `json:"test,omitempty"` + BrowserIp string `json:"browser_ip,omitempty"` + BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing,omitempty"` + CancelReason orderCancelReason `json:"cancel_reason,omitempty"` + NoteAttributes []NoteAttribute `json:"note_attributes,omitempty"` + DiscountCodes []DiscountCode `json:"discount_codes,omitempty"` + LineItems []LineItem `json:"line_items,omitempty"` + ShippingLines []ShippingLines `json:"shipping_lines,omitempty"` + Transactions []Transaction `json:"transactions,omitempty"` + AppId int `json:"app_id,omitempty"` + CustomerLocale string `json:"customer_locale,omitempty"` + LandingSite string `json:"landing_site,omitempty"` + ReferringSite string `json:"referring_site,omitempty"` + SourceName string `json:"source_name,omitempty"` + ClientDetails *ClientDetails `json:"client_details,omitempty"` + Tags string `json:"tags,omitempty"` + LocationId uint64 `json:"location_id,omitempty"` + PaymentGatewayNames []string `json:"payment_gateway_names,omitempty"` + ProcessingMethod string `json:"processing_method,omitempty"` + Refunds []Refund `json:"refunds,omitempty"` + UserId uint64 `json:"user_id,omitempty"` + OrderStatusUrl string `json:"order_status_url,omitempty"` + Gateway string `json:"gateway,omitempty"` + Confirmed bool `json:"confirmed,omitempty"` + CheckoutToken string `json:"checkout_token,omitempty"` + Reference string `json:"reference,omitempty"` + SourceIdentifier string `json:"source_identifier,omitempty"` + SourceURL string `json:"source_url,omitempty"` + DeviceId uint64 `json:"device_id,omitempty"` + Phone string `json:"phone,omitempty"` + LandingSiteRef string `json:"landing_site_ref,omitempty"` + CheckoutId uint64 `json:"checkout_id,omitempty"` + ContactEmail string `json:"contact_email,omitempty"` + Metafields []Metafield `json:"metafields,omitempty"` + SendReceipt bool `json:"send_receipt,omitempty"` + SendFulfillmentReceipt bool `json:"send_fulfillment_receipt,omitempty"` + PresentmentCurrency string `json:"presentment_currency,omitempty"` + InventoryBehaviour orderInventoryBehaviour `json:"inventory_behaviour,omitempty"` } type Address struct {