spec/features/product_types_spec.rb
def payload(type)
          payload = {
            sku: FFaker::Product.model,
            externalId: FFaker::Product.model,
            description: FFaker::Product.product,
            category: "OTHER",
            batteryConfiguration: "NOBATTERY",
            values: {
              costValue: 1,
              retailValue: 4
            },
            dimensions: {
              length: 1,
              width: 1,
              height: 1,
              weight: 1
            },
            flags: {
              isPackagedReadyToShip: 1,
              isFragile: 0,
              isDangerous: 0,
              isPerishable: 0,
              isLiquid: 0,
              isMedia: 0,
              isAdult: 0,
              hasInnerPack: 0,
              hasMasterCase: 0,
              hasPallet: 0
            }
          }

          # First of all, to create a Kit or Virtual Kit, the base products HAVE
          # to exist. They will not be created here. Kits require 2 ore more
          # products.
          # Next, `externalId` is NOT the same as the product SKU. An externalId
          # currently cannot be set using the Shipwire website. It can only be
          # set by creating a product through the API or updating an existing
          # product using the API and setting a value for externalID.
          # Otherwise instead of `externalID` you can use `productID` which is
          # the unique Shipwire ID for that product
          product_contents = [
            {
              externalId: "TEST-PRODUCT",
              quantity: 1
            },
            {
              externalId: "TEST-PRODUCT2",
              quantity: 1
            }
          ]

          case type
          when "insert"
            payload.deeper_merge!(
              dimensions: {
                height: 0.1,
                weight: 0.1
              },
              masterCase: {
                individualItemsPerCase: 1,
                sku: FFaker::Product.model,
                description: FFaker::Product.product,
                dimensions: {
                  length: 1,
                  width: 1,
                  height: 1,
                  weight: 1
                }
              },
              inclusionRules: {
                insertWhenWorthCurrency: "USD"
              }
            )
          when "kit"
            payload.deeper_merge!(kitContent: product_contents)

          when "virtual_kit"
            payload.deeper_merge!(virtualKitContent: product_contents)
          end

          payload
        end
# NOTE: This is ugly and massive and I know it. I'm down to change it.
This is ugly and massive and I know it. I'm down to change it.
This is ugly and massive and I know it . I ' m down to change it .
def payload(type)
          payload = {
            sku: FFaker::Product.model,
            externalId: FFaker::Product.model,
            description: FFaker::Product.product,
            category: "OTHER",
            batteryConfiguration: "NOBATTERY",
            values: {
              costValue: 1,
              retailValue: 4
            },
            dimensions: {
              length: 1,
              width: 1,
              height: 1,
              weight: 1
            },
            flags: {
              isPackagedReadyToShip: 1,
              isFragile: 0,
              isDangerous: 0,
              isPerishable: 0,
              isLiquid: 0,
              isMedia: 0,
              isAdult: 0,
              hasInnerPack: 0,
              hasMasterCase: 0,
              hasPallet: 0
            }
          }
          product_contents = [
            {
              externalId: "TEST-PRODUCT",
              quantity: 1
            },
            {
              externalId: "TEST-PRODUCT2",
              quantity: 1
            }
          ]
          case type
          when "insert"
            payload.deeper_merge!(
              dimensions: {
                height: 0.1,
                weight: 0.1
              },
              masterCase: {
                individualItemsPerCase: 1,
                sku: FFaker::Product.model,
                description: FFaker::Product.product,
                dimensions: {
                  length: 1,
                  width: 1,
                  height: 1,
                  weight: 1
                }
              },
              inclusionRules: {
                insertWhenWorthCurrency: "USD"
              }
            )
          when "kit"
            payload.deeper_merge!(kitContent: product_contents)
          when "virtual_kit"
            payload.deeper_merge!(virtualKitContent: product_contents)
          end
          payload
        end
def payload ( type ) payload = { sku : FFaker :: Product . model , externalId : FFaker :: Product . model , description : FFaker :: Product . product , category : "OTHER" , batteryConfiguration : "NOBATTERY" , values : { costValue : 1 , retailValue : 4 } , dimensions : { length : 1 , width : 1 , height : 1 , weight : 1 } , flags : { isPackagedReadyToShip : 1 , isFragile : 0 , isDangerous : 0 , isPerishable : 0 , isLiquid : 0 , isMedia : 0 , isAdult : 0 , hasInnerPack : 0 , hasMasterCase : 0 , hasPallet : 0 } } product_contents = [ { externalId : "TEST-PRODUCT" , quantity : 1 } , { externalId : "TEST-PRODUCT2" , quantity : 1 } ] case type when "insert" payload . deeper_merge! ( dimensions : { height : 0.1 , weight : 0.1 } , masterCase : { individualItemsPerCase : 1 , sku : FFaker :: Product . model , description : FFaker :: Product . product , dimensions : { length : 1 , width : 1 , height : 1 , weight : 1 } } , inclusionRules : { insertWhenWorthCurrency : "USD" } ) when "kit" payload . deeper_merge! ( kitContent : product_contents ) when "virtual_kit" payload . deeper_merge! ( virtualKitContent : product_contents ) end payload end
NOTE: This is ugly and massive and I know it.
NOTE : This is ugly and massive and I know it .
# First of all, to create a Kit or Virtual Kit, the base products HAVE # to exist. They will not be created here. Kits require 2 ore more # products. # Next, `externalId` is NOT the same as the product SKU. An externalId # currently cannot be set using the Shipwire website. It can only be # set by creating a product through the API or updating an existing # product using the API and setting a value for externalID. # Otherwise instead of `externalID` you can use `productID` which is # the unique Shipwire ID for that product
type