Skip to content

Commit

Permalink
nullable/ommitempty fixes for #182
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver006 committed Mar 2, 2024
1 parent 2b22533 commit 35f7251
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion carrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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"`
Expand Down
16 changes: 12 additions & 4 deletions carrier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,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",
Expand All @@ -49,10 +51,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",
Expand All @@ -76,10 +80,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",
Expand All @@ -103,10 +109,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",
Expand Down
2 changes: 1 addition & 1 deletion variant.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Variant struct {
TaxCode string `json:"tax_code,omitempty"`
Barcode string `json:"barcode,omitempty"`
ImageID int64 `json:"image_id,omitempty"`
InventoryQuantity int `json:"inventory_quantity,omitempty"`
InventoryQuantity *int `json:"inventory_quantity"`
Weight *decimal.Decimal `json:"weight,omitempty"`
WeightUnit string `json:"weight_unit,omitempty"`
OldInventoryQuantity int `json:"old_inventory_quantity,omitempty"`
Expand Down

0 comments on commit 35f7251

Please sign in to comment.