# Stock Location Sender Address Setup Services

All services related to stock location sender address setup are listed in this document.

### `GET` Is Required

This service is used to determine whether the stock location sender address setup task needs to be executed. If there are any pairs of stock location-cargo company for active stock locations and active cargo companies using the Akinon extension client that lack sender address records, this endpoint returns `true`; otherwise, it returns `false`.

**Path:** `/api/v1/oms/setup/stock_location_sender_addresses/is_required/`

**Query Parameters**

The following query parameters can be used to check the requirement of the task.

| Parameter | Data Type | In     | Description                         |
| --------- | --------- | ------ | ----------------------------------- |
| token     | string    | header | The API key of the customer account |

**Example Request**

To check the requirement of the task, a `GET` request should be sent to`/api/v1/oms/setup/stock_location_sender_addresses/is_required/` endpoint.

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

```python
import requests

url = "https://{domain_url}/api/v1/oms/setup/stock_location_sender_addresses/is_required/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

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

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

print(response.json())
```

**Example Response (200 OK)**

In a successful response with a status code of `200 OK`, the API returns the requirement status of the task as `boolean` value. If the result is `true`, it indicates that we must execute setup task.If the result is `false`, it signifies that we don't need to execute the setup task.

These attributes are described in the following table.

| Parameter | Data Type | Description                           |
| --------- | --------- | ------------------------------------- |
| result    | boolean   | The requirement status of the service |

This example response serves as a reference to understand the structure and\
data format returned from this API service.

```json
{
  "result": true
}
```

### `POST` Execute

It creates sender address information for each stock location. This step is necessary for the proper shipping of packages that utilize the Akinon shipment client.

**Path:** `/api/v1/oms/setup/stock_location_sender_addresses/execute/`

**Query Parameters**

The following query parameters can be used to execute the task.

| Parameter | Data Type | In     | Description                         |
| --------- | --------- | ------ | ----------------------------------- |
| token     | string    | header | The API key of the customer account |

**Example Request**

To create the sender address information for each stock location, a `POST`\
request should be sent to the `/api/v1/oms/setup/stock_location_sender_addresses/execute/`\
endpoint.

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

```python
import requests

url = "https://{domain_url}/api/v1/oms/setup/stock_location_sender_addresses/execute/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

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

response = requests.request('POST', url, headers=headers)

print(response.json())
```

**Example Response (204 No Content)**

In a successful response, the API returns with a status code of `204 No Content`.

### `GET` Get Async Status

This service is used to check the status of the task initiated for creating sender address information for each stock location.

**Path:** `/api/v1/oms/setup/stock_location_sender_addresses/get_async_status/`

**Query Parameters**

The following query parameters can be used to check the status of the task.

| Parameter | Data Type | In     | Description                         |
| --------- | --------- | ------ | ----------------------------------- |
| token     | string    | header | The API key of the customer account |

**Example Request**

To check the status of the task, a `GET` request should be sent to`/api/v1/oms/setup/stock_location_sender_addresses/get_async_status/` endpoint.

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

```python
import requests

url = "https://{domain_url}/api/v1/oms/setup/stock_location_sender_addresses/get_async_status/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

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

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

print(response.json())
```

**Example Response (200 OK)**

In a successful response with a status code of `200 OK`, the API returns the\
status of the task as string value. Possible values are `Ready`, `Working`,`Finished`, `Failed`, `Aborted`.

| Parameter | Data Type | Description                           |
| --------- | --------- | ------------------------------------- |
| result    | string    | The requirement status of the service |

This example response serves as a reference to understand the structure and data format returned from this API service.

```json
{
  "result": "Working"
}
```
