forked from techmatters/serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
339 lines (337 loc) · 10.6 KB
/
swagger.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# Copyright (C) 2021-2023 Technology Matters
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
openapi: 3.0.0
servers:
- url: /
description: Development server
info:
description: |
You can find out more about Swagger at
[http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).
# Introduction
This API is documented in **OpenAPI format**.
Here we will describe the params of our serverless functions and their return values,
as well as their required auth methods.
# Authentication
<SecurityDefinitions />
version: 1.0.0
title: Tech Matters serverless API
termsOfService: ''
contact:
name: Tech Matters
email:
url: https://techmatters.org/
x-logo:
url: 'https://techmatters.org/wp-content/uploads/2018/12/tech-matters-cropped.png'
altText: Tech Matters logo
license:
name: GPL 3.0
url: 'https://www.gnu.org/licenses/gpl-3.0.en.html'
externalDocs:
description: Explore our projects.
url: 'https://github.com/tech-matters'
tags:
- name: Functions
description: Serverless functions served from Twilio
- name: Assets
description: Static assets served from Twilio
# - name: pet_model
# x-displayName: The Pet Model
# description: |
# <SchemaDefinition schemaRef="#/components/schemas/Pet" />
- name: contact_model
x-displayName: The contact model
- name: contact_api
x-displayName: The contact api endpoints
x-tagGroups:
- name: Serverless
tags:
- Functions
- Assets
- name: HRM_models
x-displayName: HRM-DB Models
tags:
- contact_model
- name: HRM_api
x-displayName: HRM api endpints
tags:
- contact_api
# - name: Models
# tags:
# - pet_model
# - store_model
paths:
/swagger.html:
get:
tags:
- Assets
summary: API specification in OpenApi 3.0 format
description: Fetches the html file where the API is described (a.k.a the web you are at right now).
operationId: swagger
responses:
'200':
description: successful operation
/populateCounselors:
parameters:
post:
tags:
- Functions
summary: Retrieves councelors (workers) from a given workspace
description: Given a valid Twilio's workspace Sid [and a helpline optionally]
will return the list of asociated workers, or error otherwise. If helpline is provided, the workers
will be filtered to match it, if not all workers will be sent.
operationId: populateCounselors
requestBody:
description: user info to be filled
content:
application/x-www-form-urlencoded:
schema:
type: object
required:
- workspaceSID
properties:
workspaceSID:
type: string
description: SID of the target workspace.
helpline:
type: string
description: helpline to add as filter.
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: object
properties:
workerSummaries:
type: array
items:
type: object
properties:
fullName:
type: string
description: name of the councelor
sid:
type: string
description: unique Twilio's identifier for each councelor
'400':
$ref: '#/components/responses/BadRequest'
'403':
$ref: '#/components/responses/UnauthorizedError'
'500':
$ref: '#/components/responses/InternalError'
security:
- TwilioJWT:
/getTranslation:
parameters:
post:
tags:
- Functions
summary: Retrieves the translation of flex UI strings for the given language (if pressent)
description: Given a valid language code, will return the flex UI translations.
If the translation is missing, the response will contain an internal error status 500.
operationId: getTranslation
requestBody:
description: user info to be filled
content:
application/x-www-form-urlencoded:
schema:
type: object
required:
- language
properties:
language:
type: string
description: lnaguage code that represents the desired translation.
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: string
description: JSON representation of the strings object.
'400':
$ref: '#/components/responses/BadRequest'
'403':
$ref: '#/components/responses/UnauthorizedError'
'500':
$ref: '#/components/responses/InternalError'
security:
- TwilioJWT:
/getMessages:
parameters:
post:
tags:
- Functions
summary: Retrieves the translated system strings that are used to send to a chat-type contact.
description: Given a valid language code, will return the translated strings used to comunicate with the contact.
If the translation is missing, the response will contain an internal error status 500.
operationId: getMessages
requestBody:
description: user info to be filled
content:
application/x-www-form-urlencoded:
schema:
type: object
required:
- language
properties:
language:
type: string
description: lnaguage code that represents the desired translation.
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: string
description: JSON representation of the strings object.
'400':
$ref: '#/components/responses/BadRequest'
'403':
$ref: '#/components/responses/UnauthorizedError'
'500':
$ref: '#/components/responses/InternalError'
security:
- TwilioJWT:
components:
# schemas:
# ApiResponse:
# type: object
# properties:
# code:
# type: integer
# format: int32
# type:
# type: string
# message:
# type: string
# Cat:
# description: A representation of a cat
# allOf:
# - $ref: '#/components/schemas/Pet'
# - type: object
# properties:
# huntingSkill:
# type: string
# description: The measured skill for hunting
# default: lazy
# example: adventurous
# enum:
# - clueless
# - lazy
# - adventurous
# - aggressive
# required:
# - huntingSkill
# Category:
# type: object
# properties:
# id:
# description: Category ID
# allOf:
# - $ref: '#/components/schemas/Id'
# name:
# description: Category name
# type: string
# minLength: 1
# sub:
# description: Test Sub Category
# type: object
# properties:
# prop1:
# type: string
# description: Dumb Property
# xml:
# name: Category
# Dog:
# description: A representation of a dog
# allOf:
# - $ref: '#/components/schemas/Pet'
# - type: object
# properties:
# packSize:
# type: integer
# format: int32
# description: The size of the pack the dog is from
# default: 1
# minimum: 1
# required:
# - packSize
# HoneyBee:
# description: A representation of a honey bee
# allOf:
# - $ref: '#/components/schemas/Pet'
# - type: object
# properties:
# honeyPerDay:
# type: number
# description: Average amount of honey produced per day in ounces
# example: 3.14
# multipleOf: .01
# required:
# - honeyPerDay
# Id:
# type: integer
# format: int64
# readOnly: true
schemas:
ErrorString:
type: string
description: descriptive message about the error.
ErrorSchema:
type: object
properties:
message:
type: string
description: descriptive message about the error.
status:
type: string
description: status code of the original error (usefull on 5xx errors).
responses:
BadRequest:
description: Bad request or invalid parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorSchema'
UnauthorizedError:
description: Access token is missing or invalid
content:
text/plain:
schema:
$ref: '#/components/schemas/ErrorString'
InternalError:
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorSchema'
securitySchemes:
TwilioJWT: # arbitrary name for the security scheme
description: A valid [Twilio Flex Token](https://www.twilio.com/docs/flex/call-functions-from-plugins#securing-your-twilio-function)
that is included in the body, [according to this](https://github.com/twilio/twilio-flex-token-validator).
type: apiKey
in: body
name: Token
# examples:
# Order:
# value:
# quantity: 1,
# shipDate: 2018-10-19T16:46:45Z,
# status: placed,
# complete: false