Skip to main content

Messages

This page provides a detailed explanation of how to use the Message & Comment & Question features developed alongside Seller Center. It includes detailed instructions and sample request and response examples for Omnitron, Commerce, and PZ products.

OMNITRON Requests

The requests made through Omnitron and Commerce are sent to two different endpoints. When making a request through Omnitron, the api/v1/conversations/ and api/v1/messages/ endpoints are used.

OMNITRON List Conversations

The GET request sent through Omnitron lists all conversation objects. Here, users can use filters such as user_id, product, order_item, datasource_id, and product_base_code to obtain more specific results. These filters enable narrowing down the search and retrieving more targeted information based on individual preferences.

Request

curl --location 'https://1313ad93ee9f45229abc37216d3ab7e9.lb.akinoncloud.com/api/v1/remote/2/conversations/' --header 'Authorization: Token dd7ba7a3e9dd8767392cc5d05eda2c04bdc3b7c5'

Response

{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 9,
"user": 1,
"datasource": {
"pk": 1,
"name": "Burak's Dükkan",
"slug": "buraks-dukkan",
...
},
"item_object": null,
"message_set": [
{
"id": 1,
"message_content": "hello this is first message",
"user_type": "registered",
"content_object": {
"id": 1,
...
}
},
],
"conversation_type": "message",
"last_message_date": null
},
]
}

OMNITRON Create Conversation

Omnitron üzerinden bir conversation objesi oluşturabilmek için aşağıdaki gibi bir request göndermek gerekir.

Request

curl --location 'https://1313ad93ee9f45229abc37216d3ab7e9.lb.akinoncloud.com/api/v1/remote/2/conversations/' \ --header 'Authorization: Token dd7ba7a3e9dd8767392cc5d05eda2c04bdc3b7c5' \ --header 'Content-Type: application/json' \ --data '{ "conversation_type": "message", "user_type": "registered", "message_content": "hello this is first message", "datasource": "1", "conversation": "10", "content_type": "user", "content_id": "1", "user": "1" }'

Response

{
"datasource": 1,
"user": 1,
"conversation_type": "message",
"message_content": "hello this is first message",
"user_type": "registered",
"content_id": 1
}

OMNITRON Add New Message

Both sellers through Omnitron and customers through Commerce can send requests to this endpoint. However, as there is no user associated specifically with sellers, we expect the user making the request to match or be an is_staff with the user in the conversation object. In the case of requests coming through Omnitron, the user is expected to be is_staff and be able to send messages for the datasource.

Request

curl --location 'https://1313ad93ee9f45229abc37216d3ab7e9.lb.akinoncloud.com/api/v1/remote/2/messages/' \ --header 'Authorization: Token dd7ba7a3e9dd8767392cc5d05eda2c04bdc3b7c5' \ --header 'Content-Type: application/json' \ --data '{ "message_content": "message send.", "conversation": "9", "user_type": "registered", "content_id": "1", "content_type": "user" }'

Response

{
"conversation": 9,
"message_content": "message send.",
"user_type": "registered",
"content_id": 1,
"content_type": "user"
}

COMMERCE Requests

COMMERCE List Conversations

Request

curl --location 'https://9ee32fabf0254ca69a4caa25e394b2e8.lb.akinoncloud.com/users/conversations/' \ --header 'Authorization: Token eb51fcbbfb20a54b780377aceb2a14fc30e95af2' \ --header 'Cookie: csrftoken=E19VYMYuUoBX3SDjyw8MzxdeSnMCfcpK00AAT2tKSLr7YfnvDiuO4BSMjSlFG6dp; osessionid=61r8smsyf25bfsl5a8q5d6ujcxj3makr'

Response

