ガイドAPIリファレンス
ガイド

出荷計画を作成する

このチュートリアルでは、「出荷を作成する」と同じトピックを使用します。また、タンペレピルカ空港からヘルシンキ空港を経由してベルリンブランデンブルク空港まで飛行機で向かう、同じルートの出荷計画を作成します。

重要 出荷計画API (/shipments/v4/plans)は廃止されました。

前提条件

ユーザーをログインする

ユーザーをログインします。これにより、ユーザーアクセストークンuserTokenが返されます。このトークンは後のリクエストに必要です。

出荷計画を作成する

出荷計画を作成するには、出荷計画エンドポイントにリクエストを送信します。

curl -X POST \
    'https://{tcHost}/shipments/v4/plans' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer {userToken}' \
    -d '{
        "name":"From Tampere-Pirkkala to Berlin Brandenburg",
        "description":"A shipment from the Tampere-Pirkkala airport to the Berlin Brandenburg airport",
        "autoStart":"true",
        "segments": [
            {
                "name":"From Tampere-Pirkkala to Helsinki",
                "description":"Origin of the shipment",
                "transportMode":"air",
                "origin":"LOC-f79d965d-9124-446d-b0b4-f71ae793f602",
                "destination"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb",
                "durationS":"3600"
            },
            {
                "name":"Dwelling at Helsinki",
                "description":"Waypoint of the shipment where shipment dwells",
                "transportMode":"undefined",
                "origin":"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb",
                "destination"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb",
                "durationS":"22500"
            },
            {
                "name":"From Helsinki to Brandenburg",
                "description":"Destination of the shipment",
                "transportMode":"air",
                "origin":"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb",
                "destination"LOC-878c8e9e-2821-11ec-8fc2-00155ddd7ddb",
                "durationS":"9000"
            }
        ]
    }'
{
  "shipmentPlanId": "SHPP-3de93876-2837-11ec-aecc-00155ddd7ddb"
}

出荷計画から出荷を作成する

出荷計画はテンプレートとして機能し、これを使用して詳細が事前に入力されている出荷を作成できます。 出荷を作成するには、shipmentsエンドポイントにリクエストを送信します。

curl -X POST \
    'https://{tcHost}/shipments/v4' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer {userToken}' \
    -d '{
        "shipmentPlanId":"SHPP-3de93876-2837-11ec-aecc-00155ddd7ddb",
        "shipmentDeparture":"2021-10-01T06:30:00Z"
    }'
{
  "shipmentPlanId": "SHP-8bd8fbe6-2839-11ec-bc08-00155ddd7ddb"
}

セグメントにデバイスを割り当てる

この出荷では、各セグメントで1つのデバイスを使用します。 shipmentsエンドポイントにリクエストを送信します。

curl -X PATCH \
    'https://{tcHost}/shipments/v4/SHP-8bd8fbe6-2839-11ec-bc08-00155ddd7ddb' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer {userToken}' \
    -d '{
        "name":"From Tampere-Pirkkala to Berlin Brandenburg",
        "description":"A shipment from the Tampere-Pirkkala airport to the Berlin Brandenburg airport",
        "autoStart":"true",
        "segments": [
            {
                "transportMode":"air",
                "trackingId":"{trackingId}",
                "origin":"LOC-f79d965d-9124-446d-b0b4-f71ae793f602",
                "destination":"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb"
            },
            {
                "transportMode":"undefined",
                "trackingId":"{trackingId}",
                "origin":"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb",
                "destination":"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb"
            },
            {
                "transportMode":"air",
                "trackingId":"{trackingId}",
                "origin":"LOC-7e814132-2821-11ec-ba1d-00155ddd7ddb",
                "destination":"LOC-878c8e9e-2821-11ec-8fc2-00155ddd7ddb"
            }
        ]
    }'

これによりデバイスがセグメントに割り当てられ、成功した場合はステータスコード204の空のレスポンスが返されます。