Creating a move lockout - ministryofjustice/hmpps-book-secure-move-api GitHub Wiki
A lockout move composed of 2 journeys
- Move from
A
toB
- Journey from
A
toB
(cancelled) - Journey from
A
toC
- Journey from
C
toB
-
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}" } } } } }'
-
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}" } } } } }'
-
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}" } } } } }'
-
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}" } } } } }'
-
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}" } } } } }'
-
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}" } } } } }'