{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 10,
"user": 2,
"datasource": {
"pk": 1,
"name": "Burak's Dükkan",
"slug": "buraks-dukkan",
...
},
"item_object": null,
"message_set": [
{
"id": 4,
"message_content": "hello this is first message",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
}
],
"conversation_type": "message",
"last_message_date": null
},
{
"id": 12,
"user": 2,
"datasource": {
"pk": 1,
"name": "Burak's Dükkan",
"slug": "buraks-dukkan",
...
},
"item_object": null,
"message_set": [
{
"id": 10,
"message_content": "this is first review from commerce",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
},
{
"id": 17,
"message_content": "hello this is first message",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
},
],
"conversation_type": "review",
"last_message_date": null
}
]
}

Commerce Create Conversation

Request

curl --location 'https://9ee32fabf0254ca69a4caa25e394b2e8.lb.akinoncloud.com/users/conversations/' \ --header 'Authorization: Token eb51fcbbfb20a54b780377aceb2a14fc30e95af2' \ --header 'Content-Type: application/json' \ --header 'Cookie: csrftoken=E19VYMYuUoBX3SDjyw8MzxdeSnMCfcpK00AAT2tKSLr7YfnvDiuO4BSMjSlFG6dp; osessionid=61r8smsyf25bfsl5a8q5d6ujcxj3makr' \ --data '{ "conversation_type": "message", "user_type": "registered", "message_content": "hello this is first message", "datasource": "1", "conversation": "12", "content_type": "user", "content_id": "2", "user": "2" }'

Response

{
"datasource": 1,
"user": 2,
"conversation_type": "message",
"message_content": "hello this is first message",
"user_type": "registered",
"content_id": 2
}

Commerce Add New Message

Request

curl --location 'https://9ee32fabf0254ca69a4caa25e394b2e8.lb.akinoncloud.com/api/v1/messages/' \ --header 'Authorization: Token eb51fcbbfb20a54b780377aceb2a14fc30e95af2' \ --header 'Content-Type: application/json' \ --header 'Cookie: csrftoken=E19VYMYuUoBX3SDjyw8MzxdeSnMCfcpK00AAT2tKSLr7YfnvDiuO4BSMjSlFG6dp; osessionid=61r8smsyf25bfsl5a8q5d6ujcxj3makr' \ --data '{ "message_content": "message send.", "conversation": "12", "user_type": "registered", "content_id": "2", "content_type": "user" }'

Response

{
"conversation": 12,
"message_content": "message send.",
"user_type": "registered",
"content_id": 2,
"content_type": "user"
}

Project Zero Requests

With Project Zero, requests are transferred to the Commerce product, and the responses returned from there are used. The following examples demonstrate how the messaging feature can be used with the Project Zero product.

Request

curl --location 'https://09627d9cd0084932a4d5b156434afca0.lb.akinoncloud.com/users/conversations/' \ --header 'Authorization: Token eb51fcbbfb20a54b780377aceb2a14fc30e95af2' \ --header 'Cookie: csrftoken=nHG4iaHFpqXhMiIY0wUXAQupLFeKdCQrqE326dImB2QAV06Ua7E6kZrj29tYdLvM; osessionid=ve00sgs86u7xyydyxcorgvx4slrpok5l; sessionid=9hvt8kjd1pw4kktspyqaye3zp44bjzlu'

Response

{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 10,
"user": 2,
"datasource": {
"pk": 1,
"name": "Burak's Dükkan",
...
},
"item_object": null,
"message_set": [
{
"id": 6,
"message_content": "message send.",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
},
],
"conversation_type": "message",
"last_message_date": null
},
{
"id": 12,
"user": 2,
"datasource": {
"pk": 1,
"name": "Burak's Dükkan",
"slug": "buraks-dukkan",
...
},
"item_object": null,
"message_set": [
{
"id": 10,
"message_content": "this is first review from commerce",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
},
{
"id": 17,
"message_content": "hello this is second review",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
},
],
"conversation_type": "review",
"last_message_date": null
}
]
}

PZ Create New Conversation

Request

