#!/bin/bash
# CreateMultipleStopShipment -- REST curl example
# Pre-configured for the DM Web Services test environment.
# Replace YOUR_TOKEN below with your Bearer token.
#
# additionalStops holds ONLY the intermediate stops. The start pickup is the
# shipper block and the final delivery is the consignee block -- do not repeat
# either one as an additional stop.
#
# stopID is all-or-none: supply it on every stop or on none. When omitted the
# stops are numbered 1..N in array order.
#
# recordLayout 3 (Final Mile) is rejected by this endpoint -- use CreateShipment.

BASE_URL="https://webservices.nebulasuite.net"
TOKEN="YOUR_TOKEN"

curl -X POST "${BASE_URL}/api/public/v1/shipping/CreateMultipleStopShipment" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "clientReferenceCode": "YOUR-CLIENT-CODE",
    "carrierReferenceCode": "CARRIER-CODE",
    "serviceLevelCode": "OHN",
    "recordLayout": 1,
    "shipper": {
      "name": "Central Distribution",
      "address1": "500 Industrial Parkway",
      "city": "Dallas",
      "state": "TX",
      "zip": "75201",
      "phone": "2145550100"
    },
    "additionalStops": [
      {
        "stopID": 1,
        "stopType": 0,
        "address": {
          "name": "Overflow Warehouse",
          "address1": "1200 Depot Road",
          "city": "Temple",
          "state": "TX",
          "zip": "76501",
          "phone": "2545550200"
        },
        "locationType": "Warehouse",
        "lineNumbers": [ 1 ]
      },
      {
        "stopID": 2,
        "stopType": 1,
        "address": {
          "name": "Northside Retail",
          "address1": "88 Commerce Way",
          "city": "Waco",
          "state": "TX",
          "zip": "76701",
          "phone": "2545550188"
        },
        "locationType": "Retail Location",
        "appointmentRequired": true,
        "scheduledAppointment": "2026-08-12T13:00:00",
        "lineNumbers": [ 2 ]
      }
    ],
    "consignee": {
      "name": "John Smith",
      "address1": "123 Main Street",
      "city": "Austin",
      "state": "TX",
      "zip": "78701",
      "phone": "5125551234"
    },
    "lineItems": [
      {
        "pieces": 1,
        "weight": 65,
        "length": 24,
        "width": 12,
        "height": 10,
        "description": "Furniture piece"
      },
      {
        "pieces": 2,
        "weight": 120,
        "length": 40,
        "width": 30,
        "height": 22,
        "description": "Accent chair, boxed"
      }
    ]
  }'
