# Cancellation Reason Services

In Omnitron, when an order item or the entire order is canceled or refunded, a cancellation reason must be selected. This service pulls these cancellation reasons from Omnitron and provides access to them through both detailed and list endpoints.

### `GET` Pull Cancelation Reasons from Omnitron

**Path:** `/api/v1/oms/cancellation-reasons/pull_from_omnitron/`

**Example Request**

To run this service, a `GET` request should be sent to the `/api/v1/oms/cancellation-reasons/pull_from_omnitron/` endpoint. In the headers, set the `Authorization` header to include the api token for authentication.

Here's an example of how to make the request in python:

```python
import requests
import json
url = "https://{domain_url}/api/v1/oms/cancellation-reasons/pull_from_omnitron/"
token = "11111XXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Token {token}'
}

response = requests.request('GET', url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

When the cancellation reasons are successfully pulled from Omnitron, the service will respond with a status code of `200 OK` to indicate success.

The response body will not include any additional objects or messages.

**Example Response (401 UNAUTHORIZED)**

If the authorization token is either missing or incorrect in the request headers, the service will respond with a status code of `401 Unauthorized`.

The response body will not include any additional objects or messages.

### `GET` List Cancellation Reasons

**Path:** `/api/v1/oms/cancellation-reasons/`

**Example Request**

To run this service, a `GET` request should be sent to the `/api/v1/oms/cancellation-reasons/`endpoint. In the headers, set the `Authorization` header to include the api token for authentication.

Here's an example of how to make the request in python:

```python
import requests
import json
url = "https://{domain_url}/api/v1/oms/api/v1/oms/cancellation-reasons/"
token = "11111XXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Token {token}'
}

response = requests.request('GET', url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

If cancellation reasons successfully pulled from omnitron, it will return a\
successful response with a status code of `200 OK`. The response body contains list of objects.

| Parameter                  | Data Type | Description                     |
| -------------------------- | --------- | ------------------------------- |
| id                         | integer   | The primary key of the provider |
| cancellation\_type         | string    | The name of the provider        |
| created\_date              | date      | The creation date               |
| modified\_date             | date      | The last modified date          |
| omnitron\_id               | integer   | The omnitron ID of object       |
| subject                    | string    | The subject                     |
| extra\_information\_needed | bool      | The extra information flag      |
| ordering                   | integer   | The ordering                    |
| is\_active                 | boolean   | The active flag                 |

```json

{
    "count": 2,
    "next": "http://{domain_url}/api/v1/oms/cancellation-reasons/?page=2",
    "previous": null,
    "results": [
        {
            "id": 1,
            "cancellation_type": "cancel",
            "created_date": "2023-07-04T10:30:31.298861Z",
            "modified_date": "2023-07-04T10:30:31.298873Z",
            "omnitron_id": 1,
            "subject": "Yanl\u0131\u015f \u00fcr\u00fcn ald\u0131m.",
            "extra_information_needed": false,
            "ordering": 100,
            "is_active": true
        },
        {
            "id": 2,
            "cancellation_type": "cancel",
            "created_date": "2023-07-04T10:30:31.302982Z",
            "modified_date": "2023-07-04T10:30:31.302995Z",
            "omnitron_id": 2,
            "subject": "\u00dcr\u00fcn\u00fc sat\u0131n almaktan vazge\u00e7tim.",
            "extra_information_needed": false,
            "ordering": 100,
            "is_active": true
        }
    ]
}

```

**Example Response (401 UNAUTHORIZED)**

If the authorization token is either missing or incorrect in the request headers, the service will respond with a status code of `401 Unauthorized`.

The response body will not include any additional objects or messages.

### `GET` Detail Cancellation Reasons

**Path:** `/api/v1/oms/cancellation-reasons/{pk}/`

**Example Request**

To run this service, a `GET` request should be sent to the `/api/v1/oms/cancellation-reasons/{pk}/`endpoint. In the headers, set the`Authorization` header to include the api token for authentication.

Here's an example of how to make the request in python:

```python
import requests
import json
url = "https://{domain_url}/api/v1/oms/api/v1/oms/cancellation-reasons/1/"
token = "11111XXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Token {token}'
}

response = requests.request('GET', url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

When the cancellation reasons are successfully pulled from Omnitron, the service will respond with a status code of `200 OK` to indicate success.

In this case, the response body will contain one object.

| Parameter                  | Data Type | Description                     |
| -------------------------- | --------- | ------------------------------- |
| id                         | integer   | The primary key of the provider |
| cancellation\_type         | string    | The name of the provider        |
| created\_date              | date      | The creation date               |
| modified\_date             | date      | The last modified date          |
| omnitron\_id               | integer   | The omnitron ID of object       |
| subject                    | string    | The subject                     |
| extra\_information\_needed | bool      | The extra information flag      |
| ordering                   | integer   | The ordering                    |
| is\_active                 | boolean   | The active flag                 |

```json

{
    "id": 1,
    "cancellation_type": "cancel",
    "created_date": "2023-07-04T10:39:40.453069Z",
    "modified_date": "2023-07-04T10:39:40.453081Z",
    "omnitron_id": 1,
    "subject": "Yanl\u0131\u015f \u00fcr\u00fcn ald\u0131m.",
    "extra_information_needed": false,
    "ordering": 100,
    "is_active": true
}

```

**Example Response (401 UNAUTHORIZED)**

If the authorization token is either missing or incorrect in the request headers, the service will respond with a status code of `401 Unauthorized`.

The response body will not include any additional objects or messages.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.akinon.com/oms/cancellation-reason-services.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
