From bd8e34570e2e2942712884e8a28a62328fc8162a Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 14 Mar 2024 21:23:29 -0700 Subject: [PATCH] nullable/ommitempty fixes for #182 (#275) --- carrier.go | 2 +- carrier_test.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/carrier.go b/carrier.go index c9eddb3e..10566c76 100644 --- a/carrier.go +++ b/carrier.go @@ -30,7 +30,7 @@ type CarrierServiceOp struct { // CarrierService represents a Shopify carrier service type CarrierService struct { // Whether this carrier service is active. - Active bool `json:"active,omitempty"` + Active *bool `json:"active"` // The URL endpoint that Shopify needs to retrieve shipping rates. This must be a public URL. CallbackUrl string `json:"callback_url,omitempty"` diff --git a/carrier_test.go b/carrier_test.go index e8659261..f5d0e988 100644 --- a/carrier_test.go +++ b/carrier_test.go @@ -21,11 +21,13 @@ func TestCarrierList(t *testing.T) { t.Errorf("Carrier.List returned error: %v", err) } + trueVar := true + expected := []CarrierService{ { Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1", @@ -50,10 +52,12 @@ func TestCarrierGet(t *testing.T) { t.Errorf("Carrier.Get returned error: %v", err) } + trueVar := true + expected := &CarrierService{ Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1", @@ -77,10 +81,12 @@ func TestCarrierCreate(t *testing.T) { t.Errorf("Carrier.Create returned error: %v", err) } + trueVar := true + expected := &CarrierService{ Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1", @@ -104,10 +110,12 @@ func TestCarrierUpdate(t *testing.T) { t.Errorf("Carrier.Update returned error: %v", err) } + trueVar := true + expected := &CarrierService{ Id: 1, Name: "Shipping Rate Provider", - Active: true, + Active: &trueVar, ServiceDiscovery: true, CarrierServiceType: "api", AdminGraphqlApiId: "gid://shopify/DeliveryCarrierService/1",