### Create Import Orchestration for the first available reservation

The following request will create an orchestration for payment and the first available pick import
appointment (for empty returns please see "Creating an orchestration for Empty Return" section.
Trace information will also be provided.

* Guarantee through date for payments is provided.
* Reservation preferences are provided as an empty object indicating a first available preference.


```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "preference_datetimes": []
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Create Import Orchestration for the first available slot with two hours of "lead time"

The following request will create an orchestration for payment and the first available pick import
appointment, guaranteeing that the selected slot will end after the given threshold in minutes.
If it's currently 1:30pm, and a slot from 2:00pm to 3:00pm is available, a 120-minute threshold
will prevent this slot from being assigned since the threshold falls outside of the window. A later
slot will be selected if available.

```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "threshold": "120"
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Using a threshold to search for a slot for a limited time, and fail if no slot found after the limit

The following request will create an orchestration for payment and a pick import appointment at
a given date from 6:00pm to 10:00pm on Dec 30th, 2022. If the request is sent at 8:00 am on Dec
29th, 2022, and the request must error out after four hours if no appointment was found, the
threshold value needs to be 2040.
Basically, subtract the time limit from the end of the time preferences range: Dec 30th, 2022
10:00pm - Dec 29th, 2022 12:00pm (four hours after submitting the request) = 34 hours = 2040
minutes of threshold.

```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "try_later_dates": "N",
                "threshold": "120",
                "preference_datetimes": [
                  {
                    "range": [
                      "2021-12-30T18:00:00",
                      "2021-12-30T22:00:00"
                    ]
                  }
                ]
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Create Import Orchestration for reservation on a given date only

The following request will attempt to create a pick import pick import appointment for Jan 1st,
2021 after 7am. If no availability is found, the request will error out.

```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "try_later_dates": "N",
                "threshold": "120",
                "preference_datetimes": [
                  {
                    "range": [
                      "2021-01-01T07:00:00",
                      null
                    ]
                  }
                ]
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Create Import Orchestration for reservation between dates and times

An appointment can be requested between datetimes. In this example, the client is requesting a
pick import appointment between Jan 1st, 2021 at 7am and Jan 7th, 2021 at 5pm.

```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "try_later_dates": "N",
                "threshold": "120",
                "preference_datetimes": [
                  {
                    "range": [
                      "2021-01-01T07:00:00",
                      "2021-01-07T17:00:00"
                    ]
                  }
                ]
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Create Import Orchestration for reservation in time ranges

Appointments can also be requested to be confirmed between time ranges. The date will be
assumed to be the current date and later dates will be tried if no availability is found on the
current date. In this example, "Try every day from today, from 6:00 am to 2:00 pm and from 4:30
pm to 6:00 pm".

```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "try_later_dates": "N",
                "threshold": "120",
                "preference_datetimes": [
                  {
                    "range": [
                      "06:00:00",
                      "14:00:00"
                    ]
                  },
                  {
                    "range": [
                      "16:30:00",
                      "18:00:00"
                    ]
                  }
                ]
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Create Import Orchestration for reservation multiple time ranges

```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "try_later_dates": "N",
                "threshold": "120",
                "preference_datetimes": [
                  {
                    "range": [
                      "06:00:00",
                      "14:00:00"
                    ],
                    "days": [
                      2,
                      4,
                      6
                    ]
                  },
                  {
                    "range": [
                      "16:30:00",
                      "18:00:00"
                    ],
                    "days": [
                      1,
                      3,
                      5
                    ]
                  }
                ]
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Create Import Orchestration for reservation multiple time ranges after a given date

Each time range is tried after a given date if provided.

```shell curl
curl -i -X POST \
  /v1/orchestrations \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY_HERE' \
  -d '{
    "order": [
      {
        "trade_type": "I",
        "billoflading": "BOL12345",
        "unit": {
          "unit_nbr": "ABCD1234567"
        },
        "locations": [
          {
            "port_cd": "PORTA",
            "location_type": "O",
            "guarantee_through_date": "2021-01-01",
            "reservation_details": {
              "reservation_preferences": {
                "try_later_dates": "N",
                "threshold": "120",
                "preference_datetimes": [
                  {
                    "range": [
                      "06:00:00",
                      "14:00:00"
                    ],
                    "days": [
                      2,
                      4,
                      6
                    ],
                    "after": "2020-12-29"
                  },
                  {
                    "range": [
                      "16:30:00",
                      "18:00:00"
                    ],
                    "days": [
                      1,
                      3,
                      5
                    ],
                    "after": "2020-12-30"
                  }
                ]
              },
              "trucker_info": {
                "trucker_scac": "SCAC",
                "lic_plate_nbr": "ABCD",
                "lic_plate_state_cd": "CA",
                "driver_fname": "J",
                "driver_lname": "Doe"
              }
            }
          }
        ]
      }
    ]
  }'
```

### Create Import Orchestration for reservation multiple time ranges before a given date

Same as above using "before" instead of "after".