Chore: Update swagger API documentation (#745)

* Chore: Update swagger documentation
This commit is contained in:
Pranav Raj S 2020-04-20 11:55:06 +05:30 committed by GitHub
parent 5736f687e8
commit 06153a96ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 190 additions and 110 deletions

View file

@ -1,8 +1,11 @@
<template> <template>
<header class="header-collapsed"> <header class="header-collapsed">
<div class="header-branding">
<img v-if="avatarUrl" :src="avatarUrl" alt="avatar" />
<h2 class="title"> <h2 class="title">
{{ title }} {{ title }}
</h2> </h2>
</div>
<span class="close-button" @click="closeWindow"></span> <span class="close-button" @click="closeWindow"></span>
</header> </header>
</template> </template>
@ -13,17 +16,21 @@ import { IFrameHelper } from 'widget/helpers/utils';
export default { export default {
name: 'ChatHeader', name: 'ChatHeader',
computed: {
...mapGetters({
widgetColor: 'appConfig/getWidgetColor',
}),
},
props: { props: {
avatarUrl: {
type: String,
default: '',
},
title: { title: {
type: String, type: String,
default: '', default: '',
}, },
}, },
computed: {
...mapGetters({
widgetColor: 'appConfig/getWidgetColor',
}),
},
methods: { methods: {
closeWindow() { closeWindow() {
if (IFrameHelper.isIFrame()) { if (IFrameHelper.isIFrame()) {
@ -48,12 +55,23 @@ export default {
box-sizing: border-box; box-sizing: border-box;
color: $color-white; color: $color-white;
.header-branding {
display: flex;
align-items: center;
}
.title { .title {
font-size: $font-size-large; font-size: $font-size-large;
font-weight: $font-weight-medium; font-weight: $font-weight-medium;
color: $color-heading; color: $color-heading;
} }
img {
height: 24px;
width: 24px;
margin-right: $space-small;
}
.close-button { .close-button {
display: none; display: none;
} }

View file

@ -1,9 +1,6 @@
<template> <template>
<header class="header-expanded"> <header class="header-expanded">
<!-- <img <img v-if="avatarUrl" class="logo" :src="avatarUrl" />
class="logo"
src=""
/> -->
<span class="close close-button" @click="closeWindow"></span> <span class="close close-button" @click="closeWindow"></span>
<h2 class="title"> <h2 class="title">
{{ introHeading }} {{ introHeading }}
@ -21,14 +18,17 @@ import { IFrameHelper } from 'widget/helpers/utils';
export default { export default {
name: 'ChatHeaderExpanded', name: 'ChatHeaderExpanded',
props: { props: {
avatarUrl: {
type: String,
default: '',
},
introHeading: { introHeading: {
type: String, type: String,
default: 'Hi there ! 🙌🏼', default: '',
}, },
introBody: { introBody: {
type: String, type: String,
default: default: '',
'We make it simple to connect with us. Ask us anything, or share your feedback.',
}, },
}, },
computed: { computed: {
@ -53,14 +53,14 @@ export default {
@import '~widget/assets/scss/mixins.scss'; @import '~widget/assets/scss/mixins.scss';
.header-expanded { .header-expanded {
padding: $space-larger $space-medium $space-large; padding: $space-large $space-medium $space-large;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
.logo { .logo {
width: 64px; width: 56px;
height: 64px; height: 56px;
} }
.close { .close {
@ -74,7 +74,7 @@ export default {
font-size: $font-size-mega; font-size: $font-size-mega;
font-weight: $font-weight-normal; font-weight: $font-weight-normal;
margin-bottom: $space-slab; margin-bottom: $space-slab;
margin-top: $space-large; margin-top: $space-medium;
} }
.body { .body {

View file

@ -3,10 +3,15 @@
<div class="header-wrap"> <div class="header-wrap">
<ChatHeaderExpanded <ChatHeaderExpanded
v-if="isHeaderExpanded" v-if="isHeaderExpanded"
:intro-heading="channelConfig.welcomeTitle" :intro-heading="introHeading"
:intro-body="channelConfig.welcomeTagline" :intro-body="introBody"
:avatar-url="channelConfig.avatarUrl"
/>
<ChatHeader
v-else
:title="channelConfig.websiteName"
:avatar-url="channelConfig.avatarUrl"
/> />
<ChatHeader v-else :title="channelConfig.websiteName" />
</div> </div>
<AvailableAgents v-if="showAvailableAgents" :agents="availableAgents" /> <AvailableAgents v-if="showAvailableAgents" :agents="availableAgents" />
<ConversationWrap :grouped-messages="groupedMessages" /> <ConversationWrap :grouped-messages="groupedMessages" />
@ -55,6 +60,15 @@ export default {
showAvailableAgents() { showAvailableAgents() {
return this.availableAgents.length > 0 && this.conversationSize < 1; return this.availableAgents.length > 0 && this.conversationSize < 1;
}, },
introHeading() {
return this.channelConfig.welcomeTitle || 'Hi there ! 🙌🏼';
},
introBody() {
return (
this.channelConfig.welcomeTagline ||
'We make it simple to connect with us. Ask us anything, or share your feedback.'
);
},
}, },
}; };
</script> </script>

View file

@ -2,6 +2,7 @@ json.id @inbox.id
json.channel_id @inbox.channel_id json.channel_id @inbox.channel_id
json.name @inbox.name json.name @inbox.name
json.channel_type @inbox.channel_type json.channel_type @inbox.channel_type
json.avatar_url @inbox.try(:avatar_url)
json.website_token @inbox.channel.try(:website_token) json.website_token @inbox.channel.try(:website_token)
json.widget_color @inbox.channel.try(:widget_color) json.widget_color @inbox.channel.try(:widget_color)
json.website_url @inbox.channel.try(:website_url) json.website_url @inbox.channel.try(:website_url)
@ -9,3 +10,4 @@ json.welcome_title @inbox.channel.try(:welcome_title)
json.welcome_tagline @inbox.channel.try(:welcome_tagline) json.welcome_tagline @inbox.channel.try(:welcome_tagline)
json.agent_away_message @inbox.channel.try(:agent_away_message) json.agent_away_message @inbox.channel.try(:agent_away_message)
json.web_widget_script @inbox.channel.try(:web_widget_script) json.web_widget_script @inbox.channel.try(:web_widget_script)
json.enable_auto_assignment @inbox.enable_auto_assignment

View file

@ -2,6 +2,7 @@ json.id @inbox.id
json.channel_id @inbox.channel_id json.channel_id @inbox.channel_id
json.name @inbox.name json.name @inbox.name
json.channel_type @inbox.channel_type json.channel_type @inbox.channel_type
json.avatar_url @inbox.try(:avatar_url)
json.website_token @inbox.channel.try(:website_token) json.website_token @inbox.channel.try(:website_token)
json.widget_color @inbox.channel.try(:widget_color) json.widget_color @inbox.channel.try(:widget_color)
json.website_url @inbox.channel.try(:website_url) json.website_url @inbox.channel.try(:website_url)
@ -9,3 +10,4 @@ json.welcome_title @inbox.channel.try(:welcome_title)
json.welcome_tagline @inbox.channel.try(:welcome_tagline) json.welcome_tagline @inbox.channel.try(:welcome_tagline)
json.agent_away_message @inbox.channel.try(:agent_away_message) json.agent_away_message @inbox.channel.try(:agent_away_message)
json.web_widget_script @inbox.channel.try(:web_widget_script) json.web_widget_script @inbox.channel.try(:web_widget_script)
json.enable_auto_assignment @inbox.enable_auto_assignment

View file

@ -8,9 +8,10 @@
window.chatwootWebChannel = { window.chatwootWebChannel = {
websiteName: '<%= @web_widget.inbox.name %>', websiteName: '<%= @web_widget.inbox.name %>',
widgetColor: '<%= @web_widget.widget_color %>', widgetColor: '<%= @web_widget.widget_color %>',
websiteToken: '<%= @web_widget.welcome_title %>', websiteToken: '<%= @web_widget.website_token %>',
welcomeTitle: '<%= @web_widget.welcome_title %>', welcomeTitle: '<%= @web_widget.welcome_title %>',
welcomeTagline: '<%= @web_widget.welcome_tagline %>', welcomeTagline: '<%= @web_widget.welcome_tagline %>',
avatarUrl: '<%= @web_widget.inbox.avatar_url %>',
} }
window.chatwootPubsubToken = '<%= @contact.pubsub_token %>' window.chatwootPubsubToken = '<%= @contact.pubsub_token %>'
window.authToken = '<%= @token %>' window.authToken = '<%= @token %>'

View file

@ -3,6 +3,12 @@ properties:
id: id:
type: number type: number
description: ID of the inbox description: ID of the inbox
name:
type: string
description: The name of the inbox
website_url:
type: string
description: Website URL
channel_type: channel_type:
type: string type: string
description: The type of the inbox description: The type of the inbox
@ -21,3 +27,12 @@ properties:
web_widget_script: web_widget_script:
type: string type: string
description: Script used to load the website widget description: Script used to load the website widget
welcome_title:
type: string
description: Welcome title to be displayed on the widget
welcome_tagline:
type: string
description: Welcome tagline to be displayed on the widget
agent_away_message:
type: string
description: A message which will be sent if there is not agent available. This is not available if agentbot is connected

View file

@ -1,8 +1,8 @@
post: post:
tags: tags:
- Widget - Inbox
operationId: widgetInboxCreation operationId: inboxCreation
summary: Create a website inbox summary: Create an inbox
description: You can create more than one website inbox in each account description: You can create more than one website inbox in each account
parameters: parameters:
- name: data - name: data
@ -11,15 +11,30 @@ post:
schema: schema:
type: object type: object
properties: properties:
website: name:
type: object
properties:
website_name:
type: string type: string
description: The name of the inbox description: The name of the inbox
avatar:
type: file
description: File for avatar image
channel:
type: object
properties:
type:
type: string
enum: ['web_widget']
website_url: website_url:
type: string type: string
description: URL at which the widget will be loaded description: URL at which the widget will be loaded
welcome_title:
type: string
description: Welcome title to be displayed on the widget
welcome_tagline:
type: string
description: Welcome tagline to be displayed on the widget
agent_away_message:
type: string
description: A message which will be sent if there is not agent available. This is not available if agentbot is connected
widget_color: widget_color:
type: string type: string
description: A Hex-color string used to customize the widget description: A Hex-color string used to customize the widget

View file

@ -16,6 +16,9 @@ patch:
schema: schema:
type: object type: object
properties: properties:
name:
type: string
description: The name of the inbox
enable_auto_assignment: enable_auto_assignment:
type: boolean type: boolean
required: true required: true
@ -24,6 +27,24 @@ patch:
type: file type: file
required: false required: false
description: 'Image file for avatar' description: 'Image file for avatar'
channel:
type: object
properties:
website_url:
type: string
description: URL at which the widget will be loaded
welcome_title:
type: string
description: Welcome title to be displayed on the widget
welcome_tagline:
type: string
description: Welcome tagline to be displayed on the widget
agent_away_message:
type: string
description: A message which will be sent if there is not agent available. This is not available if agentbot is connected
widget_color:
type: string
description: A Hex-color string used to customize the widget
responses: responses:
200: 200:
description: Success description: Success

View file

@ -1,12 +1,10 @@
# Widget
/accounts/{account_id}/widget/inboxes:
$ref: ./widget/inboxes/create.yml
/accounts/{account_id}/widget/inboxes/${id}:
$ref: ./widget/inboxes/update.yml
# Inboxes # Inboxes
/accounts/{account_id}/inboxes: /accounts/{account_id}/inboxes:
$ref: ./inboxes/index.yml $ref: ./inboxes/index.yml
/accounts/{account_id}/inboxes:
$ref: ./inboxes/create.yml
/accounts/{account_id}/inboxes/{id}: /accounts/{account_id}/inboxes/{id}:
$ref: ./inboxes/update.yml $ref: ./inboxes/update.yml
/accounts/{account_id}/inboxes/{id}/set_agent_bot: /accounts/{account_id}/inboxes/{id}/set_agent_bot:

View file

@ -25,13 +25,13 @@
"application/json; charset=utf-8" "application/json; charset=utf-8"
], ],
"paths": { "paths": {
"/accounts/{account_id}/widget/inboxes": { "/accounts/{account_id}/inboxes": {
"post": { "post": {
"tags": [ "tags": [
"Widget" "Inbox"
], ],
"operationId": "widgetInboxCreation", "operationId": "inboxCreation",
"summary": "Create a website inbox", "summary": "Create an inbox",
"description": "You can create more than one website inbox in each account", "description": "You can create more than one website inbox in each account",
"parameters": [ "parameters": [
{ {
@ -41,17 +41,39 @@
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
"website": { "name": {
"type": "object",
"properties": {
"website_name": {
"type": "string", "type": "string",
"description": "The name of the inbox" "description": "The name of the inbox"
}, },
"avatar": {
"type": "file",
"description": "File for avatar image"
},
"channel": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"web_widget"
]
},
"website_url": { "website_url": {
"type": "string", "type": "string",
"description": "URL at which the widget will be loaded" "description": "URL at which the widget will be loaded"
}, },
"welcome_title": {
"type": "string",
"description": "Welcome title to be displayed on the widget"
},
"welcome_tagline": {
"type": "string",
"description": "Welcome tagline to be displayed on the widget"
},
"agent_away_message": {
"type": "string",
"description": "A message which will be sent if there is not agent available. This is not available if agentbot is connected"
},
"widget_color": { "widget_color": {
"type": "string", "type": "string",
"description": "A Hex-color string used to customize the widget" "description": "A Hex-color string used to customize the widget"
@ -78,75 +100,6 @@
} }
} }
}, },
"/accounts/{account_id}/widget/inboxes/${id}": {
"patch": {
"tags": [
"Widget"
],
"operationId": "widgetInboxUpdate",
"summary": "Update a website inbox",
"description": "Update widget color of an inbox",
"parameters": [
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"properties": {
"website": {
"type": "object",
"properties": {
"widget_color": {
"type": "string",
"description": "A Hex-color string used to customize the widget"
}
}
}
}
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/inbox"
}
},
"404": {
"description": "Inbox not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/accounts/{account_id}/inboxes": {
"get": {
"tags": [
"Inbox"
],
"operationId": "listAllInboxes",
"summary": "List all inboxes",
"description": "List all inboxes available in the current account",
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/inbox"
}
},
"404": {
"description": "Inbox not found"
},
"403": {
"description": "Access denied"
}
}
}
},
"/accounts/{account_id}/inboxes/{id}": { "/accounts/{account_id}/inboxes/{id}": {
"patch": { "patch": {
"tags": [ "tags": [
@ -170,6 +123,10 @@
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
"name": {
"type": "string",
"description": "The name of the inbox"
},
"enable_auto_assignment": { "enable_auto_assignment": {
"type": "boolean", "type": "boolean",
"required": true, "required": true,
@ -179,6 +136,31 @@
"type": "file", "type": "file",
"required": false, "required": false,
"description": "Image file for avatar" "description": "Image file for avatar"
},
"channel": {
"type": "object",
"properties": {
"website_url": {
"type": "string",
"description": "URL at which the widget will be loaded"
},
"welcome_title": {
"type": "string",
"description": "Welcome title to be displayed on the widget"
},
"welcome_tagline": {
"type": "string",
"description": "Welcome tagline to be displayed on the widget"
},
"agent_away_message": {
"type": "string",
"description": "A message which will be sent if there is not agent available. This is not available if agentbot is connected"
},
"widget_color": {
"type": "string",
"description": "A Hex-color string used to customize the widget"
}
}
} }
} }
} }
@ -1076,6 +1058,18 @@
"web_widget_script": { "web_widget_script": {
"type": "string", "type": "string",
"description": "Script used to load the website widget" "description": "Script used to load the website widget"
},
"welcome_title": {
"type": "string",
"description": "Welcome title to be displayed on the widget"
},
"welcome_tagline": {
"type": "string",
"description": "Welcome tagline to be displayed on the widget"
},
"agent_away_message": {
"type": "string",
"description": "A message which will be sent if there is not agent available. This is not available if agentbot is connected"
} }
} }
}, },