# Application Settings Services

All services related to application settings are listed in this page.

### `GET` List Application Settings

This service is used to retrieve all application settings with detailed information.

**Path:** `/api/v1/oms/settings/application_settings/`

**Query Parameters**

The following query parameters can be used to get information about application settings.

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

**Example Request**

To get a list of all application settings, a `GET` request should be sent to the `/api/v1/oms/settings/application_settings/` endpoint.

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

```python
import requests

url = "https://{domain_url}/api/v1/oms/settings/application_settings/"
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 all the application settings. The response body contains `JSON` objects of application settings and their attributes such as ID, key and json\_value.

These attributes are described in the following table.

| Parameter   | Data Type | Description                               |
| ----------- | --------- | ----------------------------------------- |
| id          | integer   | The ID of the application setting         |
| key         | string    | The key info of the application setting   |
| json\_value | string    | The value info of the application setting |

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

```json
{
  "count": 6,
  "next": "https://{domain_url}/api/v1/oms/settings/application_settings/",
  "previous": null,
  "results": [
    {
      "id": 1,
      "key": "IS_TRADEIN_ENABLED",
      "json_value": false
    },
    {
      "id": 2,
      "key": "test_count",
      "json_value": 1
    },
    {
      "id": 3,
      "key": "test_key",
      "json_value": "test_value"
    },
    {
      "id": 4,
      "key": "GEOCODE_PROVIDER_SETTINGS",
      "json_value": {
        "conf": {
          "api_key": "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d",
          "base_url": "https://{map_url}",
          "timeouts": {
            "read": 50.0,
            "connect": 5.0
          }
        },
        "client": "yandex"
      }
    },
    {
      "id": 5,
      "key": "OMNITRON_CLIENT_SETTINGS",
      "json_value": {
        "auth": {
          "password": "123",
          "username": "oms.application"
        },
        "urls": {
          "oms_url": "{oms_url}",
          "base_url": "{omnitron_url}"
        },
        "timeouts": {
          "read": 6000.0,
          "connect": 6000.0
        }
      }
    },
    {
      "id": 6,
      "key": "ORDER_FILTERING",
      "json_value": {
        "status": {
          "enum": "oms.orders.enums.OrderStatus",
          "value": "approved"
        },
        "channel": [
          1
        ],
        "is_send": true
      }
    }
  ]
}
```

### `GET` Retrieve Single Application Setting Detail

This service is used to retrieve detailed information about a single application setting with a specific ID.

**Path:** `/api/v1/oms/settings/application_settings/{id}/`

**Query Parameters**

The following query parameters can be used to get the information about a specific application setting.

| Parameter | Data Type | In     | Description                         |
| --------- | --------- | ------ | ----------------------------------- |
| token     | string    | header | The API key of the customer account |
| {id}      | integer   | url    | The ID of the application setting   |

**Example Request**

To retrieve detailed information of a specific application setting, a `GET` request should be sent to the `/api/v1/oms/settings/application_settings/{id}/` endpoint.

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

```python
import requests

url = "https://{domain_url}/api/v1/oms/settings/application_settings/{id}/"
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 detailed information of a specific application setting. The response body contains a `JSON` object with the attributes such as ID, key and json\_value.

These attributes are described in the following table.

| Parameter   | Data Type | Description                               |
| ----------- | --------- | ----------------------------------------- |
| id          | integer   | The ID of the application setting         |
| key         | string    | The key info of the application setting   |
| json\_value | string    | The value info of the application setting |

This example response serves as a reference to understand the structure and data format returned from this API service. It is showed `ORDER_FILTERING` setting as an example.

```json
{
  "id": 36,
  "key": "ORDER_FILTERING",
  "json_value": {
    "status": {
      "enum": "oms.orders.enums.OrderStatus",
      "value": "approved"
    },
    "channel": [
      1
    ],
    "is_send": false
  }
}
```

### `GET` Retrieve Application Setting Fields

Every application setting has unique `key`. `json_value` of every application setting differs according to its `key`.

This service is used the get the `json_value` details of a specific `key`.

