Skip to content

Single journey move

Thomas Leese edited this page Feb 8, 2022 · 2 revisions

A standard move composed of a single billable journey

  • Move from A to B
  • Journey from A to B (billable, proposed -> started -> completed)
  1. Create a billable journey for the move (in a proposed state)

    curl --request POST \
      --url /api/moves/{MOVE_ID}/journeys \
      --header 'Authorization: Bearer {OAUTH_TOKEN}' \
      --header 'Content-Type: application/json' \
      --header 'Idempotency-Key: {RANDOM_UUID}' \
      --data '{
      "data":{
        "type":"journeys",
        "attributes":{
          "timestamp":"2021-05-07T11:08:39.276Z",
          "billable":true,
          "date": "2021-05-07",
          "vehicle":{
            "id":"12345678ABC",
            "registration":"AB12 CDE"
          }
        },
        "relationships":{
          "from_location":{
            "data":{
              "type":"locations",
              "id":"dc76e71d-413b-48c8-b1cf-85c702c5f465"
            }
          },
          "to_location":{
            "data":{
              "type":"locations",
              "id":"8fa68589-8ded-435c-b0c1-ffcade5f1bef"
            }
          }
        }
      }
    }'
  2. Start the journey, changing its state from proposed to in_progress

    curl --request POST \
      --url /api/events \
      --header 'Authorization: Bearer {OAUTH_TOKEN}' \
      --header 'Content-Type: application/json' \
      --header 'Idempotency-Key: {RANDOM_UUID}' \
      --data '{
      "data":{
        "type":"events",
        "attributes":{
          "occurred_at":"2021-05-07T11:13:44.088Z",
          "recorded_at":"2021-05-07T11:13:44.088Z",
          "notes":"example note: lorem ipsum dolor sit amet",
          "details":{
        
          },
          "event_type":"JourneyStart"
        },
        "relationships":{
          "eventable":{
            "data":{
              "type":"journeys",
              "id":"e73f6005-afec-41e2-bcaa-a9747b5af8e3"
            }
          }
        }
      }
    }'
  3. Complete the journey, changing its state from in_progress to completed

    curl --request POST \
      --url /api/events \
      --header 'Authorization: Bearer {OAUTH_TOKEN}' \
      --header 'Content-Type: application/json' \
      --header 'Idempotency-Key: {RANDOM_UUID}' \
      --data '{
      "data":{
        "type":"events",
        "attributes":{
          "occurred_at":"2021-05-07T11:19:34.624Z",
          "recorded_at":"2021-05-07T11:19:34.624Z",
          "notes":"example note: lorem ipsum dolor sit amet",
          "details":{
        
          },
          "event_type":"JourneyComplete"
        },
        "relationships":{
          "eventable":{
            "data":{
              "type":"journeys",
              "id":"e73f6005-afec-41e2-bcaa-a9747b5af8e3"
            }
          }
        }
      }
    }'
Clone this wiki locally