Chore: Document Conversation APIs in swagger (#552)

* Added the documentation for the conversation APIs - 8 endpoints
* Added descriptions for the existing endpoints
* Added new resource models and updated some parts of the contact API
This commit is contained in:
Sony Mathew
2020-02-24 00:51:31 +05:30
committed by GitHub
parent c7a4550477
commit fc1fa579e9
25 changed files with 909 additions and 40 deletions

View File

@@ -21,8 +21,8 @@
"tags": [
"Contact"
],
"description": "Listing all contacts with pagination",
"summary": "List contacts",
"description": "Listing all the contacts with pagination",
"summary": "List Contacts",
"parameters": [
{
"name": "query_hash",
@@ -49,7 +49,7 @@
"tags": [
"Contact"
],
"description": "Create a contact",
"description": "Create New Contact",
"parameters": [
{
"name": "data",
@@ -87,7 +87,7 @@
"name": "id",
"in": "path",
"type": "number",
"description": "ID of contact",
"description": "id of the contact",
"required": true
}
],
@@ -116,7 +116,7 @@
"name": "id",
"in": "path",
"type": "number",
"description": "ID of the contact",
"description": "id of the contact",
"required": true
},
{
@@ -155,7 +155,7 @@
"name": "id",
"in": "path",
"type": "number",
"description": "ID of contact",
"description": "id of the contact",
"required": true
}
],
@@ -174,6 +174,300 @@
}
}
}
},
"/conversations": {
"get": {
"tags": [
"Conversation"
],
"description": "List all the conversations with pagination",
"summary": "Conversations List",
"parameters": [
{
"name": "query_hash",
"in": "query",
"type": "string"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/conversation_list"
}
},
"400": {
"description": "Bad Request Error",
"schema": {
"$ref": "#/definitions/bad_request_error"
}
}
}
}
},
"/conversations/{id}": {
"get": {
"tags": [
"Conversation"
],
"summary": "Conversation Details",
"description": "Get all details regarding a conversation with all messages in the conversation",
"parameters": [
{
"name": "id",
"in": "path",
"type": "number",
"description": "ID of Conversation",
"required": true
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/conversation_show"
}
},
"404": {
"description": "Conversation not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/conversations/{id}/toggle_status": {
"post": {
"tags": [
"Conversation"
],
"summary": "Toggle Status",
"description": "Toggles the status of the conversation between open and resolved",
"parameters": [
{
"name": "id",
"in": "path",
"type": "number",
"description": "id of the conversation",
"required": true
}
],
"responses": {
"204": {
"description": "Success",
"schema": {
"$ref": "#/definitions/conversation_status_toggle"
}
},
"404": {
"description": "Conversation not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/conversations/{id}/update_last_seen": {
"post": {
"tags": [
"Conversation"
],
"summary": "Update Last Seen",
"description": "Updates the last seen of the conversation so that conversations will have the bubbles in the agents screen",
"parameters": [
{
"name": "id",
"in": "path",
"type": "number",
"description": "id of the conversation",
"required": true
}
],
"responses": {
"200": {
"description": "Success"
},
"404": {
"description": "Contact not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/conversations/{id}/labels": {
"get": {
"tags": [
"Conversation"
],
"summary": "List Labels",
"description": "Lists all the labels of a conversation",
"parameters": [
{
"name": "id",
"in": "path",
"type": "number",
"description": "id of the conversation",
"required": true
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/conversation_labels"
}
},
"404": {
"description": "Conversation not found"
},
"403": {
"description": "Access denied"
}
}
},
"post": {
"tags": [
"Conversation"
],
"summary": "Add Label",
"description": "Creates a new label and associates it with the conversation",
"parameters": [
{
"name": "id",
"in": "path",
"type": "number",
"description": "id of the conversation",
"required": true
},
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"properties": {
"labels": {
"type": "array",
"description": "array of labels",
"properties": {
"type": "string"
}
}
}
}
}
],
"responses": {
"204": {
"description": "Success",
"schema": {
"$ref": "#/definitions/conversation_labels"
}
},
"404": {
"description": "Conversation not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/conversations/{id}/assignments": {
"post": {
"tags": [
"Conversation"
],
"summary": "Assign Conversation",
"description": "Assign a conversation to an agent",
"parameters": [
{
"name": "id",
"in": "path",
"type": "number",
"description": "id of the conversation",
"required": true
},
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"properties": {
"assignee_id": {
"type": "number"
}
}
}
}
],
"responses": {
"204": {
"description": "Success",
"schema": {
"$ref": "#/definitions/user"
}
},
"404": {
"description": "Conversation not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/conversations/{id}/messages": {
"post": {
"tags": [
"Conversation"
],
"summary": "Create New Message",
"description": "All the agent replies are created as new messages through this endpoint",
"parameters": [
{
"name": "id",
"in": "path",
"type": "number",
"description": "id of the conversation",
"required": true
},
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/conversation_message_create"
}
}
],
"responses": {
"204": {
"description": "Success",
"schema": {
"allOf": [
{
"$ref": "#/definitions/generic_id"
},
{
"$ref": "#/definitions/message"
}
]
}
},
"404": {
"description": "Conversation not found"
},
"403": {
"description": "Access denied"
}
}
}
}
},
"definitions": {
@@ -206,6 +500,14 @@
}
}
},
"generic_id": {
"type": "object",
"properties": {
"id": {
"type": "number"
}
}
},
"contact": {
"type": "object",
"properties": {
@@ -229,9 +531,6 @@
"conversation": {
"type": "object",
"properties": {
"display_id": {
"type": "number"
},
"messages": {
"type": "array",
"items": {
@@ -262,6 +561,65 @@
}
}
},
"message": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"inbox_id": {
"type": "number"
},
"conversation_id": {
"type": "number"
},
"message_type": {
"type": "string"
},
"created_at": {
"type": "integer"
},
"private": {
"type": "boolean"
},
"attachment": {
"type": "object"
}
}
},
"user": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"uid": {
"type": "string"
},
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"account_id": {
"type": "number"
},
"role": {
"type": "string",
"enum": [
"agent",
"administrator"
]
},
"confirmed": {
"type": "boolean"
},
"nickname": {
"type": "string"
}
}
},
"extended_contact": {
"allOf": [
{
@@ -287,38 +645,30 @@
"contact_base": {
"allOf": [
{
"$ref": "#/definitions/contact"
"$ref": "#/definitions/generic_id"
},
{
"type": "object",
"properties": {
"id": {
"type": "number"
}
}
"$ref": "#/definitions/contact"
}
]
},
"contact_list": {
"type": "array",
"description": "array of contacts",
"items": {
"allOf": [
{
"$ref": "#/definitions/contact"
"$ref": "#/definitions/generic_id"
},
{
"type": "object",
"properties": {
"id": {
"type": "number"
}
}
"$ref": "#/definitions/contact"
}
]
}
},
"contact_conversations": {
"type": "array",
"description": "array of conversations",
"items": {
"allOf": [
{
@@ -348,15 +698,183 @@
}
},
"assignee": {
"type": "object"
"$ref": "#/definitions/user"
}
}
}
}
},
{
"type": "object",
"properties": {
"display_id": {
"type": "number"
}
}
}
]
}
},
"conversation_list": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"meta": {
"type": "object",
"properties": {
"mine_count": {
"type": "number"
},
"unassigned_count": {
"type": "number"
},
"all_count": {
"type": "number"
}
}
},
"payload": {
"type": "array",
"description": "array of conversations",
"items": {
"allOf": [
{
"$ref": "#/definitions/generic_id"
},
{
"$ref": "#/definitions/conversation"
},
{
"type": "object",
"properties": {
"meta": {
"type": "object",
"properties": {
"sender": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"name": {
"type": "string"
},
"thumbnail": {
"type": "string"
},
"channel": {
"type": "string"
}
}
},
"assignee": {
"$ref": "#/definitions/user"
}
}
}
}
}
]
}
}
}
}
}
},
"conversation_show": {
"type": "object",
"properties": {
"meta": {
"type": "object",
"properties": {
"labels": {
"type": "array",
"items": {
"type": "string"
}
},
"additional_attributes": {
"type": "object"
},
"contact_id": {
"type": "number"
}
}
},
"payload": {
"type": "array",
"description": "array of messages",
"items": {
"allOf": [
{
"$ref": "#/definitions/extended_message"
}
]
}
}
}
},
"conversation_status_toggle": {
"type": "object",
"properties": {
"meta": {
"type": "object"
},
"payload": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"current_status": {
"type": "string",
"enum": [
"open",
"resolved"
]
},
"conversation_id": {
"type": "number"
}
}
}
}
},
"conversation_labels": {
"type": "object",
"properties": {
"payload": {
"type": "array",
"description": "array of labels",
"items": {
"type": "string"
}
}
}
},
"extended_message": {
"allOf": [
{
"$ref": "#/definitions/generic_id"
},
{
"$ref": "#/definitions/message"
},
{
"type": "object",
"properties": {
"source_id": {
"type": "number"
},
"sender": {
"type": "object"
}
}
}
]
},
"contact_create": {
"type": "object",
"properties": {
@@ -381,6 +899,23 @@
"type": "string"
}
}
},
"conversation_message_create": {
"type": "object",
"properties": {
"conversation_id": {
"type": "number"
},
"message": {
"type": "string"
},
"private": {
"type": "boolean"
},
"fb_id": {
"type": "number"
}
}
}
}
}