**Path:** `/api/v1/oms/settings/application_settings/settings_fields/`

**Query Parameters**

The following query parameters can be used to get the information about json value of a specidic application setting

The `settings_key` field is mandatory; otherwise, the server will respond with a 400 Bad Request error.

| Parameter     | Data Type | In     | Description                         |
| ------------- | --------- | ------ | ----------------------------------- |
| token         | string    | header | The API key of the customer account |
| settings\_key | string    | params | The key of the application setting  |

These are the list of `setting keys` in the system.

You can provide one of them as a query parameter.

| Application Settings Key                                     |
| ------------------------------------------------------------ |
| GEOCODE\_PROVIDER\_SETTINGS                                  |
| GEOLOCATION\_DISCOVERY                                       |
| MAX\_FULFILMENT\_TIME\_OF\_ORDER\_ITEM                       |
| OMNITRON\_CLIENT\_SETTINGS                                   |
| ORDER\_ITEM\_EXCLUSION\_METHODS                              |
| ORDER\_FILTERING                                             |
| PACKAGE\_NUMBER\_GENERATOR\_PATTERN                          |
| IS\_CLICK\_AND\_COLLECT\_ENABLED                             |
| SHIPPED\_THRESHOLD\_DAYS                                     |
| IS\_RESERVATION\_ACTIVE                                      |
| COD\_FEE\_BASE\_CODE\_VALUE                                  |
| MIN\_ORDER\_OMNITRON\_ID                                     |
| OMNITRON\_APPLICATION\_ID                                    |
| CLASS\_MAPPING                                               |
| IS\_TRADEIN\_ENABLED                                         |
| ALLOWED\_PACKAGE\_STATES\_FOR\_RESERVATION                   |
| ALLOWED\_TRANSFER\_STATES\_FOR\_RESERVATION                  |
| IS\_THE\_PICKUP\_LOCATION\_FROM\_THE\_STORE\_PACKING\_CENTER |

**Example Request**

To get a details of json\_value of a specific application setting, a `GET` request should be sent to the `/api/v1/oms/settings/application_settings/settings_fields/` endpoint.

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

```python
import requests

url = "https://{domain_url}/api/v1/oms/settings/application_settings/settings_fields/?settings_key=ORDER_FILTERING"
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 json\_value details of given application setting. The response body contains a `JSON` object with the attributes such as type, required, children etc.

These attributes are described in the following table.

| Parameter  | Data Type | Description                                                                                          |
| ---------- | --------- | ---------------------------------------------------------------------------------------------------- |
| type       | string    | What kind of data will be stored in the application setting for example an object, list or integer ? |
| required   | boolean   | Is it required to show application setting on the frontend ?                                         |
| read\_only | boolean   | Is the application setting read only or can be updated ?                                             |
| label      | string    | label of the application setting                                                                     |
| children   | json      | Sub fields of the application setting (if it has)                                                    |

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

`ORDER_FILTERING` setting has a `json_value` as follows:

```json
{
  "json_value": {
    "type": "nested object",
    "required": true,
    "read_only": false,
    "label": "Json value",
    "children": {
      "status": {
        "type": "nested object",
        "required": false,
        "read_only": false,
        "label": "Status",
        "children": {
          "enum": {
            "type": "string",
            "required": true,
            "read_only": false,
            "label": "Enum"
          },
          "value": {
            "type": "string",
            "required": true,
            "read_only": false,
            "label": "Value"
          }
        }
      },
      "channel": {
        "type": "list",
        "required": false,
        "read_only": false,
        "label": "Channel",
        "child": {
          "type": "field",
          "required": true,
          "read_only": false
        }
      },
      "is_send": {
        "type": "boolean",
        "required": false,
        "read_only": false,
        "label": "Is send"
      }
    }
  }
}
```

`SHIPPED_THRESHOLD_DAYS` setting has a `json_value` as belows.

```json
{
  "json_value": {
    "type": "integer",
    "required": true,
    "read_only": false,
    "label": "Json value",
    "min_value": 1
  }
}
```

### `POST` Create Application Setting

This service is used to create a new application setting with the request body.

**Path:** `/api/v1/oms/settings/application_settings/`

**Request Body**

The following request body parameters can be used to create an application setting object.

| Parameter   | Data Type | In     | Description                               |
| ----------- | --------- | ------ | ----------------------------------------- |
| token       | string    | header | The API key of the customer account       |
| key         | string    | body   | The key of the application setting        |
| json\_value | string    | body   | The json value of the application setting |

`json_value` parameter differs for each other application setting. The value of this field must be obtained from the `Application Settings Fields` service by key.

For instance, `ORDER_FILTERING` setting has a request body as follows:

```json
{
  "key": "ORDER_FILTERING",
  "json_value": {
    "status": {
      "enum": "oms.orders.enums.OrderStatus",
      "value": "approved"
    },
    "channel": [
      1
    ],
    "is_send": true
  }
}
```

`SHIPPED_THRESHOLD_DAYS` setting has a request body as follows:

```json
{
  "key": "SHIPPED_THRESHOLD_DAYS",
  "json_value": 5
}
```

**Example Request**

To create a new application setting, a POST request should be sent to the `/api/v1/oms/settings/application_settings/` endpoint.

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

```python
import requests
import json

