Place a termination order
This guide describes how to place a termination order step by step.
The examples in this guide are meant to be used as a reference. The UUIDs and dates are not real and should be replaced with real data. The illustrations are for visual representation only and do not match the data used to explain the endpoints.
Step 1 - Retrieve the order draft id
GET /v1/profile/order-drafts
Swagger documentation here: Get profile order drafts
Response:
```json
{
"order_draft_id":"a474ad23-e9d0-4ea7-8562-e13fd0826583"
}
```
Step 2 - Update the draft with the end customer account
PATCH /v1/order-drafts/{orderDraftId}
Swagger documentation here: Update the order draft
Payload:
```json
[
{
"op":"add",
"path":"/order-on-account",
"value":"08684e47-9d25-4dc7-9d00-d288b1861ba9"
}
]
```
Properties
Option | Type | Description
----------- | ------ | ------------
`operation` | string | Operation to be performed. In this case "add"
`path` | string | Path to the property to be updated. In this case "/order-on-account"
`order_account_id` | UUID | UUID of the end customer account.
Step 3 - Place an empty change to the draft
PATCH /v1/order-drafts/{orderDraftId}
Swagger documentation here: Update the order draft
This will set the selected subscription(s) to the draft. Fetching the draft in next step will list the intake orders in the subscription(s). If more than one subscription is selected for changing, the payload should contain multiple operations as below, one for every subscription.
Payload:
```json
[
{
"op":"add",
"path":"/changes",
"value":
{
"subscription_id":"08684e47-9d25-4dc7-9d00-d288b1861ba9",
"products":[]
}
}
]
```
Properties
Option | Type | Description
----------- | ------ | ------------
`operation` | string | Operation to be performed. In this case "add"
`path` | string | Path to the property to be updated. In this case "/order-on-account"
`subscription_id` | UUID | UUID of the selected subscription.
`products` | array | Array of products to be added to the subscription. In this case, it is empty.
Step 4 - Retrieve the draft
GET /v1/order-drafts/{draftId}
Swagger documentation here: Get the order draft
Query Parameters:
Parameter | Required | Type | Description
----------- | ------ | ---------- |------------
`draftId` | required | UUID | UUID of the draft
Response:
```json
{
"_links": {
"intakes": {
"href": "/v1/order-drafts/a474ad23-e9d0-4ea7-8562-e13fd0826583/intakes"
},
"changes": {
"href": "/v1/order-drafts/a474ad23-e9d0-4ea7-8562-e13fd0826583/changes"
},
"terminates": {
"href": "/v1/order-drafts/a474ad23-e9d0-4ea7-8562-e13fd0826583/terminates"
}
},
"_embedded": {
"intakes": [],
"changes": [
{
"_links": {
"self": {
"href": "/v1/order-drafts/a474ad23-e9d0-4ea7-8562-e13fd0826583/changes/3a508bc2-02e7-4cb6-a747-6283e93e121e"
}
}
}
],
"terminates": []
},
"id": "a474ad23-e9d0-4ea7-8562-e13fd0826583",
"order_account_id": "829cd758-e448-4de1-a3ed-363a01666a3a",
"reference": "-"
}
```
Properties
Option | Type | Description
----------- | ------ | ------------
`order_account_id` | UUID | UUID of the wholesaler account
`reference` | string | Reference for the order
The link(s) for changes should be used to retrieve the products active in the subscription(s).
```json
"changes": [
{
"_links": {
"self": {
"href": "/v1/order-drafts/a474ad23-e9d0-4ea7-8562-e13fd0826583/changes/3a508bc2-02e7-4cb6-a747-6283e93e121e"
}
}
}
],
```
Step 5 - Get details of latest changes gives the products active in the subscription
GET /v1/order-drafts/{orderDraftId}/changes/{changeId}
Swagger documentation here: Update the order draft This step needs to be repeated for every change retrieved in step 9.
Query Parameters:
Parameter | Required | Type | Description
----------- | ------ | ---------- |------------
`orderDraftId` | required | UUID | UUID of the draft. In this example: a474ad23-e9d0-4ea7-8562-e13fd0826583
`changeId` | required | UUID | UUID of the change. In this example: 3a508bc2-02e7-4cb6-a747-6283e93e121e
Response:
```json
{
"_embedded": {
"active_products": [
{
"product_id":"a6c0bbb9-c865-4085-8c75-f634e0f2e60c",
"quantity":1
},
{
"product_id":"07cd1c6e-2532-5f74-8aa5-fe885de42d9f",
"quantity":1
},
{
"product_id":"0cd6d604-7d28-5f27-a1e2-cb2399e5912f",
"quantity":1
},
{
"product_id":"95f514fb-e715-508c-b1ec-7a933471f031",
"quantity":1
},
{
"product_id":"6c93335f-8f2a-5d36-b6a8-eb16a7765349",
"quantity":1
}
]
},
"change_id": "3a508bc2-02e7-4cb6-a747-6283e93e121e",
"subscription_id": "d373fc61-6a7b-4671-b359-e40b5043c132",
"wish_date": "2024-08-02",
"reference": "-",
"products": []
}
```
Step 6 - See individual prices for each product
Individual prices are explained in the Intake orders
Step 7 - Adds a termination to the draft
PATCH /v1/order-drafts/{orderDraftId}
Swagger documentation here: Update the order draft
This will set the selected subscription(s) to the draft.
Payload:
```json
[
{
"op":"add",
"path":"/terminates",
"value":
{
"reference":"test",
"subscription_id":"d373fc61-6a7b-4671-b359-e40b5043c132"
"wish_date":"2024-05-16",
}
}
]
```
Properties
Option | Type | Description
----------- | ------ | ------------
`operation` | string | Operation to be performed. In this case "add"
`path` | string | Path to the property to be updated. In this case "/order-on-account"
`subscription_id` | UUID | UUID of the selected subscription.
`reference` | string | Reference of the order.
`wish_date` | date(YYY-mm-dd) | Date the subscription is wished to be terminated.

Step 8 - Execute dry-run to validate the draft
POST /v1/accounts/{accountId}/orders?order_draft_id={orderDraftId}&dry_run=true
Swagger documentation here: Post an order with dry_run
Query Parameters:
Parameter | Required | Type | Description
----------- | ------ | ---------- |------------
`accountId` | required | UUID | UUID of the account
`orderDraftId` | required | UUID | UUID of the draft
Step 9 - Place the order
Finally, it is all settled to successfully submit the order. The order can handle multiple subscriptions. All the subscriptions in the order will be delivered on the same date (the date set for the order).
POST /v1/accounts/{accountId}/orders?order_draft_id={orderDraftId}
Swagger documentation here: Post an order
Query Parameters:
Parameter | Required | Type | Description
----------- | ------ | ---------- |------------
`accountId` | required | UUID | UUID of the account
`orderDraftId` | required | UUID | UUID of the draft
