# User Support & Conversation

### `GET` Contact Us Subjects

Lists the selectable subjects for the Contact Us form. Each subject is displayed with its ID, content, and order\_needed information.

**Path:** `/users/contact-us-subjects/`

**Authentication Required:** No

**Headers:**

```
Accept-Language: <iso_language_code>
```

**Example Request**

```py
import requests

headers = {
  'Accept-Language': '<iso_language_code>'
}

url = "https://{commerce_url}/users/contact-us-subjects/"

response = requests.get(url)
print(response.json())
```

**Example Response (200 OK)**

```json
[
    {
        "id": 1,
        "text": "Refund",
        "is_order_needed": true
    },
    {
        "id": 2,
        "text": "Technical Support",
        "is_order_needed": false
    }
]
```

**Response Parameters**

| Property          | Data Type | Description                                 |
| ----------------- | --------- | ------------------------------------------- |
| id                | Integer   | The unique ID of the contact subject.       |
| text              | String    | The localized text or name of the subject.  |
| is\_order\_needed | Boolean   | Indicates if order information is required. |

### `POST` Contact Us

This endpoint allows users to send messages to the relevant shop, expressing their wishes, suggestions, or complaints. The message can include optional details like an order reference or an attachment.

**Path:** `/users/contact-us/`

**Authentication Required:** No

**Headers:**

```
Content-Type: application/json
Accept-Language: <iso_language_code>
x-csrftoken: <token>
```

**Body Parameters**

| Property   | Data Type | Required | Description                                                                                                                                                                                                                                                     |
| ---------- | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| subject    | int       | True     | The ID of the subject (as obtained from the `GET /users/contact-us-subjects/` endpoint).                                                                                                                                                                        |
| full\_name | string    | True     | The full name of the user (maximum 70 characters).                                                                                                                                                                                                              |
| email      | string    | True     | The user's email address.                                                                                                                                                                                                                                       |
| phone      | string    | False    | The user's phone number (maximum 70 characters).                                                                                                                                                                                                                |
| message    | string    | True     | The content of the user's message or reason for contact.                                                                                                                                                                                                        |
| file       | file      | False    | An optional file attachment. Supported formats: .pdf, .jpg, .jpeg, .png, .xls, .xlsx, .doc, .docx.                                                                                                                                                              |
| order      | int       | False    | The order ID associated with the user's inquiry (if applicable).                                                                                                                                                                                                |
| operation  | string    | False    | Specifies the key used to determine the recipient email address in the `CONTACT_US_EMAIL_TO` dynamic setting. The `operation` field can take values such as `"franchise"` or `"contact_us"`, and the corresponding email address will be used as the recipient. |

**Request Body**

```json
{
    "message": "<User Message Content>",
    "email": "info@akinon.com",
    "full_name": "Joe Doe",
    "subject": "<SUBJECT_ID>"
}
```

**Example Request**

```py
import requests
import json

url = "https://{commerce_url}/users/contact-us/"

payload = json.dumps({
    "message": "test",
    "email": "test@test.com",
    "full_name": "testname",
    "subject": 1
})

headers = {
   'Content-Type': 'application/json'
   'Accept-Language': '<iso_language_code>'
   'x-csrftoken': '<token>'
}

response = requests.post(url, headers=headers, data=payload)

print(response.text)
```

**Example Response (200 OK)**

No content is returned for a successful submission.

### `GET` List User Conversations

This endpoint retrieves a paginated list of conversations associated with the authenticated user. Conversations include details about the type, associated item, user, and the relevant datasource.

**Path:** `/users/conversations/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/conversations/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

```json
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 3,
            "conversation_type": "message",
            "item_object": {
                "pk": 3855,
                "sku": "4455002",
                "product_images": [
                    {
                        "pk": 26,
                        "product": 9,
                        "image": "products/2021/05/21/134/d192331113a.jpg",
                        "order": 0,
                        "height": 80,
                        "width": 101
                    }
                ],
                "name": "Oversized Sweatshirt"
            },
            "is_answered": false,
            "subject": "subject-1",
            "message_set": [],
            "user": {
                "id": 853,
                "first_name": "John",
                "last_name": "Doe",
                "gender": null,
                "email": "testuser1@akinon.com",
                "phone": null
            },
            "last_message_date": null,
            "is_public": false,
            "item_content": "product",
            "datasource": {
                "phone_number": null,
                "name": "seller-1",
                "title": "Test Seller",
                "supplier_code": "Code123",
                "mersis_number": null,
                "fax_number": null,
                "email": null,
                "is_active": true,
                "trade_association": null,
                "price_list": null,
                "address": null,
                "stock_list": null,
                "pk": 57,
                "slug": null,
                "kep_address": null,
                "extras": {}
            }
        }
    ]
}
```

### `GET` Retrieve User Conversation

This endpoint retrieves detailed information about a specific conversation associated with the authenticated user. The conversation details include the type of conversation, the related item (e.g., product or order), user information, and relevant datasource details.

For more details about this method, please refer to the [Conversation](https://docs.akinon.com/technical-guides/commerce/conversation-and-messages#listing-and-filtering-conversations) documentation.

**Path:** `/users/conversations/<id>/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
```

**Example Request**

```py
import requests