url = "https://{instore_url}/api/v1/oms/settings/application_settings/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
    "key": "ORDER_FILTERING",
    "json_value": {
        "status": {
            "enum": "oms.orders.enums.OrderStatus",
            "value": "approved"
        },
        "channel": [
            1
        ],
        "is_send": true
    }
})

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Token {}'.format(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 API indicates that a new application setting has been successfully created.The response body contains a JSON object representing the newly created application setting, including its unique ID and any additional information provided during the creation process.

| Parameter   | Data Type | In     | Description                               |
| ----------- | --------- | ------ | ----------------------------------------- |
| token       | string    | header | The API key of the customer account       |
| key         | string    | body   | The key of the application setting        |
| json\_value | string    | body   | The json value of the application setting |

This example response serves as a reference to understand the structure and data format returned when a new application setting is created successfully.

```json
{
  "id": 36,
  "key": "ORDER_FILTERING",
  "json_value": {
    "status": {
      "enum": "oms.orders.enums.OrderStatus",
      "value": "approved"
    },
    "channel": [
      1
    ],
    "is_send": true
  }
}
```

**Example Response (400 Bad Request)**

In an unsuccessful response with a status code of 400 Bad Request, the API indicates that the request could not be processed due to client error. The response body contains a JSON object that provides additional information about the error, including an error message or validation errors.

This example response serves as a reference to understand the structure and data format returned when a request fails due to client error.

```json
{
  "error": {
    "json_value": {
      "is_send": [
        "Must be a valid boolean."
      ]
    }
  },
  "status_code": 400
}
```

### `PUT` Update Application Setting

This service is used to update an aplication setting with the request body.

**Path:** `/api/v1/oms/settings/application_settings/{id}/`

**Request Body**

The following request body parameters can be used to update an application setting.

| Parameter   | Data Type | In     | Description                               |
| ----------- | --------- | ------ | ----------------------------------------- |
| token       | string    | header | The API key of the customer account       |
| json\_value | string    | body   | The json value of the application setting |

**Example Request**

To update an application setting, a `PUT` request should be sent to the `/api/v1/oms/settings/application_settings/{id}/` endpoint.

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

```python
import requests
import json

url = "https://{instore_url}/api/v1/oms/settings/application_settings/{id}/"
token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

payload = json.dumps({
    "json_value": {
        "status": {
            "enum": "oms.orders.enums.OrderStatus",
            "value": "approved"
        },
        "channel": [
            1
        ],
        "is_send": false
    }
})

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Token {}'.format(token)
}

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

print(response.text)
```

**Example Response (200 OK)**

In a successful response with a status code of 200 OK, the API indicates that the application setting has been successfully updated. The response body does not contain any messages or json objects.


---

# 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/application-settings-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.
