# OMS Setup Services

In Omnitron, a setup is a collection of settings used to configure the OMS (Order Management System). This service retrieves these settings from Omnitron and prepares the OMS for its initial configuration.

### `POST` Run OMS Setup

This service is used to run the OMS setup.

**Path:** `/api/v1/oms/oms_setup/`

**Payload**

| Parameter         | Data Type | In   | Description                                         |
| ----------------- | --------- | ---- | --------------------------------------------------- |
| username          | `string`  | body | The username of the application                     |
| password          | `string`  | body | The password of the application                     |
| auth\_token       | `string`  | body | The auth token of the application                   |
| application\_id   | `int`     | body | The application ID                                  |
| user\_id          | `int`     | body | The user id                                         |
| oms\_url          | `string`  | body | The oms url                                         |
| omnitron\_url     | `string`  | body | The omnitron url                                    |
| load\_fixtures    | `bool`    | body | To load fixtures set True, not required             |
| whippy\_ware\_url | `string`  | body | To load whippyware set this parameter, not required |

**Example Request**

To run this service, a `POST` request should be sent to `/api/v1/oms/oms_setup/` endpoint. Celery tasks will be triggered to complete the setup tasks.

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

```python
import requests

url = "https://{oms_base_url}/api/v1/oms/oms_setup/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload={
    "username": "oms_user_124",
    "application_id": 124,
    "auth_token": "28afd3fa77c37083f1f6e8fbeae312e04e1b2ew",
    "password": "A30x0cBhqc",
    "user_id": 12,
    "omnitron_url": "test-bo.akinon.net",
    "oms_url": "https://841407a553684dd781d0f591eed9cb84.lb.akinoncloud.org",
    "whippy_ware_url": "https://whippy_ware.lb.akinoncloud.org"
}
headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

**Example Response (201 CREATED)**

In a successful response with a status code of 201 CREATED, the response body does not contain any objects or messages.

### `GET` Query OMS Setup Status

This service is used to check the status of the "OMS Setup" and whether it has been completed or not.

**Path:** `/api/v1/oms/is_setup_completed/`

**Example Request**

To retreive information about status of the OMS Setup, a GET request shoud be sent. No parameters are required.

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

```python
import requests

url = "https://{oms_base_url}/api/v1/oms/is_setup_completed/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'Accept': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.request("GET", url, headers=headers)

print(response.text)
```

**Example Response (200 OK)**

If the OMS Setup has been completed, it will return a successful response with a status code of `200 OK`.

| Parameter           | Data Type | Description                          |
| ------------------- | --------- | ------------------------------------ |
| is\_task\_completed | bool      | Status of the OMS setup tasks        |
| context             | object    | Detail of the each setup task status |
