Skip to content

Commit

Permalink
chore: Add API documentation for teams (chatwoot#2221)
Browse files Browse the repository at this point in the history
Add API documentation for teams
  • Loading branch information
pranavrajs authored May 5, 2021
1 parent 6469acc commit fd0c26c
Show file tree
Hide file tree
Showing 18 changed files with 378 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ group :development do
gem 'web-console'

# used in swagger build
gem 'json_refs', git: 'https://github.com/tzmfreedom/json_refs', ref: 'e32deb0'
gem 'json_refs', git: 'https://github.com/tzmfreedom/json_refs', ref: '131b11294fd6af9c428171f38516e6222a58c874'

# When we want to squash migrations
gem 'squasher'
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ GIT

GIT
remote: https://github.com/tzmfreedom/json_refs
revision: e32deb073ce9aef39bdd63556bffd7fe7c2a803d
ref: e32deb0
revision: 131b11294fd6af9c428171f38516e6222a58c874
ref: 131b11294fd6af9c428171f38516e6222a58c874
specs:
json_refs (0.1.2)
json_refs (0.1.6)
hana

GEM
Expand Down Expand Up @@ -250,7 +250,7 @@ GEM
activerecord (>= 5.0, < 7)
ruby2ruby (~> 2.4)
ruby_parser (~> 3.10)
hana (1.3.6)
hana (1.3.7)
hashdiff (1.0.1)
hashie (4.1.0)
hkdf (0.3.0)
Expand Down
7 changes: 7 additions & 0 deletions swagger/definitions/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ contact_inboxes:
$ref: ./resource/contact_inboxes.yml
account:
$ref: ./resource/account.yml
team:
$ref: ./resource/team.yml

# RESPONSE

Expand Down Expand Up @@ -78,3 +80,8 @@ contact_update:
## conversation
conversation_message_create:
$ref: ./request/conversation/create_message.yml

# Team request Payload

team_create_update_payload:
$ref: ./request/team/create_update_payload.yml
11 changes: 11 additions & 0 deletions swagger/definitions/request/team/create_update_payload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object
properties:
name:
type: string
description: The name of the team
description:
type: string
description: The description of the team
allow_auto_assign:
type: boolean
description: If this setting is turned on, the system would automatically assign the conversation to an agent in the team while assigning the conversation to a team
20 changes: 20 additions & 0 deletions swagger/definitions/resource/team.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type: object
properties:
id:
type: number
description: The id of the team
name:
type: string
description: The name of the team
description:
type: string
description: The description about the team
allow_auto_assign:
type: boolean
description: If this setting is turned on, the system would automatically assign the conversation to an agent in the team while assigning the conversation to a team
account_id:
type: number
description: The id of the account with the team is a part of
is_member:
type: boolean
description: This field shows whether the current user is a part of the team
2 changes: 1 addition & 1 deletion swagger/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<!-- needed for adaptive design -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
<!--
ReDoc doesn't change outer page styles
-->
<style>
body {
margin: 0;
padding: 0;
font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
}
</style>
</head>
Expand Down
4 changes: 3 additions & 1 deletion swagger/index.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
swagger: 2.0
swagger: "2.0"
info:
description: This is the API documentation for Chatwoot server.
version: 1.0.0
Expand Down Expand Up @@ -40,3 +40,5 @@ paths:
$ref: ./paths/index.yml
definitions:
$ref: ./definitions/index.yml
parameters:
$ref: ./parameters/index.yml
6 changes: 6 additions & 0 deletions swagger/parameters/account_id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
in: path
name: account_id
schema:
type: integer
required: true
description: Numeric ID of the account
5 changes: 5 additions & 0 deletions swagger/parameters/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
account_id:
$ref: ./account_id.yml

team_id:
$ref: ./team_id.yml
6 changes: 6 additions & 0 deletions swagger/parameters/team_id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
in: path
name: id
schema:
type: integer
required: true
description: The id of the team to be updated
6 changes: 5 additions & 1 deletion swagger/paths/conversation/assignments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ post:
- ConversationAssignment
operationId: conversationAssignment
summary: Assign Conversation
description: Assign a conversation to an agent
description: Assign a conversation to an agent or a team
parameters:
- name: id
in: path
Expand All @@ -18,6 +18,10 @@ post:
properties:
assignee_id:
type: number
description: Id of the assignee user
team_id:
type: number
description: Id of the team. If the assignee_id is present, this param would be ignored
responses:
200:
description: Success
Expand Down
20 changes: 20 additions & 0 deletions swagger/paths/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,23 @@
# Profile
/profile:
$ref: ./profile/index.yml

# Teams
/accounts/{account_id}/teams:
parameters:
- $ref: '#/parameters/account_id'
get:
$ref: ./teams/index.yml
post:
$ref: ./teams/create.yml

/accounts/{account_id}/teams/{id}:
parameters:
- $ref: '#/parameters/account_id'
- $ref: '#/parameters/team_id'
get:
$ref: './teams/show.yml'
patch:
$ref: ./teams/update.yml
delete:
$ref: ./teams/delete.yml
19 changes: 19 additions & 0 deletions swagger/paths/teams/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
tags:
- Teams
operationId: create-a-team
summary: Create a team
description: Create a team in the account
parameters:
- $ref: '#/parameters/account_id'
- name: data
in: body
required: true
schema:
$ref: '#/definitions/team_create_update_payload'
responses:
200:
description: Success
schema:
$ref: '#/definitions/team'
401:
description: Unauthorized
12 changes: 12 additions & 0 deletions swagger/paths/teams/delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tags:
- Teams
operationId: delete-a-team,
summary: Delete a team
description: Delete a team from the account
responses:
200:
description: Success
401:
description: Unauthorized
404:
description: The team does not exist in the account
14 changes: 14 additions & 0 deletions swagger/paths/teams/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tags:
- Teams
operationId: list-all-teams
summary: List all teams
description: List all teams available in the current account
responses:
200:
description: Success
schema:
type: array
description: 'Array of teams'
$ref: '#/definitions/team'
401:
description: Unauthorized
14 changes: 14 additions & 0 deletions swagger/paths/teams/show.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tags:
- Teams
operationId: get-details-of-a-single-team
summary: Get a team details
description: Get the details of a team in the account
responses:
200:
description: Success
schema:
$ref: '#/definitions/team'
401:
description: Unauthorized
404:
description: The given team id does not exist in the account
18 changes: 18 additions & 0 deletions swagger/paths/teams/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tags:
- Teams
operationId: update-a-team
summary: Update a team
description: Update a team's attributes
parameters:
- name: data
in: body
required: true
schema:
$ref: '#/definitions/team_create_update_payload'
responses:
200:
description: Success
schema:
$ref: '#/definitions/team'
401:
description: Unauthorized
Loading

0 comments on commit fd0c26c

Please sign in to comment.