Skip to main content

Manually run Prime API for Slice demo

Pricing Acceptance script is being used to mimick the Prime's use of the Prime API. If this script fails on a step, you will need to run the commands manually. This wiki page is to document the list of commands in order that would normally be run by the Prime.

1. Fetch MTOs available to the Prime

Assuming the MTO was created during the demo, fetch the latest MTO and save it to a file

 prime-api-client --cac --hostname api.stg.move.mil --port 443 fetch-mto-updates | jq 'sort_by(.updatedAt) | .[-1]' > demo_mto.json

If successful, go to step 2.

Other variations if needed

Fetch all MTOs

prime-api-client --cac --hostname api.stg.move.mil --port 443 fetch-mto-updates | jq

To find the latest MTO use a jq filter

  prime-api-client --cac --hostname api.stg.move.mil --port 443 fetch-mto-updates | jq 'sort_by(.updatedAt) | .[-1]'

To find the MTO by MoveOrderID use a jq filter

  prime-api-client --cac --hostname api.stg.move.mil --port 443 fetch-mto-updates | jq 'map(select(.moveOrderID == "uuid-for-moveorder-id")) | .[0]'

An additional filter can be added to only return the MTO ID

 prime-api-client --cac --hostname api.stg.move.mil --port 443 fetch-mto-updates | jq 'sort_by(.updatedAt) | .[-1]' | jq '.id'

2. Prime to update dates for the shipment

The shipmentID must be consistent between steps 2, 3, 4, and 5.

Date format: YYYY-MM-DD

Copy the payload to a file, filling in the variables. The file in this example will be demo_updates_dates.json

{
"mtoShipmentID": ${shipmentID},
"ifMatch": ${shipmentEtag},
"body": {
"scheduledPickupDate": "${scheduledPickupDate}",
"actualPickupDate": "${actualPickupDate}"
}
}
prime-api-client --cac --hostname api.stg.move.mil --port 443 update-mto-shipment --filename demo_updates_dates.json | jq

For help narrowing down the eTag you can use jq

The first .id is the MTO ID and the second .id is the Shipment ID.

prime-api-client --cac --hostname api.stg.move.mil --port 443  fetch-mto-updates | \
jq 'map(select(.id == "da3f34cc-fb94-4e0b-1c90-ba3333cb7791")) | .[0] | .mtoShipments | map(select(.id == "b4148fad-acc6-4065-b387-90d05a702a24")) | .[0] | .eTag'

If successful, go to step 3.

3. Prime to update the weights for the shipment

The shipmentID must be consistent between steps 2, 3, 4, and 5.

Copy the payload to a file, filling in the variables. The file is this example will be demo_update_weights.json

{
"mtoShipmentID": ${shipmentID},
"ifMatch": ${shipmentEtag},
"body": {
"primeEstimatedWeight": ${estimatedWeight},
"primeActualWeight": ${actualWeight}
}
}
prime-api-client --cac --hostname api.stg.move.mil --port 443 update-mto-shipment --filename demo_update_weights.json | jq

For help narrowing down the eTag you can use jq

The first .id is the MTO ID and the second .id is the Shipment ID.

prime-api-client --cac --hostname api.stg.move.mil --port 443 fetch-mto-updates | \
jq 'map(select(.id == "da3f34cc-fb94-4e0b-1c90-ba3333cb7791")) | .[0] | .mtoShipments | map(select(.id == "b4148fad-acc6-4065-b387-90d05a702a24")) | .[0] | .eTag'

If successful, go to step 4.

4. Prime to update destination address for the shipment

The shipmentID must be consistent between steps 2, 3, 4, and 5.

NOTE It is critical to pick a zip code that is not within 50 miles of the origin zip

Copy the payload to a file, filling in the variables. The file in this example will be demo_updates_dates.json

{
"mtoShipmentID": ${shipmentID},
"ifMatch": ${shipmentEtag},
"body": {
"destinationAddress": {
"streetAddress1": "${destStreetAddress1}",
"city": "${destCity}",
"state": "${destState}",
"postalCode": "${destZip}",
"country": "US"
}
}
}
prime-api-client --cac --hostname api.stg.move.mil --port 443 update-mto-shipment --filename demo_updates_dates.json | jq

For help narrowing down the eTag you can use jq

The first .id is the MTO ID and the second .id is the Shipment ID.

prime-api-client --cac --hostname api.stg.move.mil --port 443  fetch-mto-updates | \
jq 'map(select(.id == "da3f34cc-fb94-4e0b-1c90-ba3333cb7791")) | .[0] | .mtoShipments | map(select(.id == "b4148fad-acc6-4065-b387-90d05a702a24")) | .[0] | .eTag'

If successful, go to step 3.

5. Prime creates a payment request

The shipmentID must be consistent between steps 2, 3, 4, and 5.

Create the payload

Edit the list of service codes as needed for the demo

jq '.mtoServiceItems | map(select((.mtoShipmentID == "e272af65-c662-40e3-a47b-9711942d9ce1") and (.reServiceCode == "FSC" or .reServiceCode == "DLH") or .reServiceCode == "MS" or .reServiceCode == "CS")) | { body: { isFinal: false, moveTaskOrderID: "ec88724f-bfa9-4d89-8833-4fcfab24ef59", serviceItems: map({ id: .id }) } }' demo_mto.json > demo_create_payment_request.json

Review the payload

jq . demo_create_payment_request.json

Send the payment request and save the response

prime-api-client --cac --hostname api.stg.move.mil --port 443 create-payment-request --filename demo_create_payment_request.json > demo_create_payment_request_response.json

Get the payment request ID and payment request Number

jq .id demo_create_payment_request_response.json
jq .paymentRequestNumber demo_create_payment_request_response.json

If successful, go to step 5.

6. Prime adds proof of service documents

Get the list of documents that you want to send e.g. (./tmp/uploads/proof_of_service.png ./tmp/uploads/proof_of_service.jpg ./tmp/uploads/proof_of_service.pdf)

for proofOfService in "./tmp/uploads/proof_of_service.png" "./tmp/uploads/proof_of_service.jpg" "./tmp/uploads/proof_of_service.pdf"; do
if [ -f "$proofOfService" ]; then
echo "Uploading file ${proofOfService}."
proofBase=$(basename "${proofOfService}")
prime-api-client --cac --hostname api.stg.move.mil --port 443 create-upload --paymentRequestID "${prID}" --filename "${proofOfService}" > demo_create_upload_response_"${proofBase}".json
else
echo "File ${proofOfService} does not exist, skipping upload."
fi
done

If successful, go to step 6

Store fake upload files to ./tmp/uploads

If you would like to following this example as-is. You can copy these files to your ./tmp/uploads directory

7. Generate EDI in 858 format for the Payment Request

Use the payment ID from step #5.

Save payload to filename demo_get_payment_request_edi.json

{
"paymentRequestID": "${prID}"
}
prime-api-client --cac --hostname api.stg.move.mil --port 443 support-get-payment-request-edi --filename demo_get_payment_request_edi.json | jq -r '.edi' > demo_edi_response.json; cat  demo_edi_response.json

8. Update the payment requests status

Use the payment ID from step #5.

Save payload to a filename demo_update_payment_request_status.json

{
"body": {
"paymentRequestID": "${prID}",
"sendToSyncada": false
}
}
prime-api-client --cac --hostname api.stg/move.mil --port 443 support-reviewed-payment-requests --filename demo_update_payment_request_status.json

If successful, Prime demo is complete 🎉.

References