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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 909 additions and 40 deletions

View file

@ -5,35 +5,68 @@ request_error:
$ref: ./error/request.yml
# RESOURCE
generic_id:
$ref: ./resource/extension/generic.yml
contact:
$ref: ./resource/contact.yml
conversation:
$ref: ./resource/conversation.yml
message:
$ref: ./resource/message.yml
user:
$ref: ./resource/user.yml
# RESPONSE
## contact
extended_contact:
allOf:
- $ref: '#/definitions/contact'
- $ref: ./resource/extension/contact/show.yml
contact_base:
allOf:
- $ref: '#/definitions/generic_id'
- $ref: '#/definitions/contact'
- $ref: ./resource/extension/generic.yml
contact_list:
type: array
description: 'array of contacts'
items:
allOf:
- $ref: '#/definitions/generic_id'
- $ref: '#/definitions/contact'
- $ref: ./resource/extension/generic.yml
contact_conversations:
type: array
description: 'array of conversations'
items:
allOf:
- $ref: '#/definitions/conversation'
- $ref: ./resource/extension/contact/conversation.yml
- $ref: ./resource/extension/conversation/with_display_id.yml
## conversation
conversation_list:
$ref: ./resource/extension/conversation/list.yml
conversation_show:
$ref: ./resource/extension/conversation/show.yml
conversation_status_toggle:
$ref: ./resource/extension/conversation/status_toggle.yml
conversation_labels:
$ref: ./resource/extension/conversation/labels.yml
## message
extended_message:
allOf:
- $ref: '#/definitions/generic_id'
- $ref: '#/definitions/message'
- $ref: ./resource/extension/message/with_source_sender.yml
# REQUEST
## contact
contact_create:
$ref: ./request/contact/create.yml
contact_update:
$ref: ./request/contact/update.yml
## conversation
conversation_message_create:
$ref: ./request/conversation/create_message.yml

View file

@ -0,0 +1,10 @@
type: object
properties:
conversation_id:
type: number
message:
type: string
private:
type: boolean
fb_id:
type: number

View file

@ -1,7 +1,5 @@
type: object
properties:
display_id:
type: number
messages:
type: array
items:

View file

@ -15,4 +15,4 @@ properties:
channel:
type: string
assignee:
type: object
$ref: '#/definitions/user'

View file

@ -1,5 +0,0 @@
type: object
properties:
allOf:
- $ref: '#/definitions/contact'
- $ref: ./resource/extension/contact.yaml

View file

@ -0,0 +1,7 @@
type: object
properties:
payload:
type: array
description: 'array of labels'
items:
type: string

View file

@ -0,0 +1,22 @@
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'
- $ref: '../contact/conversation.yml'

View file

@ -0,0 +1,19 @@
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'

View file

@ -0,0 +1,14 @@
type: object
properties:
meta:
type: object
payload:
type: object
properties:
success:
type: boolean
current_status:
type: string
enum: ['open', 'resolved']
conversation_id:
type: number

View file

@ -0,0 +1,4 @@
type: object
properties:
display_id:
type: number

View file

@ -0,0 +1,6 @@
type: object
properties:
source_id:
type: number
sender:
type: object

View file

@ -0,0 +1,16 @@
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

View file

@ -0,0 +1,19 @@
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

View file

@ -5,7 +5,7 @@ get:
- name: id
in: path
type: number
description: ID of contact
description: id of the contact
required: true
responses:
200:

View file

@ -5,7 +5,7 @@ get:
- name: id
in: path
type: number
description: ID of contact
description: id of the contact
required: true
responses:
200:
@ -24,7 +24,7 @@ put:
- name: id
in: path
type: number
description: ID of the contact
description: id of the contact
required: true
- name: data
in: body

View file

@ -1,7 +1,7 @@
get:
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
in: query
@ -18,7 +18,7 @@ get:
post:
tags: [Contact]
description: Create a contact
description: Create New Contact
parameters:
- name: data
in: body

View file

@ -0,0 +1,27 @@
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

View file

@ -0,0 +1,19 @@
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

View file

@ -0,0 +1,50 @@
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

View file

@ -0,0 +1,17 @@
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'

View file

@ -0,0 +1,26 @@
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

View file

@ -0,0 +1,19 @@
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

View file

@ -0,0 +1,17 @@
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

View file

@ -5,3 +5,19 @@
$ref: ./contact/crud.yml
/contacts/{id}/conversations:
$ref: ./contact/conversations.yml
# Conversations
/conversations:
$ref: ./conversation/list.yml
/conversations/{id}:
$ref: ./conversation/crud.yml
/conversations/{id}/toggle_status:
$ref: ./conversation/toggle_status.yml
/conversations/{id}/update_last_seen:
$ref: ./conversation/update_last_seen.yml
/conversations/{id}/labels:
$ref: ./conversation/labels.yml
/conversations/{id}/assignments:
$ref: ./conversation/assignments.yml
/conversations/{id}/messages:
$ref: ./conversation/messages.yml

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,7 +698,79 @@
}
},
"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"
}
}
}
@ -356,6 +778,102 @@
}
]
}
}
}
}
}
},
"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",
@ -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"
}
}
}
}
}