diff --git a/customer.go b/customer.go index 1e7a6057..6134bb22 100644 --- a/customer.go +++ b/customer.go @@ -41,30 +41,28 @@ type CustomerServiceOp struct { // Customer represents a Shopify customer type Customer struct { - Id uint64 `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 uint64 `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"` + Id uint64 `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 uint64 `json:"last_order_id,omitempty"` + LastOrderName string `json:"last_order_name,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 diff --git a/customer_test.go b/customer_test.go index 016a8b07..157e2b62 100644 --- a/customer_test.go +++ b/customer_test.go @@ -353,26 +353,24 @@ func TestCustomerGet(t *testing.T) { } 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: "", - AcceptsMarketingUpdatedAt: &updatedAt, - EmailMarketingConsent: &emailMarketingConsent1, - SMSMarketingConsent: &smsMarketingConsent1, - DefaultAddress: address1, - Addresses: []*CustomerAddress{address1}, - CreatedAt: &createdAt, - UpdatedAt: &updatedAt, + Id: 1, + Email: "test@example.com", + FirstName: "Test", + LastName: "Citizen", + VerifiedEmail: true, + TaxExempt: false, + OrdersCount: 4, + State: "enabled", + TotalSpent: &totalSpent, + LastOrderId: 123, + Note: "", + Phone: "", + EmailMarketingConsent: &emailMarketingConsent1, + SMSMarketingConsent: &smsMarketingConsent1, + DefaultAddress: address1, + Addresses: []*CustomerAddress{address1}, + CreatedAt: &createdAt, + UpdatedAt: &updatedAt, } if customer.Id != expectation.Id { @@ -387,9 +385,6 @@ func TestCustomerGet(t *testing.T) { if customer.LastName != expectation.LastName { t.Errorf("Customer.LastName returned %+v, expected %+v", customer.LastName, expectation.LastName) } - if customer.AcceptsMarketing != expectation.AcceptsMarketing { - t.Errorf("Customer.AcceptsMarketing returned %+v, expected %+v", customer.AcceptsMarketing, expectation.AcceptsMarketing) - } if !customer.CreatedAt.Equal(*expectation.CreatedAt) { t.Errorf("Customer.CreatedAt returned %+v, expected %+v", customer.CreatedAt, expectation.CreatedAt) } @@ -481,9 +476,6 @@ 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 { diff --git a/order.go b/order.go index caa1a33a..f4a8d34a 100644 --- a/order.go +++ b/order.go @@ -60,80 +60,80 @@ const ( OrderStatusAny orderStatus = "any" ) -type orderFulfillmentStatus string +type OrderFulfillmentStatus string // https://shopify.dev/docs/api/admin-rest/2023-07/resources/order#get-orders?status=any const ( // Show orders that have been shipped. - OrderFulfillmentStatusShipped orderFulfillmentStatus = "shipped" + OrderFulfillmentStatusShipped OrderFulfillmentStatus = "shipped" // Show partially shipped orders. - OrderFulfillmentStatusPartial orderFulfillmentStatus = "partial" + OrderFulfillmentStatusPartial OrderFulfillmentStatus = "partial" // Show orders that have not yet been shipped. - OrderFulfillmentStatusUnshipped orderFulfillmentStatus = "unshipped" + OrderFulfillmentStatusUnshipped OrderFulfillmentStatus = "unshipped" // Show orders of any fulfillment status. - OrderFulfillmentStatusAny orderFulfillmentStatus = "any" + OrderFulfillmentStatusAny OrderFulfillmentStatus = "any" // Returns orders with fulfillment_status of null or partial. - OrderFulfillmentStatusUnfulfilled orderFulfillmentStatus = "unfulfilled" + OrderFulfillmentStatusUnfulfilled OrderFulfillmentStatus = "unfulfilled" //"fulfilled" used to be an acceptable value? Was it deprecated? It isn't noted //in the Shopify docs at the provided URL, but it was used in tests and still //seems to function. - OrderFulfillmentStatusFulfilled orderFulfillmentStatus = "fulfilled" + OrderFulfillmentStatusFulfilled OrderFulfillmentStatus = "fulfilled" ) -type orderFinancialStatus string +type OrderFinancialStatus string // https://shopify.dev/docs/api/admin-rest/2023-07/resources/order#get-orders?status=any const ( // Show only authorized orders. - OrderFinancialStatusAuthorized orderFinancialStatus = "authorized" + OrderFinancialStatusAuthorized OrderFinancialStatus = "authorized" // Show only pending orders. - OrderFinancialStatusPending orderFinancialStatus = "pending" + OrderFinancialStatusPending OrderFinancialStatus = "pending" // Show only paid orders. - OrderFinancialStatusPaid orderFinancialStatus = "paid" + OrderFinancialStatusPaid OrderFinancialStatus = "paid" // Show only partially paid orders. - OrderFinancialStatusPartiallyPaid orderFinancialStatus = "partially_paid" + OrderFinancialStatusPartiallyPaid OrderFinancialStatus = "partially_paid" // Show only refunded orders. - OrderFinancialStatusRefunded orderFinancialStatus = "refunded" + OrderFinancialStatusRefunded OrderFinancialStatus = "refunded" // Show only voided orders. - OrderFinancialStatusVoided orderFinancialStatus = "voided" + OrderFinancialStatusVoided OrderFinancialStatus = "voided" // Show only partially refunded orders. - OrderFinancialStatusPartiallyRefunded orderFinancialStatus = "partially_refunded" + OrderFinancialStatusPartiallyRefunded OrderFinancialStatus = "partially_refunded" // Show orders of any financial status. - OrderFinancialStatusAny orderFinancialStatus = "any" + OrderFinancialStatusAny OrderFinancialStatus = "any" // Show authorized and partially paid orders. - OrderFinancialStatusUnpaid orderFinancialStatus = "unpaid" + OrderFinancialStatusUnpaid OrderFinancialStatus = "unpaid" ) -type orderCancelReason string +type OrderCancelReason string const ( // The customer canceled the order. - OrderCancelReasonCustomer orderCancelReason = "customer" + OrderCancelReasonCustomer OrderCancelReason = "customer" // The order was fraudulent. - OrderCancelReasonFraud orderCancelReason = "fraud" + OrderCancelReasonFraud OrderCancelReason = "fraud" // Items in the order were not in inventory. - OrderCancelReasonInventory orderCancelReason = "inventory" + OrderCancelReasonInventory OrderCancelReason = "inventory" // The payment was declined. - OrderCancelReasonDeclined orderCancelReason = "declined" + OrderCancelReasonDeclined OrderCancelReason = "declined" // Cancelled for some other reason. - OrderCancelReasonOther orderCancelReason = "other" + OrderCancelReasonOther OrderCancelReason = "other" ) type discountAllocationMethod string @@ -210,8 +210,8 @@ type OrderCountOptions struct { Order string `url:"order,omitempty"` Fields string `url:"fields,omitempty"` Status orderStatus `url:"status,omitempty"` - FinancialStatus orderFinancialStatus `url:"financial_status,omitempty"` - FulfillmentStatus orderFulfillmentStatus `url:"fulfillment_status,omitempty"` + FinancialStatus OrderFinancialStatus `url:"financial_status,omitempty"` + FulfillmentStatus OrderFulfillmentStatus `url:"fulfillment_status,omitempty"` } // A struct for all available order list options. @@ -219,8 +219,8 @@ type OrderCountOptions struct { type OrderListOptions struct { ListOptions Status orderStatus `url:"status,omitempty"` - FinancialStatus orderFinancialStatus `url:"financial_status,omitempty"` - FulfillmentStatus orderFulfillmentStatus `url:"fulfillment_status,omitempty"` + FinancialStatus OrderFinancialStatus `url:"financial_status,omitempty"` + FulfillmentStatus OrderFulfillmentStatus `url:"fulfillment_status,omitempty"` ProcessedAtMin time.Time `url:"processed_at_min,omitempty"` ProcessedAtMax time.Time `url:"processed_at_max,omitempty"` Order string `url:"order,omitempty"` @@ -283,9 +283,9 @@ type Order struct { 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"` + FinancialStatus OrderFinancialStatus `json:"financial_status,omitempty"` Fulfillments []Fulfillment `json:"fulfillments,omitempty"` - FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` + FulfillmentStatus OrderFulfillmentStatus `json:"fulfillment_status,omitempty"` Token string `json:"token,omitempty"` CartToken string `json:"cart_token,omitempty"` Number int `json:"number,omitempty"` @@ -294,7 +294,7 @@ type Order struct { Test bool `json:"test,omitempty"` BrowserIp string `json:"browser_ip,omitempty"` BuyerAcceptsMarketing bool `json:"buyer_accepts_marketing,omitempty"` - CancelReason orderCancelReason `json:"cancel_reason,omitempty"` + CancelReason OrderCancelReason `json:"cancel_reason,omitempty"` NoteAttributes []NoteAttribute `json:"note_attributes,omitempty"` DiscountCodes []DiscountCode `json:"discount_codes,omitempty"` DiscountApplications []DiscountApplication `json:"discount_applications,omitempty"` @@ -392,7 +392,7 @@ type LineItem struct { ProductExists bool `json:"product_exists,omitempty"` FulfillableQuantity int `json:"fulfillable_quantity,omitempty"` Grams int `json:"grams,omitempty"` - FulfillmentStatus orderFulfillmentStatus `json:"fulfillment_status,omitempty"` + FulfillmentStatus OrderFulfillmentStatus `json:"fulfillment_status,omitempty"` TaxLines []TaxLine `json:"tax_lines,omitempty"` // Deprecated: See 2022-10 release notes: https://shopify.dev/docs/api/release-notes/2022-10 diff --git a/usagecharge.go b/usagecharge.go index b69cb707..74d49835 100644 --- a/usagecharge.go +++ b/usagecharge.go @@ -30,7 +30,9 @@ type UsageCharge struct { BalanceRemaining *decimal.Decimal `json:"balance_remaining,omitempty"` BalanceUsed *decimal.Decimal `json:"balance_used,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` Description string `json:"description,omitempty"` + Currency string `json:"currency,omitempty"` Id uint64 `json:"id,omitempty"` Price *decimal.Decimal `json:"price,omitempty"` RiskLevel *decimal.Decimal `json:"risk_level,omitempty"`