url = "https://{commerce_url}/users/conversations/<id>/"

headers = {
    'Accept-Language': '<iso_language_code>',
    'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)
print(response.json())
```

**Example Response (200 OK)**

```json
{
	"id": 3,
	"conversation_type": "message",
	"item_object": {
    	"pk": 3855,
    	"sku": "4455002",
    	"product_images": [
        	{
            	"pk": 26,
            	"product": 9,
            	"image": "products/2021/05/21/134/d192331113a.jpg",
            	"order": 0,
            	"height": 80,
            	"width": 101
        	}
    	],
    	"name": "Oversized Sweatshirt"
	},
	"is_answered": false,
	"subject": "subject-1",
	"message_set": [],
	"user": {
    	"id": 853,
    	"first_name": "John",
    	"last_name": "Doe",
    	"gender": null,
    	"email": "testuser1@akinon.com",
    	"phone": null
	},
	"last_message_date": null,
	"is_public": false,
	"item_content": "product",
	"datasource": {
    	"phone_number": null,
    	"name": "seller-1",
    	"title": "Test Seller",
    	"supplier_code": "Code123",
    	"mersis_number": null,
    	"fax_number": null,
    	"email": null,
    	"is_active": true,
    	"trade_association": null,
    	"price_list": null,
    	"address": null,
    	"stock_list": null,
    	"pk": 57,
    	"slug": null,
    	"kep_address": null,
    	"extras": {}
	}
}
```

### `POST` Create User Conversation

This endpoint allows the creation of a new conversation for the authenticated user. The request body must include essential details such as the conversation type, associated item, user ID, and relevant datasource.

For more details about this method, please refer to the [Conversation](https://docs.akinon.com/technical-guides/commerce/conversation-and-messages#listing-and-filtering-conversations) documentation.

**Path:** `/users/conversations/`

**Authentication Required:** Yes

**Headers:**

```
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>
Content-Type: 'application/json'
```

**Body Parameters**

| Property           | Data Type | Required | Description                                                                                                                 |
| ------------------ | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| conversation\_type | Enum      | True     | Values: “message”, “question”, “review”                                                                                     |
| user               | Integer   | True     | The user ID associated with the conversation.                                                                               |
| user\_type         | Enum      | True     | The type of the user associated with the conversation. Values: “guest”, “registered”                                        |
| message\_content   | String    | True     | The content of the conversation message.                                                                                    |
| datasource         | Integer   | True     | The vendor ID associated with the conversation.                                                                             |
| content\_type      | Enum      | True     | The model associated with the message in the conversation. Values: “user”, “datasource”. The 'user' value must be provided. |
| is\_public         | Boolean   | False    | Determines the visibility of the conversation for everyone                                                                  |
| content\_id        | Integer   | True     | The user ID value must be provided.                                                                                         |
| subject            | String    | False    | Defines the conversation subject.                                                                                           |
| conversation       | Integer   | False    | If a message is to be sent to an existing conversation, the relevant conversation ID must be provided.                      |
| item\_content      | Enum      | False    | If the conversation is related to a product or order item, it must be provided. Values: “product”, “orderitem”              |
| item\_id           | Integer   | False    | The ID of the selected product or order item in the item\_content.                                                          |

**Request Body**

```json
{
	"conversation_type": "message",
	"user": 76,
	"user_type": "registered",
	"message_content": "hello first message",
	"datasource": 135,
	"content_type": "user",
	"is_public": false,
	"content_id": 76,
	"subject": "subject",
	"conversation": 1,
	"item_content": "product",
	"item_id": 1
}
```

**Example Request**

```py
import requests
import json

url = "https://{commerce_url}/users/conversations/"

payload = json.dumps({
  "conversation_type": "message",
  "user": 76,
  "user_type": "registered",
  "message_content": "hello first message",
  "datasource": 135,
  "content_type": "user",
  "is_public": False,
  "content_id": 76,
  "subject": "subject",
  "conversation": 1,
  "item_content": "product",
  "item_id": 1
})
headers = {
  'Accept-Language': ' <iso_language_code>',
  'Cookie': ' <cookie-name>=<session_id>',
  'x-csrftoken': ' <token>',
  'Content-Type': 'application/json'
}

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

print(response.text)
```

**Example Response (201 Created)**

```json
{
	"id": 35,
	"datasource": 1,
	"user": 76,
	"subject": "subject",
	"item_content": null,
	"is_public": false,
	"item_id": null,
	"conversation_type": "message",
	"message_content": "hello first message 2",
	"user_type": "registered",
	"content_id": 76,
	"content_type": "user"
}
```

**Example Response (400 Bad Request)**

```json
[
	"Conversation already exists"
]
```
