Skip to content

Creating a move lockout

Adam Sharp edited this page Aug 12, 2022 · 2 revisions

A lockout move composed of 2 journeys

  • Move from A to B
  • Journey from A to B (cancelled)
  • Journey from A to C
  • Journey from C to B
  1. Create a journey from A to B 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":"2022-08-12T08:01:39.276Z",
          "billable":true,
          "date": "2022-08-12",
          "vehicle":{
            "id":"12345678ABC",
            "registration":"AB12 CDE"
          }
        },
        "relationships":{
          "from_location":{
            "data":{
              "type":"locations",
              "id":"{LOCATION_A_ID}"
            }
          },
          "to_location":{
            "data":{
              "type":"locations",
              "id":"{LOCATION_B_ID}"
            }
          }
        }
      }
    }'
  2. Start journey 1 (A to B)

    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":"2022-08-12T08:03:44.088Z",
          "recorded_at":"2022-08-12T08:03:44.088Z",
          "notes":"example note: lorem ipsum dolor sit amet",
          "details":{
        
          },
          "event_type":"JourneyStart"
        },
        "relationships":{
          "eventable":{
            "data":{
              "type":"journeys",
              "id":"{JOURNEY_1_ID}"
            }
          }
        }
      }
    }'
  3. Create a MoveLockout event

    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":"2022-08-12T08:05:04.088Z",
          "recorded_at":"2022-08-12T08:05:04.088Z",
          "notes":"example note: lorem ipsum dolor sit amet",
          "details":{
            "reason":"no_space",
            "authorised_at":"2022-08-12T08:05:04+00:00",
            "authorised_by":"PMU"
          },
          "event_type":"MoveLockout"
        },
        "relationships":{ 
          "eventable":{
            "data":{
              "type":"moves",
              "id":"{MOVE_ID}"
            }
          },
          "from_location":{
            "data":{
              "type":"locations",
              "id":"{LOCATION_B_ID}"
            }
          }
        }
      }
    }'
  4. Cancel journey 1 (A to B)

    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":"2022-08-12T08:10:44.088Z",
          "recorded_at":"2022-08-12T08:10:44.088Z",
          "notes":"example note: lorem ipsum dolor sit amet",
          "details":{
        
          },
          "event_type":"JourneyCancel"
        },
        "relationships":{
          "eventable":{
            "data":{
              "type":"journeys",
              "id":"{JOURNEY_1_ID}"
            }
          }
        }
      }
    }'
  5. Create a journey from A to C 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":"2022-08-12T08:15:39.276Z",
          "billable":true,
          "date": "2022-08-12",
          "vehicle":{
            "id":"12345678ABC",
            "registration":"AB12 CDE"
          }
        },
        "relationships":{
          "from_location":{
            "data":{
              "type":"locations",
              "id":"{LOCATION_A_ID}"
            }
          },
          "to_location":{
            "data":{
              "type":"locations",
              "id":"{LOCATION_C_ID}"
            }
          }
        }
      }
    }'
  6. Create a journey from C to B 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":"2022-08-12T08:20:39.276Z",
          "billable":true,
          "date": "2022-08-13",
          "vehicle":{
            "id":"12345678ABC",
            "registration":"AB12 CDE"
          }
        },
        "relationships":{
          "from_location":{
            "data":{
              "type":"locations",
              "id":"{LOCATION_C_ID}"
            }
          },
          "to_location":{
            "data":{
              "type":"locations",
              "id":"{LOCATION_B_ID}"
            }
          }
        }
      }
    }'
Clone this wiki locally