# Question

## Module endpoints

* [`DELETE /questions/:id`](#delete-questions-id)​
* ​[`GET /questions`](#get-invites)​
* ​[`GET /questions/:id`](#get-questions-id)​
* [`GET /question-types`](#get-invites-1)​
* ​[`PATCH /questions/:id`](#patch-questions-id)​
* ​[`POST /questions`](#post-questions)​

### `DELETE /questions/:id`

> `DELETE` <http://api.slyk.i&#x6F;**/questions/:id>\*\*

Deletes the `question` with given `id`.

{% tabs %}
{% tab title="Response" %}

> `204` No Content
> {% endtab %}
> {% endtabs %}

### `GET /questions` <a href="#get-invites" id="get-invites"></a>

> `GET` <https://api.slyk.i&#x6F;**/questions>\*\*

Returns a paginated list of `questions`.

{% tabs %}
{% tab title="Available Filters" %}

| Name                |      Type      | Example                                           |
| ------------------- | :------------: | ------------------------------------------------- |
| **id**              | `=` `in` `nin` | `filter[id]=7938e446-1c77-4513-8cb0-8b1f2e9f47b9` |
| **productTypeCode** |     `ilike`    | `filter[productTypeCode]=bar`                     |
| **title**           |     `ilike`    | `filter[title]=foo`                               |
| **typeCode**        | `=` `in` `nin` | `filter[typeCode]=nin:foo`                        |
| {% endtab %}        |                |                                                   |

{% tab title="Available Sorts" %}

| Name          | Example                                                            |
| ------------- | ------------------------------------------------------------------ |
| **createdAt** | <p><code>sort=createdAt</code><br><code>sort=-createdAt</code></p> |
| **typeCode**  | <p><code>sort=typeCode</code><br><code>sort=-typeCode</code></p>   |
| **title**     | <p><code>sort=title</code><br><code>sort=-title</code></p>         |
| {% endtab %}  |                                                                    |

{% tab title="Paginate Options" %}

| Name         | Description                                             | Example          |
| ------------ | ------------------------------------------------------- | ---------------- |
| **size**     | Defines the number of results per page. Default = 30.   | `page[size]=2`   |
| **number**   | Defines the number of the page to retrieve. Default = 1 | `page[number]=2` |
| {% endtab %} |                                                         |                  |

{% tab title="Response" %}

```javascript
{
  "data": [
    {
      "configurations": { "values": ["XL", "M"] },
      "createdAt": "2020-08-10T10:00:00.000Z",
      "customData": {},
      "description": "Clothes size by nomenclature",
      "id": "fc78d28f-a8dd-49de-a22f-722fe3bd26c2",
      "jsonSchema": {},
      "metadata": {},
      "productTypeCode": "physical",
      "required": true,
      "title": "Clothes size",
      "typeCode": "single",
      "updatedAt": "2020-08-10T10:00:00.000Z"
    },
    {
      "configurations": { "values": ["39-40", "40-41"] },
      "createdAt": "2020-08-10T11:00:00.000Z",
      "customData": {},
      "description": "Boot size by number",
      "id": "ec78d28f-a8dd-49de-a22f-722fe3bd26c5",
      "jsonSchema": {},
      "metadata": {},
      "productTypeCode": "physical",
      "required": false,
      "title": "Boot size",
      "typeCode": "multiple",
      "updatedAt": "2020-08-10T11:00:00.000Z"
    }
  ],
  "total": 2
}
```

{% endtab %}
{% endtabs %}

### `GET /questions/:id`

> `GET` <https://api.slyk.i&#x6F;**/questions/:id**‌>

Gets the question details of the given `id`.

{% tabs %}
{% tab title="Response" %}

```javascript
{
  "data": {
      "configurations": { "values": ["39-40", "40-41"] },
      "createdAt": "2020-08-10T10:00:00.000Z",
      "customData": {},
      "description": "Boot size by number",
      "id": "fc78d28f-a8dd-49de-a22f-722fe3bd26c2",
      "metadata": {},
      "productTypeCode": "physical",
      "required": true,
      "title": "Boot size",
      "typeCode": "single",
      "updatedAt": "2020-08-10T10:00:00.000Z"
    }
}
```

{% endtab %}
{% endtabs %}

### `GET /question-types` <a href="#get-invites" id="get-invites"></a>

> `GET` <https://api.slyk.i&#x6F;**/question-types>\*\*

Returns a paginated list of `question types`.

{% tabs %}
{% tab title="Available Filters" %}

| Name         |      Type      | Example            |
| ------------ | :------------: | ------------------ |
| **code**     | `=` `in` `nin` | `filter[code]=foo` |
| {% endtab %} |                |                    |

{% tab title="Available Sorts" %}

| Name          | Example                                                            |
| ------------- | ------------------------------------------------------------------ |
| **code**      | <p><code>sort=code</code><br><code>sort=-code</code></p>           |
| **createdAt** | <p><code>sort=createdAt</code><br><code>sort=-createdAt</code></p> |
| {% endtab %}  |                                                                    |

{% tab title="Paginate Options" %}

| Name         | Description                                             | Example          |
| ------------ | ------------------------------------------------------- | ---------------- |
| **size**     | Defines the number of results per page. Default = 30.   | `page[size]=2`   |
| **number**   | Defines the number of the page to retrieve. Default = 1 | `page[number]=2` |
| {% endtab %} |                                                         |                  |

{% tab title="Response" %}

```javascript
{
  "data": [
    {
      "code": "date",
      "dashboardJsonSchema": {},
      "jsonSchemaTemplate": {
        "format": "date",
        "type": "string"
      }
    },
    {
      "code": "single",
      "dashboardJsonSchema": {
        "properties": {
          "values": {
            "items": { "type": "string" },
            "minItems": 1,
            "type": "array"
          }
        },
        "required": ["values"]
      },
      "jsonSchemaTemplate": {
        "enum": ["{{values}}"],
        "type": "string"
      }
    }
  ],
  "total": 2
}
```

{% endtab %}
{% endtabs %}

### `PATCH /questions/:id`

> `PATCH` <https://api.slyk.i&#x6F;**/questions/:id>\*\*

Patches the `questions` details of the given `id`.

{% tabs %}
{% tab title="Request Parameters" %}

| Field               |    Type   | Required | Description                                                                        |
| ------------------- | :-------: | :------: | ---------------------------------------------------------------------------------- |
| **configurations**  |  `object` |  `false` | Question configurations that contains possible values.                             |
| **customData**      |  `object` |  `false` | Can store any additional information about the question.                           |
| **description**     |  `string` |  `false` | Question description.                                                              |
| **productTypeCode** |  `string` |  `false` | Associated product type code.                                                      |
| **required**        | `boolean` |  `false` | Require indicator.                                                                 |
| **title**           |  `string` |  `false` | Question title.                                                                    |
| **typeCode**        |  `string` |  `false` | Associated question type code. One of `date`, `multiple`, `single`, `text`, `time` |
| {% endtab %}        |           |          |                                                                                    |

{% tab title="Request" %}

```javascript
{
  "configurations": {
    "values": [
      "39-40",
      "40-41",
      "41-42"
    ]
  },
  "customData": {},
  "description": "Boot size by number",
  "productTypeCode": "physical",
  "required": true,
  "title": "Boot size",
  "typeCode": "single"
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "configurations": {
      "values": [
        "39-40",
        "40-41",
        "41-42"
      ]
    },
    "createdAt": "2020-08-10T10:00:00.000Z",
    "customData": {},
    "description": "Boot size by number",
    "id": "fc78d28f-a8dd-49de-a22f-722fe3bd26c2",
    "metadata": {},
    "productTypeCode": "physical",
    "required": true,
    "title": "Boot size",
    "typeCode": "single",
    "updatedAt": "2020-08-10T10:00:00.000Z"
  }
}
```

{% endtab %}
{% endtabs %}

### `POST /questions`

> `POST` <https://api.slyk.i&#x6F;**/questions>\*\*

Creates a new `question`.

{% tabs %}
{% tab title="Request Parameters" %}

<table data-header-hidden><thead><tr><th>Field</th><th width="150" align="center">Type</th><th align="center">Required</th><th>Description</th></tr></thead><tbody><tr><td>Field</td><td align="center">Type</td><td align="center">Required</td><td>Description</td></tr><tr><td><strong>configurations</strong></td><td align="center"><code>object</code></td><td align="center"><code>false</code></td><td>Question configurations that contains possible values.</td></tr><tr><td><strong>customData</strong></td><td align="center"><code>object</code></td><td align="center"><code>false</code></td><td>Can store any additional information about the question.</td></tr><tr><td><strong>description</strong></td><td align="center"><code>string</code></td><td align="center"><code>false</code></td><td>Question description.</td></tr><tr><td><strong>productTypeCode</strong></td><td align="center"><code>string</code></td><td align="center"><code>true</code></td><td>Associated product type code.</td></tr><tr><td><strong>required</strong></td><td align="center"><code>boolean</code></td><td align="center"><code>false</code></td><td>Require indicator.</td></tr><tr><td><strong>title</strong></td><td align="center"><code>string</code></td><td align="center"><code>true</code></td><td>Question title.</td></tr><tr><td><strong>typeCode</strong></td><td align="center"><code>string</code></td><td align="center"><code>true</code></td><td>Associated question type code. One of <code>date</code>, <code>multiple</code>, <code>single</code>, <code>text</code>, <code>time</code></td></tr></tbody></table>
{% endtab %}

{% tab title="Request" %}

```javascript
{
  "configurations": {
    "values": [
      "39-40",
      "40-41",
      "41-42"
    ]
  },
  "customData": {},
  "description": "Boot size by number",
  "productTypeCode": "digital",
  "required": true,
  "title": "Boot size",
  "typeCode": "single"
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "configurations": {
      "values": [
        "39-40",
        "40-41",
        "41-42"
      ]
    },
    "createdAt": "2020-08-10T10:00:00.000Z",
    "customData": {},
    "description": "Boot size by number",
    "id": "fc78d28f-a8dd-49de-a22f-722fe3bd26c2",
    "metadata": {},
    "productTypeCode": "physical",
    "required": true,
    "title": "Boot size",
    "typeCode": "single",
    "updatedAt": "2020-08-10T10:00:00.000Z"
  }
}
```

{% endtab %}
{% endtabs %}
