{
  "name": "ShipPickup: buy the cheapest label",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {
        "maxResults": 1
      },
      "mapper": {},
      "metadata": {
        "designer": { "x": 0, "y": 0 },
        "restore": {},
        "interface": [
          { "name": "order_id", "type": "text" },
          { "name": "to_name", "type": "text" },
          { "name": "to_line1", "type": "text" },
          { "name": "to_city", "type": "text" },
          { "name": "to_state", "type": "text" },
          { "name": "to_postal_code", "type": "text" },
          { "name": "to_country", "type": "text" },
          { "name": "weight_g", "type": "number" },
          { "name": "length_mm", "type": "number" },
          { "name": "width_mm", "type": "number" },
          { "name": "height_mm", "type": "number" },
          { "name": "description", "type": "text" },
          { "name": "quantity", "type": "number" },
          { "name": "unit_value_cents", "type": "number" }
        ]
      }
    },
    {
      "id": 2,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {
        "handleErrors": false,
        "useNewZLibDeCompress": true
      },
      "mapper": {
        "url": "https://api.shippickup.com/v1/rates",
        "method": "post",
        "headers": [
          { "name": "Authorization", "value": "Bearer {{var.organization.SHIPPICKUP_API_KEY}}" }
        ],
        "serializeUrl": false,
        "bodyType": "raw",
        "contentType": "application/json",
        "data": "{\"from\":{\"country\":\"US\",\"postal_code\":\"10001\"},\"to\":{\"country\":\"{{1.to_country}}\",\"postal_code\":\"{{1.to_postal_code}}\"},\"parcel\":{\"weight_g\":{{1.weight_g}},\"length_mm\":{{1.length_mm}},\"width_mm\":{{1.width_mm}},\"height_mm\":{{1.height_mm}}},\"declared_value_cents\":{{1.quantity * 1.unit_value_cents}}}",
        "parseResponse": true,
        "timeout": "30",
        "shareCookies": false,
        "followRedirect": true,
        "ca": ""
      },
      "metadata": {
        "designer": { "x": 300, "y": 0 },
        "restore": {}
      }
    },
    {
      "id": 3,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {
        "handleErrors": false,
        "useNewZLibDeCompress": true
      },
      "mapper": {
        "url": "https://api.shippickup.com/v1/shipments",
        "method": "post",
        "headers": [
          { "name": "Authorization", "value": "Bearer {{var.organization.SHIPPICKUP_API_KEY}}" },
          { "name": "Idempotency-Key", "value": "make-order-{{1.order_id}}-label" }
        ],
        "serializeUrl": false,
        "bodyType": "raw",
        "contentType": "application/json",
        "data": "{\"rate_id\":\"{{2.data.data[1].rate_id}}\",\"from\":{\"name\":\"Your Store\",\"line1\":\"350 5th Ave\",\"city\":\"New York\",\"state\":\"NY\",\"postal_code\":\"10001\",\"country\":\"US\",\"phone\":\"+12125550100\"},\"to\":{\"name\":\"{{1.to_name}}\",\"line1\":\"{{1.to_line1}}\",\"city\":\"{{1.to_city}}\",\"state\":\"{{1.to_state}}\",\"postal_code\":\"{{1.to_postal_code}}\",\"country\":\"{{1.to_country}}\"},\"parcel\":{\"weight_g\":{{1.weight_g}},\"length_mm\":{{1.length_mm}},\"width_mm\":{{1.width_mm}},\"height_mm\":{{1.height_mm}}},\"items\":[{\"description\":\"{{1.description}}\",\"quantity\":{{1.quantity}},\"unit_value_cents\":{{1.unit_value_cents}},\"origin_country\":\"US\"}],\"declared_value_cents\":{{1.quantity * 1.unit_value_cents}}}",
        "parseResponse": true,
        "timeout": "60",
        "shareCookies": false,
        "followRedirect": true,
        "ca": ""
      },
      "metadata": {
        "designer": { "x": 600, "y": 0 },
        "restore": {}
      }
    }
  ],
  "metadata": {
    "instant": true,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "confidential": false,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": { "orphans": [] },
    "zone": "eu1.make.com"
  }
}