curl --location 'https://09627d9cd0084932a4d5b156434afca0.lb.akinoncloud.com/users/conversations/' \ --header 'Authorization: Token eb51fcbbfb20a54b780377aceb2a14fc30e95af2' \ --header 'Content-Type: application/json' \ --header 'Cookie: csrftoken=nHG4iaHFpqXhMiIY0wUXAQupLFeKdCQrqE326dImB2QAV06Ua7E6kZrj29tYdLvM; osessionid=ve00sgs86u7xyydyxcorgvx4slrpok5l; sessionid=9hvt8kjd1pw4kktspyqaye3zp44bjzlu' \ --data '{ "conversation_type": "message", "user_type": "registered", "message_content": "hello this is first message", "datasource": "1", "conversation": "12", "content_type": "user", "content_id": "2", "user": "2" }'

Response

{
"datasource": 1,
"user": 2,
"conversation_type": "message",
"message_content": "hello this is first message",
"user_type": "registered",
"content_id": 2
}

PZ Add New Message

Request

curl --location 'https://09627d9cd0084932a4d5b156434afca0.lb.akinoncloud.com/users/messages/' \ --header 'Authorization: Token eb51fcbbfb20a54b780377aceb2a14fc30e95af2' \ --header 'Content-Type: application/json' \ --header 'Cookie: csrftoken=nHG4iaHFpqXhMiIY0wUXAQupLFeKdCQrqE326dImB2QAV06Ua7E6kZrj29tYdLvM; osessionid=ve00sgs86u7xyydyxcorgvx4slrpok5l; sessionid=9hvt8kjd1pw4kktspyqaye3zp44bjzlu' \ --data '{ "message_content": "message send.", "conversation": "12", "user_type": "registered", "content_id": "2", "content_type": "user" }'

Response

{
"conversation": 12,
"message_content": "message send.",
"user_type": "registered",
"content_id": 2,
"content_type": "user"
}

Public Questions & Reviews

Endpoints have been created for the products sold by sellers, enabling the public publication of content such as placed orders, asked questions, and comments for sellers, products, and orders. By making requests to these endpoints, users can access comments and questions. Additionally, while filtering conversations, you can use specific filters such as user_id, datasource_id, product, order_item, and product_base_code to obtain more specific results.

Public Questions

Request

curl --location 'https://09627d9cd0084932a4d5b156434afca0.lb.akinoncloud.com/public-questions/' \ --header 'Cookie: csrftoken=nHG4iaHFpqXhMiIY0wUXAQupLFeKdCQrqE326dImB2QAV06Ua7E6kZrj29tYdLvM; osessionid=ve00sgs86u7xyydyxcorgvx4slrpok5l; sessionid=9hvt8kjd1pw4kktspyqaye3zp44bjzlu'

Response

{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 11,
"user": 1,
"datasource": {
"pk": 1,
"name": "Burak's Dükkan",
"slug": "buraks-dukkan",
...
},
"item_object": null,
"message_set": [
{
"id": 7,
"message_content": "hello this is first question",
"user_type": "registered",
"content_object": {
"id": 1,
...
}
}
],
"conversation_type": "question",
"last_message_date": null
}
]
}

Public Reviews

Request

curl --location 'https://09627d9cd0084932a4d5b156434afca0.lb.akinoncloud.com/public-reviews/' \ --header 'Cookie: csrftoken=nHG4iaHFpqXhMiIY0wUXAQupLFeKdCQrqE326dImB2QAV06Ua7E6kZrj29tYdLvM; osessionid=ve00sgs86u7xyydyxcorgvx4slrpok5l; sessionid=9hvt8kjd1pw4kktspyqaye3zp44bjzlu'

Response

{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 12,
"user": 2,
"datasource": {
"pk": 1,
"name": "Burak's Dükkan",
"slug": "buraks-dukkan",
...
},
"item_object": null,
"message_set": [
{
"id": 10,
"message_content": "this is first review from commerce",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
},
{
"id": 17,
"message_content": "this is second review",
"user_type": "registered",
"content_object": {
"id": 2,
...
}
},
],
"conversation_type": "review",
"last_message_date": null
}
]
}