Skip to content

Commit

Permalink
Merge branch 'incentro-ecx:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom authored Nov 12, 2024
2 parents 4a16e54 + a2f260c commit c1c4f3b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
14 changes: 14 additions & 0 deletions commercelayer/resource_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func resourceMarket() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"code": {
Description: "A string that you can use to identify the market (must be unique within the environment).",
Type: schema.TypeString,
Optional: true,
},
"facebook_pixel_id": {
Description: "The Facebook Pixed ID",
Type: schema.TypeString,
Expand All @@ -62,6 +67,11 @@ func resourceMarket() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"shipping_cost_cutoff": {
Description: "When specified indicates the maximum number of shipping line items with cost that will be added to an order.",
Type: schema.TypeInt,
Optional: true,
},
"reference": {
Description: "A string that you can use to add any external identifier to the resource. This " +
"can be useful for integrating the resource to an external system, like an ERP, a " +
Expand Down Expand Up @@ -157,9 +167,11 @@ func resourceMarketCreateFunc(ctx context.Context, d *schema.ResourceData, i int
Attributes: commercelayer.POSTMarkets201ResponseDataAttributes{
Name: attributes["name"].(string),
FacebookPixelId: stringRef(attributes["facebook_pixel_id"]),
Code: stringRef(attributes["code"]),
CheckoutUrl: stringRef(attributes["checkout_url"]),
ExternalPricesUrl: stringRef(attributes["external_prices_url"]),
ExternalOrderValidationUrl: stringRef(attributes["external_order_validation_url"]),
ShippingCostCutoff: intToInt32Ref(attributes["shipping_cost_cutoff"]),
Reference: stringRef(attributes["reference"]),
ReferenceOrigin: stringRef(attributes["reference_origin"]),
Metadata: keyValueRef(attributes["metadata"]),
Expand Down Expand Up @@ -238,10 +250,12 @@ func resourceMarketUpdateFunc(ctx context.Context, d *schema.ResourceData, i int
Id: d.Id(),
Attributes: commercelayer.PATCHMarketsMarketId200ResponseDataAttributes{
Name: stringRef(attributes["name"]),
Code: stringRef(attributes["code"]),
FacebookPixelId: stringRef(attributes["facebook_pixel_id"]),
CheckoutUrl: stringRef(attributes["checkout_url"]),
ExternalPricesUrl: stringRef(attributes["external_prices_url"]),
ExternalOrderValidationUrl: stringRef(attributes["external_order_validation_url"]),
ShippingCostCutoff: intToInt32Ref(attributes["shipping_cost_cutoff"]),
Reference: stringRef(attributes["reference"]),
ReferenceOrigin: stringRef(attributes["reference_origin"]),
Metadata: keyValueRef(attributes["metadata"]),
Expand Down
18 changes: 14 additions & 4 deletions commercelayer/resource_market_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ func testAccMarketCreate(testName string) string {
return hclTemplate(`
resource "commercelayer_market" "incentro_market" {
attributes {
code = "M-001"
name = "Incentro Market"
facebook_pixel_id = "pixel"
external_order_validation_url = "https://www.example.com"
checkout_url = "https://www.checkout.com/:order_id"
external_order_validation_url = "https://www.example.com"
external_prices_url = "https://www.prices.com"
shipping_cost_cutoff = 100
reference = "M-001-EXT"
reference_origin = "ERP"
metadata = {
testName: "{{.testName}}"
}
Expand All @@ -97,10 +102,15 @@ func testAccMarketUpdate(testName string) string {
return hclTemplate(`
resource "commercelayer_market" "incentro_market" {
attributes {
code = "M-001-CHG"
name = "Incentro Market Changed"
facebook_pixel_id = "pixelchanged"
external_order_validation_url = "https://www.example.com"
checkout_url = "https://www.checkout-changed.com/:order_id"
external_order_validation_url = "https://www.example-changed.com"
external_prices_url = "https://www.prices-changed.com"
shipping_cost_cutoff = 105
reference = "M-001-EXT-CHG"
reference_origin = "ERP-CHG"
metadata = {
testName: "{{.testName}}"
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.23
require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-docs v0.19.4
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/incentro-dc/go-commercelayer-sdk v0.0.6
github.com/ladydascalie/currency v1.8.0
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -45,8 +45,8 @@ require (
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.24.0 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.25.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ=
github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg=
github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec=
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
github.com/hashicorp/terraform-json v0.23.0 h1:sniCkExU4iKtTADReHzACkk8fnpQXrdD2xoR+lppBkI=
github.com/hashicorp/terraform-json v0.23.0/go.mod h1:MHdXbBAbSg0GvzuWazEGKAn/cyNfIB7mN6y7KJN6y2c=
github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c=
github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA=
github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U=
github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg=
github.com/hashicorp/terraform-plugin-go v0.25.0 h1:oi13cx7xXA6QciMcpcFi/rwA974rdTxjqEhXJjbAyks=
github.com/hashicorp/terraform-plugin-go v0.25.0/go.mod h1:+SYagMYadJP86Kvn+TGeV+ofr/R3g4/If0O5sO96MVw=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 h1:wyKCCtn6pBBL46c1uIIBNUOWlNfYXfXpVo16iDyLp8Y=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0/go.mod h1:B0Al8NyYVr8Mp/KLwssKXG1RqnTk7FySqSn4fRuLNgw=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url" : "/api/markets",
"method" : "POST",
"bodyPatterns" : [ {
"equalToJson" : "{\"data\":{\"attributes\":{\"checkout_url\":null,\"external_order_validation_url\":\"https://www.example.com\",\"external_prices_url\":null,\"facebook_pixel_id\":\"pixel\",\"metadata\":{\"testName\":\"commercelayer_market.incentro_market\"},\"name\":\"Incentro Market\",\"reference\":null,\"reference_origin\":null},\"relationships\":{\"inventory_model\":{\"data\":{\"id\":\"kZXEvSyREa\",\"type\":\"inventory_models\"}},\"merchant\":{\"data\":{\"id\":\"qnzZLHQmpn\",\"type\":\"merchants\"}},\"price_list\":{\"data\":{\"id\":\"AkYYaCErEk\",\"type\":\"price_lists\"}}},\"type\":\"markets\"}}\n",
"equalToJson" : "{\"data\":{\"attributes\":{\"code\":\"M-001\",\"shipping_cost_cutoff\":100,\"checkout_url\":\"https://www.checkout.com/:order_id\",\"external_order_validation_url\":\"https://www.example.com\",\"external_prices_url\":\"https://www.prices.com\",\"facebook_pixel_id\":\"pixel\",\"metadata\":{\"testName\":\"commercelayer_market.incentro_market\"},\"name\":\"Incentro Market\",\"reference\":\"M-001-EXT\",\"reference_origin\":\"ERP\"},\"relationships\":{\"inventory_model\":{\"data\":{\"id\":\"kZXEvSyREa\",\"type\":\"inventory_models\"}},\"merchant\":{\"data\":{\"id\":\"qnzZLHQmpn\",\"type\":\"merchants\"}},\"price_list\":{\"data\":{\"id\":\"AkYYaCErEk\",\"type\":\"price_lists\"}}},\"type\":\"markets\"}}\n",
"ignoreArrayOrder" : true,
"ignoreExtraElements" : true
} ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url" : "/api/markets/XjBdyhLYOl",
"method" : "PATCH",
"bodyPatterns" : [ {
"equalToJson" : "{\"data\":{\"attributes\":{\"checkout_url\":null,\"external_order_validation_url\":\"https://www.example.com\",\"external_prices_url\":null,\"facebook_pixel_id\":\"pixelchanged\",\"metadata\":{\"testName\":\"commercelayer_market.incentro_market\"},\"name\":\"Incentro Market Changed\",\"reference\":null,\"reference_origin\":null},\"id\":\"XjBdyhLYOl\",\"relationships\":{\"inventory_model\":{\"data\":{\"id\":\"kZXEvSyREa\",\"type\":\"inventory_models\"}},\"merchant\":{\"data\":{\"id\":\"qnzZLHQmpn\",\"type\":\"merchants\"}},\"price_list\":{\"data\":{\"id\":\"AkYYaCErEk\",\"type\":\"price_lists\"}}},\"type\":\"markets\"}}\n",
"equalToJson" : "{\"data\":{\"attributes\":{\"code\":\"M-001-CHG\",\"shipping_cost_cutoff\":105,\"checkout_url\":\"https://www.checkout-changed.com/:order_id\",\"external_order_validation_url\":\"https://www.example-changed.com\",\"external_prices_url\":\"https://www.prices-changed.com\",\"facebook_pixel_id\":\"pixelchanged\",\"metadata\":{\"testName\":\"commercelayer_market.incentro_market\"},\"name\":\"Incentro Market Changed\",\"reference\":\"M-001-EXT-CHG\",\"reference_origin\":\"ERP-CHG\"},\"id\":\"XjBdyhLYOl\",\"relationships\":{\"inventory_model\":{\"data\":{\"id\":\"kZXEvSyREa\",\"type\":\"inventory_models\"}},\"merchant\":{\"data\":{\"id\":\"qnzZLHQmpn\",\"type\":\"merchants\"}},\"price_list\":{\"data\":{\"id\":\"AkYYaCErEk\",\"type\":\"price_lists\"}}},\"type\":\"markets\"}}\n",
"ignoreArrayOrder" : true,
"ignoreExtraElements" : true
} ]
Expand Down

0 comments on commit c1c4f3b

Please sign in to comment.