@gls_spain/gps-common 27.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +11 -0
- package/.idea/codeStyles/Project.xml +37 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/gps-common.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/watcherTasks.xml +45 -0
- package/.prettierignore +5 -0
- package/.prettierrc.json +13 -0
- package/.releaserc +17 -0
- package/CHANGELOG.md +848 -0
- package/README.md +122 -0
- package/errors/DatabaseNotEmptyError.js +9 -0
- package/errors/DefaultsDoNotExistError.js +9 -0
- package/errors/ExpeditionAlreadyExistsError.js +9 -0
- package/errors/ExpeditionCannotBeDeletedError.js +9 -0
- package/errors/ExpeditionCannotBeUpdatedError.js +9 -0
- package/errors/ExpeditionDoesNotExistError.js +9 -0
- package/errors/JobDoesNotExistError.js +9 -0
- package/errors/NetworkAlreadyExistsError.js +9 -0
- package/errors/NetworkCannotBeDeletedError.js +9 -0
- package/errors/NetworkDoesNotExistError.js +9 -0
- package/errors/RepresentativeAlreadyExistsError.js +9 -0
- package/errors/RepresentativeCannotBeDeletedError.js +9 -0
- package/errors/RepresentativeDoesNotExistError.js +9 -0
- package/errors/ShopAlreadyExistsError.js +9 -0
- package/errors/ShopCannotBeDeletedError.js +9 -0
- package/errors/ShopDoesNotExistError.js +9 -0
- package/errors/ShopNotEnabledError.js +9 -0
- package/errors/UserAlreadyExistsError.js +9 -0
- package/errors/UserCannotBeDeletedError.js +9 -0
- package/errors/UserCannotBeUpdatedError.js +9 -0
- package/errors/UserDoesNotExistError.js +9 -0
- package/errors/WrongNetworkError.js +9 -0
- package/errors/WrongPasswordError.js +9 -0
- package/errors/WrongShopError.js +9 -0
- package/errors/ZoneAlreadyExistsError.js +9 -0
- package/errors/ZoneCannotBeDeletedError.js +9 -0
- package/errors/ZoneDoesNotExistError.js +9 -0
- package/errors/index.js +88 -0
- package/index.js +9 -0
- package/index.test.js +35 -0
- package/jest.config.js +5 -0
- package/open-api-spec/index.js +2920 -0
- package/package.json +68 -0
- package/schemas/definitions/become.js +5 -0
- package/schemas/definitions/common.js +172 -0
- package/schemas/definitions/defaults.js +84 -0
- package/schemas/definitions/expeditions.js +637 -0
- package/schemas/definitions/init.js +37 -0
- package/schemas/definitions/integration-events.js +127 -0
- package/schemas/definitions/jobs.js +124 -0
- package/schemas/definitions/login.js +38 -0
- package/schemas/definitions/logout.js +8 -0
- package/schemas/definitions/networks.js +107 -0
- package/schemas/definitions/pods.js +37 -0
- package/schemas/definitions/representatives.js +178 -0
- package/schemas/definitions/shops.js +352 -0
- package/schemas/definitions/users.js +373 -0
- package/schemas/definitions/zones.js +92 -0
- package/schemas/index.js +335 -0
- package/scripts/build-documentation.js +40 -0
- package/scripts/build-json-schemas.js +35 -0
|
@@ -0,0 +1,2920 @@
|
|
|
1
|
+
const {
|
|
2
|
+
BadRequestError,
|
|
3
|
+
UnauthorizedError,
|
|
4
|
+
ForbiddenError,
|
|
5
|
+
UnsupportedMediaTypeError,
|
|
6
|
+
InternalServerErrorError,
|
|
7
|
+
InvalidUsernameOrPasswordError,
|
|
8
|
+
InvalidUserInCookieOrHeaderError,
|
|
9
|
+
InvalidCookieOrHeaderError,
|
|
10
|
+
MissingCookieOrHeaderError,
|
|
11
|
+
} = require('@gls_spain/common-errors');
|
|
12
|
+
const { errorResponse, specificHttpError } = require('@gls_spain/common-json-schemas');
|
|
13
|
+
const {
|
|
14
|
+
DatabaseNotEmptyError,
|
|
15
|
+
UserDoesNotExistError,
|
|
16
|
+
UserAlreadyExistsError,
|
|
17
|
+
UserCannotBeUpdatedError,
|
|
18
|
+
UserCannotBeDeletedError,
|
|
19
|
+
NetworkDoesNotExistError,
|
|
20
|
+
NetworkAlreadyExistsError,
|
|
21
|
+
NetworkCannotBeDeletedError,
|
|
22
|
+
ShopDoesNotExistError,
|
|
23
|
+
ShopAlreadyExistsError,
|
|
24
|
+
ShopCannotBeDeletedError,
|
|
25
|
+
ShopNotEnabledError,
|
|
26
|
+
WrongPasswordError,
|
|
27
|
+
ExpeditionDoesNotExistError,
|
|
28
|
+
ExpeditionAlreadyExistsError,
|
|
29
|
+
ExpeditionCannotBeUpdatedError,
|
|
30
|
+
ExpeditionCannotBeDeletedError,
|
|
31
|
+
DefaultsDoNotExistError,
|
|
32
|
+
RepresentativeDoesNotExistError,
|
|
33
|
+
RepresentativeAlreadyExistsError,
|
|
34
|
+
RepresentativeCannotBeDeletedError,
|
|
35
|
+
ZoneDoesNotExistError,
|
|
36
|
+
ZoneAlreadyExistsError,
|
|
37
|
+
ZoneCannotBeDeletedError,
|
|
38
|
+
} = require('../errors');
|
|
39
|
+
const { timezoneNames } = require('../schemas/definitions/common');
|
|
40
|
+
const { initRequest, initResponse } = require('../schemas/definitions/init');
|
|
41
|
+
const { loginResponse } = require('../schemas/definitions/login');
|
|
42
|
+
const { logoutResponse } = require('../schemas/definitions/logout');
|
|
43
|
+
const { becomeRequest } = require('../schemas/definitions/become');
|
|
44
|
+
const {
|
|
45
|
+
superAdmin,
|
|
46
|
+
createSuperAdminRequest,
|
|
47
|
+
createSuperAdminResponse,
|
|
48
|
+
findSuperAdminsRequest,
|
|
49
|
+
findSuperAdminsResponse,
|
|
50
|
+
updateSuperAdminRequest,
|
|
51
|
+
updateSuperAdminResponse,
|
|
52
|
+
deleteSuperAdminRequest,
|
|
53
|
+
deleteSuperAdminResponse,
|
|
54
|
+
networkAdmin,
|
|
55
|
+
createNetworkAdminRequest,
|
|
56
|
+
createNetworkAdminResponse,
|
|
57
|
+
findNetworkAdminsRequest,
|
|
58
|
+
findNetworkAdminsResponse,
|
|
59
|
+
updateNetworkAdminRequest,
|
|
60
|
+
updateSelfNetworkAdminRequest,
|
|
61
|
+
updateNetworkAdminResponse,
|
|
62
|
+
deleteNetworkAdminRequest,
|
|
63
|
+
deleteNetworkAdminResponse,
|
|
64
|
+
shopUser,
|
|
65
|
+
createShopUserRequest,
|
|
66
|
+
createShopUserResponse,
|
|
67
|
+
findShopUsersSuperAdminRequest,
|
|
68
|
+
findShopUsersNetworkAdminRequest,
|
|
69
|
+
findShopUsersResponse,
|
|
70
|
+
updateShopUserRequest,
|
|
71
|
+
updateSelfShopUserRequest,
|
|
72
|
+
updateShopUserResponse,
|
|
73
|
+
deleteShopUserRequest,
|
|
74
|
+
deleteShopUserResponse,
|
|
75
|
+
} = require('../schemas/definitions/users');
|
|
76
|
+
const {
|
|
77
|
+
network,
|
|
78
|
+
createNetworkRequest,
|
|
79
|
+
createNetworkResponse,
|
|
80
|
+
listNetworksNamesResponse,
|
|
81
|
+
findNetworksRequest,
|
|
82
|
+
findNetworksResponse,
|
|
83
|
+
updateNetworkRequest,
|
|
84
|
+
updateNetworkResponse,
|
|
85
|
+
deleteNetworkRequest,
|
|
86
|
+
deleteNetworkResponse,
|
|
87
|
+
} = require('../schemas/definitions/networks');
|
|
88
|
+
const {
|
|
89
|
+
shop,
|
|
90
|
+
createShopRequest,
|
|
91
|
+
createShopResponse,
|
|
92
|
+
findShopsSuperAdminRequest,
|
|
93
|
+
findShopsNetworkAdminRequest,
|
|
94
|
+
findShopsResponse,
|
|
95
|
+
updateShopRequest,
|
|
96
|
+
updateShopResponse,
|
|
97
|
+
deleteShopRequest,
|
|
98
|
+
deleteShopResponse,
|
|
99
|
+
} = require('../schemas/definitions/shops');
|
|
100
|
+
const {
|
|
101
|
+
expedition,
|
|
102
|
+
createExpeditionRequest,
|
|
103
|
+
createExpeditionResponse,
|
|
104
|
+
findExpeditionsRequest,
|
|
105
|
+
findExpeditionsResponse,
|
|
106
|
+
updateExpeditionRequest,
|
|
107
|
+
updateExpeditionResponse,
|
|
108
|
+
deleteExpeditionRequest,
|
|
109
|
+
deleteExpeditionResponse,
|
|
110
|
+
redirectExpeditionRequest,
|
|
111
|
+
redirectExpeditionResponse,
|
|
112
|
+
scanExpeditionRequest,
|
|
113
|
+
scanExpeditionResponse,
|
|
114
|
+
processExpeditionsWithDriverRequest,
|
|
115
|
+
processExpeditionsWithCustomerRequest,
|
|
116
|
+
processExpeditionsResponse,
|
|
117
|
+
receiveAllExpeditionsFromDriverRequest,
|
|
118
|
+
receiveAllExpeditionsFromDriverResponse,
|
|
119
|
+
} = require('../schemas/definitions/expeditions');
|
|
120
|
+
const { getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
|
|
121
|
+
const { pod, findPodsRequest, findPodsResponse } = require('../schemas/definitions/pods');
|
|
122
|
+
const {
|
|
123
|
+
receiveFromDriverEvent,
|
|
124
|
+
receiveFromCustomerEvent,
|
|
125
|
+
giveToCustomerEvent,
|
|
126
|
+
giveToDriverEvent,
|
|
127
|
+
expirationReminderEvent,
|
|
128
|
+
expiredEvent,
|
|
129
|
+
priceEvent,
|
|
130
|
+
upsertShopEvent,
|
|
131
|
+
upsertNetworkEvent,
|
|
132
|
+
} = require('../schemas/definitions/integration-events');
|
|
133
|
+
const {
|
|
134
|
+
findJobsRequest,
|
|
135
|
+
findExpeditionJobsResponse,
|
|
136
|
+
findShopsJobsResponse,
|
|
137
|
+
findNetworksJobsResponse,
|
|
138
|
+
} = require('../schemas/definitions/jobs');
|
|
139
|
+
const {
|
|
140
|
+
representative,
|
|
141
|
+
createRepresentativeRequest,
|
|
142
|
+
createRepresentativeResponse,
|
|
143
|
+
findRepresentativesRequest,
|
|
144
|
+
findRepresentativesResponse,
|
|
145
|
+
listRepresentativesNamesResponse,
|
|
146
|
+
updateRepresentativeRequest,
|
|
147
|
+
updateRepresentativeResponse,
|
|
148
|
+
getRepresentativeCommissionsRequest,
|
|
149
|
+
getRepresentativeCommissionsResponse,
|
|
150
|
+
deleteRepresentativeRequest,
|
|
151
|
+
deleteRepresentativeResponse,
|
|
152
|
+
} = require('../schemas/definitions/representatives');
|
|
153
|
+
const {
|
|
154
|
+
zone,
|
|
155
|
+
createZoneRequest,
|
|
156
|
+
createZoneResponse,
|
|
157
|
+
listZonesNamesResponse,
|
|
158
|
+
findZonesRequest,
|
|
159
|
+
findZonesResponse,
|
|
160
|
+
updateZoneRequest,
|
|
161
|
+
updateZoneResponse,
|
|
162
|
+
deleteZoneRequest,
|
|
163
|
+
deleteZoneResponse,
|
|
164
|
+
} = require('../schemas/definitions/zones');
|
|
165
|
+
|
|
166
|
+
const openApiSpec = { openapi: '3.0.2' };
|
|
167
|
+
|
|
168
|
+
openApiSpec.info = {
|
|
169
|
+
title: 'GLS Parcel Shops API',
|
|
170
|
+
description: `
|
|
171
|
+
This API is versioned using [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html) and follows the semver specification.
|
|
172
|
+
|
|
173
|
+
You can see what's new and the latest changes to the API in the [changelog](/help/changelog).`,
|
|
174
|
+
contact: { name: 'Cristóbal Valverde', email: 'cristobal.valverde@gls-spain.es' },
|
|
175
|
+
license: { name: 'NO LICENSE', url: 'https://choosealicense.com/no-permission/' },
|
|
176
|
+
version: 'v1.0.0',
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
openApiSpec.servers = [
|
|
180
|
+
{
|
|
181
|
+
url: 'http://localhost:3001',
|
|
182
|
+
description: 'Localhost API connected to localhost or staging DB',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
url: 'https://api.gps.albo.dev',
|
|
186
|
+
description: 'Staging API and DB',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
url: 'https://api.shop.gls-spain.es',
|
|
190
|
+
description: 'Production API and DB',
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
openApiSpec['x-tagGroups'] = [
|
|
195
|
+
{
|
|
196
|
+
name: '',
|
|
197
|
+
tags: ['Introduction', 'Errors', 'Data formats'],
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'RESOURCES',
|
|
201
|
+
tags: ['Super admin', 'Network', 'Network admin', 'Zone', 'Shop', 'Shop user', 'Expedition', 'Pod', 'Sales representative'],
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'INTEGRATIONS',
|
|
205
|
+
tags: ['GLS'],
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: 'ENDPOINTS',
|
|
209
|
+
tags: [
|
|
210
|
+
'Authentication',
|
|
211
|
+
'Documentation',
|
|
212
|
+
'Config',
|
|
213
|
+
'Background jobs',
|
|
214
|
+
'Super admins',
|
|
215
|
+
'Networks',
|
|
216
|
+
'Network admins',
|
|
217
|
+
'Zones',
|
|
218
|
+
'Shops',
|
|
219
|
+
'Shop users',
|
|
220
|
+
'Expeditions',
|
|
221
|
+
'Pods',
|
|
222
|
+
'Sales representatives',
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
|
|
227
|
+
openApiSpec.tags = [
|
|
228
|
+
{
|
|
229
|
+
name: 'Introduction',
|
|
230
|
+
description: `
|
|
231
|
+
This is the API for managing GLS parcel shops, which are establishments that can store packages for the customers to pick up.
|
|
232
|
+
|
|
233
|
+
Parcel shops are grouped by networks, which are the companies or associations that have a deal with GLS to use their
|
|
234
|
+
establishments as parcel shops.
|
|
235
|
+
|
|
236
|
+
The API can be used by 3 kinds of users:
|
|
237
|
+
|
|
238
|
+
- Super admins: these are the GLS staff that manage the entire API. They can:
|
|
239
|
+
|
|
240
|
+
- Manage all kinds of users, including other super admins.
|
|
241
|
+
- Manage networks.
|
|
242
|
+
- Manage shops from any network.
|
|
243
|
+
|
|
244
|
+
- Network admins: these are the managers of a single network. They can:
|
|
245
|
+
|
|
246
|
+
- Manage shops from their network.
|
|
247
|
+
- Manage their shop users.
|
|
248
|
+
|
|
249
|
+
- Shop users: these are the staff that work at the parcel shops. They can:
|
|
250
|
+
|
|
251
|
+
- Manage the shop inventory.
|
|
252
|
+
- Receive packages from GLS.
|
|
253
|
+
- Deliver packages to customers.
|
|
254
|
+
- Receive packages from customers to return to the sender.
|
|
255
|
+
- etc...
|
|
256
|
+
|
|
257
|
+
Every endpoint of this documentation has a caption before its name indicating who can use it: **[S]** for super admins,
|
|
258
|
+
**[N]** for network admins and **[U]** for shop users. If an endpoint can be used by more than one role the caption will
|
|
259
|
+
include all the relevant letters, e.g. **[SNU]** for an endpoint that everybody can use.`,
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: 'Errors',
|
|
263
|
+
description: `
|
|
264
|
+
When the API encounters an error it will respond with the appropriate HTTP status code and a JSON body with an error like this:
|
|
265
|
+
|
|
266
|
+
<SchemaDefinition schemaRef="#/components/schemas/errorResponse" />
|
|
267
|
+
|
|
268
|
+
Each endpoint lists all the possible errors it can return. Error names can be specific (e.g. \`UserDoesNotExistError\`)
|
|
269
|
+
or generic (e.g. \`BadRequest\` or \`Unauthorized\`) depending on the situation.
|
|
270
|
+
|
|
271
|
+
An endpoint can return more than one error with the same HTTP status, e.g.:
|
|
272
|
+
|
|
273
|
+
- \`500 InternalServerError\`.
|
|
274
|
+
- \`500 UserAlreadyExistsError\`.
|
|
275
|
+
- \`500 UserCannotBeDeletedError\`.
|
|
276
|
+
|
|
277
|
+
You will need to look at the name to differentiate them.`,
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: 'Data formats',
|
|
281
|
+
description: `
|
|
282
|
+
The API follows the [OpenAPI specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md)
|
|
283
|
+
and the [JSON Schema draft 7 standard](https://json-schema.org/understanding-json-schema/index.html) for data types.
|
|
284
|
+
|
|
285
|
+
There are two string formats that require special consideration: \`uuid\` and \`date-time\`.
|
|
286
|
+
|
|
287
|
+
#### Strings with uuid format
|
|
288
|
+
|
|
289
|
+
As per the [international specification](http://www.itu.int/rec/T-REC-X.667/en) the API accepts both uppercase and
|
|
290
|
+
lowercase strings when dealing with \`uuid\`, and always returns them as lowercase.
|
|
291
|
+
|
|
292
|
+
#### Strings with date-time format
|
|
293
|
+
|
|
294
|
+
The API manipulates all datetime information as strings with \`date-time\` format as described in the
|
|
295
|
+
[RFC3339 standard](https://tools.ietf.org/html/rfc3339#section-5.6).
|
|
296
|
+
|
|
297
|
+
All information is stored as UTC datetimes (e.g. *2019-09-01T09:00:00.000Z*) but for compatibility purposes the API
|
|
298
|
+
will accept and transform the following variations:
|
|
299
|
+
|
|
300
|
+
- As per the RFC3339 recommendation, the date and time separator can be a space instead of a T.
|
|
301
|
+
- If the incoming string has no timezone information (e.g. *2019-09-01T09:00:00*) it will be assumed to be UTC.
|
|
302
|
+
- If the incoming string uses another timezone (e.g. *2019-01-09T11:00:00+02:00*) it will be transformed to UTC.
|
|
303
|
+
|
|
304
|
+
#### Strings with timezone format
|
|
305
|
+
|
|
306
|
+
The \`timezone\` format allows timezone names from the [tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
|
|
307
|
+
except for the following names that have been removed:
|
|
308
|
+
|
|
309
|
+
- The deprecated names.
|
|
310
|
+
- The \`Etc\` zone.
|
|
311
|
+
- Generic values like \`GMT\` or \`UTC\` that are not geographic zones.
|
|
312
|
+
|
|
313
|
+
The full list of allowed timezone names is:
|
|
314
|
+
|
|
315
|
+
<SchemaDefinition schemaRef="#/components/schemas/timezoneNames" />
|
|
316
|
+
`,
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: 'Super admin',
|
|
320
|
+
description: `
|
|
321
|
+
Super administrators can manage all the resources of the API.
|
|
322
|
+
|
|
323
|
+
An initial super administrator is created when the API is deployed (see [config](#tag/Config)) and then that super administrator
|
|
324
|
+
can create additional super administrators using the [super admins](#tag/Super-admins) endpoints.
|
|
325
|
+
|
|
326
|
+
<SchemaDefinition schemaRef="#/components/schemas/superAdmin" />`,
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: 'Network',
|
|
330
|
+
description: `
|
|
331
|
+
Networks represent the providers of parcel shops, e.g. the companies or associations that have a deal with GLS to use
|
|
332
|
+
their establishments as parcel shops. Every parcel shop belongs to a single network.
|
|
333
|
+
|
|
334
|
+
Super administrators can manage networks using the [networks](#tag/Networks) endpoints.
|
|
335
|
+
|
|
336
|
+
<SchemaDefinition schemaRef="#/components/schemas/network" />`,
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: 'Network admin',
|
|
340
|
+
description: `
|
|
341
|
+
Network administrators are associated with a single network and they can view the parcel shops that belong to their network.
|
|
342
|
+
|
|
343
|
+
Super administrators can manage network administrators using the [network admins](#tag/Network-admins) endpoints.
|
|
344
|
+
|
|
345
|
+
<SchemaDefinition schemaRef="#/components/schemas/networkAdmin" />`,
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: 'Zone',
|
|
349
|
+
description: `
|
|
350
|
+
Zones are geographic areas that define the commissions that the sales representatives earn for their work on the shops in those areas.
|
|
351
|
+
|
|
352
|
+
Super administrators can create and manage zones using the [zones](#tag/Zones) endpoints, and then associate them to parcel shops and sales
|
|
353
|
+
representatives on creation or update.
|
|
354
|
+
|
|
355
|
+
<SchemaDefinition schemaRef="#/components/schemas/zone" />`,
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: 'Shop',
|
|
359
|
+
description: `
|
|
360
|
+
Parcel shops are the establishments that GLS and the customers can use to deliver and pickup expeditions instead of doing
|
|
361
|
+
it at the customers home.
|
|
362
|
+
|
|
363
|
+
Every parcel shop is associated to a network, and it must have at least one shop user associated to it for the parcel
|
|
364
|
+
shop to function.
|
|
365
|
+
|
|
366
|
+
Super administrators can manage shops from any network and network administrators can view shops from their own network
|
|
367
|
+
using the [shops](#tag/Shops) endpoints.
|
|
368
|
+
|
|
369
|
+
<SchemaDefinition schemaRef="#/components/schemas/shop" />`,
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
name: 'Shop user',
|
|
373
|
+
description: `
|
|
374
|
+
Shop users are associated with a single shop and they have limited capabilities to manage the shop and its expeditions,
|
|
375
|
+
e.g. they can edit some of the shop properties or receive and deliver expeditions, but not edit anything else about them.
|
|
376
|
+
|
|
377
|
+
Super administrators can manage shop users from any network and network administrators can view shop users from their
|
|
378
|
+
own network using the [shop users](#tag/Shop-users) endpoints.
|
|
379
|
+
|
|
380
|
+
<SchemaDefinition schemaRef="#/components/schemas/shopUser" />`,
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'Expedition',
|
|
384
|
+
description: `
|
|
385
|
+
Expeditions are the packages that are delivered and picked up at parcel shops.
|
|
386
|
+
|
|
387
|
+
Every expedition is associated to a parcel shop.
|
|
388
|
+
|
|
389
|
+
Super administrators can manage expeditions using the [expeditions](#tag/Expeditions) endpoints. Shop users can also use
|
|
390
|
+
some of those endpoints to receive and give expeditions from and to GLS and customers.
|
|
391
|
+
|
|
392
|
+
<SchemaDefinition schemaRef="#/components/schemas/expedition" />`,
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: 'Pod',
|
|
396
|
+
description: `
|
|
397
|
+
Expeditions that have been delivered to a customer have a POD (Proof Of Delivery) associated to them that contains the
|
|
398
|
+
signature of the customer that picked up the expedition.
|
|
399
|
+
|
|
400
|
+
Pods are created automatically by the API when an expedition is delivered to a customer.
|
|
401
|
+
|
|
402
|
+
Super administrators, network administrators and shop users can use the [pods](#tag/Pods) endpoints to find the pods of the
|
|
403
|
+
expeditions they have access to.
|
|
404
|
+
|
|
405
|
+
<SchemaDefinition schemaRef="#/components/schemas/pod" />`,
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: 'Sales representative',
|
|
409
|
+
description: `
|
|
410
|
+
Sales representatives are the GLS staff that make deals with businesses to open establishments as parcel shops. Each parcel shop
|
|
411
|
+
in the API has two representatives associated to it: the one that made the deal to open the shop and the one that is currently
|
|
412
|
+
managing it.
|
|
413
|
+
|
|
414
|
+
Super administrators can create and manage sales representatives using the [sales representatives](#tag/Sales-representatives)
|
|
415
|
+
endpoints, and then associate them to parcel shops on creation or update.
|
|
416
|
+
|
|
417
|
+
<SchemaDefinition schemaRef="#/components/schemas/representative" />`,
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
name: 'GLS',
|
|
421
|
+
description: `
|
|
422
|
+
This API is integrated with another GLS API connected to the main database. The integration goes in both directions:
|
|
423
|
+
|
|
424
|
+
- The GLS API has a super admin user to access this API and manage its resources, e.g. creating expeditions.
|
|
425
|
+
- This API sends events to the GLS API on certain situations, e.g. when a shop receives an expedition.
|
|
426
|
+
|
|
427
|
+
Since this API may have networks that are independent of the GLS API, it needs a way to configure for each network if it
|
|
428
|
+
has to send the events or not. This is done with the \`integrations\` property of a network. The API will only send events
|
|
429
|
+
for those networks whose \`integrations\` property contains the value \`gls\`.
|
|
430
|
+
|
|
431
|
+
Also this API needs to know when a request comes from the GLS API or not, in order to prevent a feedback loop where the
|
|
432
|
+
GLS API does an operation and this API sends back an event telling it to synchronize with the operation. This is done
|
|
433
|
+
with the \`integrations\` property of the users. If it contains the value \`glsApi\` then the API will not send events
|
|
434
|
+
for any request made by that user.
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
### Events
|
|
438
|
+
|
|
439
|
+
The possible events sent to the GLS API are listed below, along with the situation that causes them to be sent.
|
|
440
|
+
|
|
441
|
+
#### Upsert network event
|
|
442
|
+
|
|
443
|
+
A network has been created or updated by calling [/networks/create](#tag/Networks/paths/~1networks~1create/post) or
|
|
444
|
+
[/networks/update](#tag/Networks/paths/~1networks~1update/post).
|
|
445
|
+
|
|
446
|
+
<SchemaDefinition schemaRef="#/components/schemas/upsertNetworkEvent" />
|
|
447
|
+
|
|
448
|
+
#### Upsert shop event
|
|
449
|
+
|
|
450
|
+
A shop has been created or updated by calling [/shops/create](#tag/Shops/paths/~1shops~1create/post) or
|
|
451
|
+
[/shops/update](#tag/Shops/paths/~1shops~1update/post).
|
|
452
|
+
|
|
453
|
+
<SchemaDefinition schemaRef="#/components/schemas/upsertShopEvent" />
|
|
454
|
+
|
|
455
|
+
#### Receive from driver event
|
|
456
|
+
|
|
457
|
+
The [/expeditions/receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) endpoint has been called,
|
|
458
|
+
indicating that a shop has received an expedition from a driver.
|
|
459
|
+
|
|
460
|
+
<SchemaDefinition schemaRef="#/components/schemas/receiveFromDriverEvent" />
|
|
461
|
+
|
|
462
|
+
#### Receive from customer event
|
|
463
|
+
|
|
464
|
+
The [/expeditions/receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post) endpoint has been
|
|
465
|
+
called, indicating that a shop has received an expedition from a customer.
|
|
466
|
+
|
|
467
|
+
<SchemaDefinition schemaRef="#/components/schemas/receiveFromCustomerEvent" />
|
|
468
|
+
|
|
469
|
+
#### Give to customer event
|
|
470
|
+
|
|
471
|
+
The [/expeditions/giveToCustomer](#tag/Expeditions/paths/~1expeditions~1giveToCustomer/post) endpoint has been called,
|
|
472
|
+
indicating that a shop has given an expedition to a customer.
|
|
473
|
+
|
|
474
|
+
<SchemaDefinition schemaRef="#/components/schemas/giveToCustomerEvent" />
|
|
475
|
+
|
|
476
|
+
#### Give to driver event
|
|
477
|
+
|
|
478
|
+
The [/expeditions/giveToDriver](#tag/Expeditions/paths/~1expeditions~1giveToDriver/post) endpoint has been called, indicating
|
|
479
|
+
that a shop has given an expedition to a driver.
|
|
480
|
+
|
|
481
|
+
<SchemaDefinition schemaRef="#/components/schemas/giveToDriverEvent" />
|
|
482
|
+
|
|
483
|
+
#### Expiration reminder event
|
|
484
|
+
|
|
485
|
+
The API has detected in one of its background checks that an expedition that is still in a shop is configured to send a
|
|
486
|
+
reminder today. The customer should be notified that he still has an expedition to retrieve.
|
|
487
|
+
|
|
488
|
+
<SchemaDefinition schemaRef="#/components/schemas/expirationReminderEvent" />
|
|
489
|
+
|
|
490
|
+
#### Expired event
|
|
491
|
+
|
|
492
|
+
The API has detected in one of its background checks that an expedition that is still in a shop is configured to expire
|
|
493
|
+
today. A driver should come to the shop to retrieve it.
|
|
494
|
+
|
|
495
|
+
<SchemaDefinition schemaRef="#/components/schemas/expiredEvent" />
|
|
496
|
+
|
|
497
|
+
#### Price event
|
|
498
|
+
|
|
499
|
+
The expedition price (the amount paid to the shop and network) has been calculated for the first time when the expedition is received at
|
|
500
|
+
the shop, or anytime after that the expedition has been updated and the price has changed.
|
|
501
|
+
|
|
502
|
+
<SchemaDefinition schemaRef="#/components/schemas/priceEvent" />`,
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: 'Authentication',
|
|
506
|
+
description: `
|
|
507
|
+
Most of the endpoints of this API require that the requests are made by an authenticated user.
|
|
508
|
+
|
|
509
|
+
To authenticate a user use the [login](#tag/Authentication/paths/~1login/get) endpoint which requires an HTTP basic auth header.
|
|
510
|
+
|
|
511
|
+
If the authentication is successful it will return the user in the response body and set two cookies:
|
|
512
|
+
|
|
513
|
+
- \`x-access-token\`:
|
|
514
|
+
- It has the \`http-only\`, \`domain\` and \`sameSite: strict\` attributes.
|
|
515
|
+
- The client must send back this cookie on subsequent requests.
|
|
516
|
+
- \`x-csrf-token\`:
|
|
517
|
+
- It has the \`domain\` and \`sameSite: strict\` attributes.
|
|
518
|
+
- The client must access this cookie and send it back on subsequent requests **as a header with the same name**.
|
|
519
|
+
|
|
520
|
+
Using this two cookies prevents XSS and CSRF attacks, but forces the API and the frontend to run under some common domain,
|
|
521
|
+
which means that for development **a client running on localhost can only authenticate against an API also running on localhost.**
|
|
522
|
+
|
|
523
|
+
Some endpoints may require additional authorization, e.g. for the authenticated user to be a \`superAdmin\`.
|
|
524
|
+
The endpoints that require so will indicate it in their description.`,
|
|
525
|
+
},
|
|
526
|
+
{ name: 'Documentation' },
|
|
527
|
+
{
|
|
528
|
+
name: 'Config',
|
|
529
|
+
description: `API initialization and configuration.
|
|
530
|
+
|
|
531
|
+
This section has an endpoint to initialize the API when deployed to a new environment.
|
|
532
|
+
|
|
533
|
+
There are also endpoints to configure the default settings for networks and shops, like the rate prices for deliveries
|
|
534
|
+
and pickups, the maximum number of days that an expedition can be in a shop before returning it, etc.
|
|
535
|
+
|
|
536
|
+
These settings can be set at various levels of specificity:
|
|
537
|
+
|
|
538
|
+
- Default values: these are set in this section and apply to networks and shops that do not have custom settings.
|
|
539
|
+
- Network specific values: each network can have its custom settings, which override the default ones.
|
|
540
|
+
- Shop specific values: each shop can have its custom settings, which override the network and default ones.`,
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
name: 'Background jobs',
|
|
544
|
+
description: `Find the status and progress of the API background jobs.
|
|
545
|
+
|
|
546
|
+
In addition to handling requests, the API also performs background work. Some of this work is in response to a request
|
|
547
|
+
like when an expedition is given to a customer, and some of it is because the API does regular checks for certain conditions
|
|
548
|
+
like checking every day if any expedition has expired and needs to be retired by the driver.
|
|
549
|
+
|
|
550
|
+
This work is scheduled as individual jobs stored in one of several processing queues. A background process periodically
|
|
551
|
+
checks this queues and processes the pending jobs.
|
|
552
|
+
|
|
553
|
+
These endpoints allow a super admin to check the jobs in the processing queues.`,
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
name: 'Super admins',
|
|
557
|
+
description: `Create and manage super admins.
|
|
558
|
+
|
|
559
|
+
Super admins are the top level admins of the system and they can manage all kinds of resources.`,
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
name: 'Networks',
|
|
563
|
+
description: `Create and manage networks.
|
|
564
|
+
|
|
565
|
+
Networks are collections of parcel shops that belong to the same provider.
|
|
566
|
+
|
|
567
|
+
A network that has admins or parcel shops associated to it will have its \`deletable\` property automatically set to
|
|
568
|
+
\`false\` and cannot be deleted.
|
|
569
|
+
|
|
570
|
+
A network may have custom derivation and expiration settings or use the defaults defined in [config](#tag/Config):
|
|
571
|
+
|
|
572
|
+
- If it has \`derivationSettings\` or \`expirationSettings\` properties it means it has custom settings.
|
|
573
|
+
- If not, then the values in its \`defaults\` property will be used, which are a copy of the default values.
|
|
574
|
+
|
|
575
|
+
See [create](#tag/Networks/paths/~1networks~1create/post) and [update](#tag/Networks/paths/~1networks~1update/post) on
|
|
576
|
+
how to set or remove the custom properties.
|
|
577
|
+
|
|
578
|
+
See the [GLS integration](#tag/GLS) section for more information about the \`integrations\` property.`,
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
name: 'Network admins',
|
|
582
|
+
description: `Create and manage network admins.
|
|
583
|
+
|
|
584
|
+
Network admins are associated to a particular network and can view its resources, like their shops and shop users.`,
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: 'Zones',
|
|
588
|
+
description: `Create and manage zones.
|
|
589
|
+
|
|
590
|
+
Zones define geographic areas that both the shops and the sales representatives are associated to. They define the commissions the sales
|
|
591
|
+
representatives earn for the shops they open or manage.
|
|
592
|
+
`,
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
name: 'Shops',
|
|
596
|
+
description: `Create and manage shops.
|
|
597
|
+
|
|
598
|
+
A shop is assigned to a network on creation and its network cannot be changed later.
|
|
599
|
+
|
|
600
|
+
A shop that has users or expeditions associated to it will have its \`deletable\` property automatically set to \`false\`
|
|
601
|
+
and cannot be deleted.
|
|
602
|
+
|
|
603
|
+
A shop may have custom derivation and expiration settings, use its network values or use the defaults defined in [config](#tag/Config):
|
|
604
|
+
|
|
605
|
+
- If it has \`derivationSettings\` or \`expirationSettings\` properties it means it has custom settings.
|
|
606
|
+
- If not, then the values in its \`network\` property will be used, which are a copy of the values of its network.
|
|
607
|
+
- If it doesn't have settings in its \`network\` property then the values in its \`defaults\` property will be used, which are a copy of
|
|
608
|
+
the default values.
|
|
609
|
+
|
|
610
|
+
See [create](#tag/Shops/paths/~1shops~1create/post) and [update](#tag/Shops/paths/~1shops~1update/post) on how to set or remove
|
|
611
|
+
the custom properties.
|
|
612
|
+
|
|
613
|
+
### Status
|
|
614
|
+
|
|
615
|
+
A shop can be enabled or disabled as indicated by its \`status.code\` property. This property cannot be set directly,
|
|
616
|
+
instead its value depends on the other \`status\` properties:
|
|
617
|
+
|
|
618
|
+
| \`status.manuallyDisabled\` | \`status.disabled\` | Resulting \`status.code\` |
|
|
619
|
+
| :---: | :---: | :--- |
|
|
620
|
+
| √ | - | \`manuallyDisabled\` |
|
|
621
|
+
| X | √ | \`disabled\` |
|
|
622
|
+
| X | X | \`enabled\` |
|
|
623
|
+
|
|
624
|
+
`,
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
name: 'Shop users',
|
|
628
|
+
description: `Create and manage shop users.
|
|
629
|
+
|
|
630
|
+
Shop users are associated with a single shop and they have limited capabilities to manage the shop and its expeditions`,
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
name: 'Expeditions',
|
|
634
|
+
description: `Create and manage expeditions.
|
|
635
|
+
|
|
636
|
+
Expeditions are the packages that are delivered and picked up via the parcel shops. Each expedition can have more than one package.
|
|
637
|
+
|
|
638
|
+
An expedition that has pods associated to it will have its \`deletable\` property automatically set to \`false\` and cannot be deleted.
|
|
639
|
+
|
|
640
|
+
### Types
|
|
641
|
+
|
|
642
|
+
There are 3 kinds of expeditions, indicated in its \`type\` property:
|
|
643
|
+
|
|
644
|
+
- \`delivery\`: the most common situation where a driver leaves an expedition at a parcel shop for the customer to retrieve it later.
|
|
645
|
+
- \`pickup\`: the reverse situation (e.g. a return) where a customer leaves an expedition at a parcel shop for the driver to retrieve it later.
|
|
646
|
+
- \`sale\`: a customer comes to the parcel shop with a new expedition, pays a rate for it to be delivered to someone else and leaves it
|
|
647
|
+
at the parcel shop for a driver to retrieve it later.
|
|
648
|
+
|
|
649
|
+
### Status
|
|
650
|
+
|
|
651
|
+
The \`status.code\` property of an expedition indicates the situation of an expedition from the parcel shop perspective:
|
|
652
|
+
|
|
653
|
+
- \`incoming\`: the expedition is on its way to the parcel shop. A driver or a customer is expected to come and leave it at the parcel shop.
|
|
654
|
+
- \`inShop\`: the parcel shop has received the expedition and it is waiting for the other person to retrieve it.
|
|
655
|
+
- \`inShopExpired\`: only for deliveries that have been in the parcel shop for too long without the customer retrieving it.
|
|
656
|
+
The expedition is then scheduled to be given to the driver to return it to the original sender.
|
|
657
|
+
- \`delivered\`: the final status for any expedition, meaning that it has been given to the customer or driver and is no longer in the parcel shop.
|
|
658
|
+
|
|
659
|
+
The \`status\` of an expedition cannot be updated with a regular [update](#tag/Expeditions/paths/~1expeditions~1update/post)
|
|
660
|
+
because it has a predetermined life cycle. The following endpoints update an expedition status and add or remove additional
|
|
661
|
+
\`status\` properties:
|
|
662
|
+
|
|
663
|
+
| Operation | Type | From status | To status | New status properties |
|
|
664
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
665
|
+
| [receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) | delivery | incoming | inShop | receivedFrom, expiration |
|
|
666
|
+
| [receiveAllFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveAllFromDriver/post) | delivery | incoming | inShop | receivedFrom, expiration |
|
|
667
|
+
| [receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post) | pickup | incoming | inShop | receivedFrom, expiration |
|
|
668
|
+
| [giveToCustomer](#tag/Expeditions/paths/~1expeditions~1giveToCustomer/post) | delivery | inShop | delivered | givenTo |
|
|
669
|
+
| [giveToDriver](#tag/Expeditions/paths/~1expeditions~1giveToDriver/post) | delivery<br/>pickup | inShopExpired<br/>inShop | delivered<br/>delivered | givenTo<br/>givenTo |
|
|
670
|
+
| [redirect](#tag/Expeditions/paths/~1expeditions~1redirect/post) | any | any | incoming | clear everything |
|
|
671
|
+
|
|
672
|
+
`,
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
name: 'Pods',
|
|
676
|
+
description: `Find expeditions PODS (Proof Of Delivery).`,
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
name: 'Sales representatives',
|
|
680
|
+
description: `Create and manage sales representatives.
|
|
681
|
+
|
|
682
|
+
Once created, sales representatives can be associated to parcel shops.`,
|
|
683
|
+
},
|
|
684
|
+
];
|
|
685
|
+
|
|
686
|
+
const headers = {
|
|
687
|
+
setAccessTokenCookie: {
|
|
688
|
+
schema: { type: 'string' },
|
|
689
|
+
description: 'Access token',
|
|
690
|
+
example: 'x-access-token=s%3AeyJh...; Domain=gps.gls-spain.es; Path=/; HttpOnly; Secure; SameSite=Strict',
|
|
691
|
+
},
|
|
692
|
+
setCSRFTokenCookie: {
|
|
693
|
+
schema: { type: 'string' },
|
|
694
|
+
description: 'CSRF Token',
|
|
695
|
+
example: 'x-csrf-token=s%3A%242...; Domain=gps.gls-spain.es; Path=/; Secure; SameSite=Strict',
|
|
696
|
+
},
|
|
697
|
+
clearAccessTokenCookie: {
|
|
698
|
+
schema: { type: 'string' },
|
|
699
|
+
description: 'Access token',
|
|
700
|
+
example:
|
|
701
|
+
'x-access-token=s%3AeyJh...; Domain=gps.gls-spain.es; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Secure; SameSite=Strict',
|
|
702
|
+
},
|
|
703
|
+
clearCSRFTokenCookie: {
|
|
704
|
+
schema: { type: 'string' },
|
|
705
|
+
description: 'CSRF Token',
|
|
706
|
+
example: 'x-csrf-token=s%3A%242...; Domain=gps.gls-spain.es; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Secure; SameSite=Strict',
|
|
707
|
+
},
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// noinspection JSCheckFunctionSignatures
|
|
711
|
+
const errors = {
|
|
712
|
+
badRequest: new BadRequestError(),
|
|
713
|
+
unauthorized: new UnauthorizedError('A non specific authorization error.'),
|
|
714
|
+
invalidUsernameOrPassword: new InvalidUsernameOrPasswordError('Invalid username or password.'),
|
|
715
|
+
invalidUserInCookieOrHeader: new InvalidUserInCookieOrHeaderError('Invalid user in cookie or header.'),
|
|
716
|
+
invalidCookieOrHeader: new InvalidCookieOrHeaderError('Invalid cookie or header.'),
|
|
717
|
+
missingCookieOrHeader: new MissingCookieOrHeaderError('Missing cookie or header.'),
|
|
718
|
+
forbidden: new ForbiddenError(),
|
|
719
|
+
unsupportedMediaType: new UnsupportedMediaTypeError(),
|
|
720
|
+
internalServerError: new InternalServerErrorError(),
|
|
721
|
+
databaseNotEmpty: new DatabaseNotEmptyError(),
|
|
722
|
+
userDoesNotExist: new UserDoesNotExistError(),
|
|
723
|
+
userAlreadyExists: new UserAlreadyExistsError(),
|
|
724
|
+
userCannotBeUpdated: new UserCannotBeUpdatedError(),
|
|
725
|
+
userCannotBeDeleted: new UserCannotBeDeletedError(),
|
|
726
|
+
networkDoesNotExist: new NetworkDoesNotExistError(),
|
|
727
|
+
networkAlreadyExists: new NetworkAlreadyExistsError(),
|
|
728
|
+
networkCannotBeDeleted: new NetworkCannotBeDeletedError(),
|
|
729
|
+
shopDoesNotExist: new ShopDoesNotExistError(),
|
|
730
|
+
shopAlreadyExists: new ShopAlreadyExistsError(),
|
|
731
|
+
shopCannotBeDeleted: new ShopCannotBeDeletedError(),
|
|
732
|
+
shopNotEnabled: new ShopNotEnabledError(),
|
|
733
|
+
wrongPassword: new WrongPasswordError(),
|
|
734
|
+
expeditionDoesNotExist: new ExpeditionDoesNotExistError(),
|
|
735
|
+
expeditionAlreadyExists: new ExpeditionAlreadyExistsError(),
|
|
736
|
+
expeditionCannotBeUpdated: new ExpeditionCannotBeUpdatedError(),
|
|
737
|
+
expeditionCannotBeDeleted: new ExpeditionCannotBeDeletedError(),
|
|
738
|
+
defaultsDoNotExist: new DefaultsDoNotExistError(),
|
|
739
|
+
representativeDoesNotExist: new RepresentativeDoesNotExistError(),
|
|
740
|
+
representativeAlreadyExists: new RepresentativeAlreadyExistsError(),
|
|
741
|
+
representativeCannotBeDeleted: new RepresentativeCannotBeDeletedError(),
|
|
742
|
+
zoneDoesNotExist: new ZoneDoesNotExistError(),
|
|
743
|
+
zoneAlreadyExists: new ZoneAlreadyExistsError(),
|
|
744
|
+
zoneCannotBeDeleted: new ZoneCannotBeDeletedError(),
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
const responses = {
|
|
748
|
+
badRequest: {
|
|
749
|
+
description: errors.badRequest.message,
|
|
750
|
+
content: { 'application/json': { schema: specificHttpError(errors.badRequest) } },
|
|
751
|
+
},
|
|
752
|
+
unauthorized: {
|
|
753
|
+
description: errors.unauthorized.message,
|
|
754
|
+
content: { 'application/json': { schema: specificHttpError(errors.unauthorized) } },
|
|
755
|
+
},
|
|
756
|
+
invalidUsernameOrPassword: {
|
|
757
|
+
description: errors.invalidUsernameOrPassword.message,
|
|
758
|
+
content: { 'application/json': { schema: specificHttpError(errors.invalidUsernameOrPassword) } },
|
|
759
|
+
},
|
|
760
|
+
invalidUserInCookieOrHeader: {
|
|
761
|
+
description: errors.invalidUserInCookieOrHeader.message,
|
|
762
|
+
content: { 'application/json': { schema: specificHttpError(errors.invalidUserInCookieOrHeader) } },
|
|
763
|
+
},
|
|
764
|
+
invalidCookieOrHeader: {
|
|
765
|
+
description: errors.invalidCookieOrHeader.message,
|
|
766
|
+
content: { 'application/json': { schema: specificHttpError(errors.invalidCookieOrHeader) } },
|
|
767
|
+
},
|
|
768
|
+
missingCookieOrHeader: {
|
|
769
|
+
description: errors.missingCookieOrHeader.message,
|
|
770
|
+
content: { 'application/json': { schema: specificHttpError(errors.missingCookieOrHeader) } },
|
|
771
|
+
},
|
|
772
|
+
forbidden: {
|
|
773
|
+
description: errors.forbidden.message,
|
|
774
|
+
content: { 'application/json': { schema: specificHttpError(errors.forbidden) } },
|
|
775
|
+
},
|
|
776
|
+
unsupportedMediaType: {
|
|
777
|
+
description: errors.unsupportedMediaType.message,
|
|
778
|
+
content: { 'application/json': { schema: specificHttpError(errors.unsupportedMediaType) } },
|
|
779
|
+
},
|
|
780
|
+
internalServerError: {
|
|
781
|
+
description: 'A generic error in the server.',
|
|
782
|
+
content: { 'application/json': { schema: specificHttpError(errors.internalServerError) } },
|
|
783
|
+
},
|
|
784
|
+
databaseNotEmpty: {
|
|
785
|
+
description: 'The database is not empty.',
|
|
786
|
+
content: { 'application/json': { schema: specificHttpError(errors.databaseNotEmpty) } },
|
|
787
|
+
},
|
|
788
|
+
userDoesNotExist: {
|
|
789
|
+
description: 'The user does not exist.',
|
|
790
|
+
content: { 'application/json': { schema: specificHttpError(errors.userDoesNotExist) } },
|
|
791
|
+
},
|
|
792
|
+
userAlreadyExists: {
|
|
793
|
+
description: 'The user already exists.',
|
|
794
|
+
content: { 'application/json': { schema: specificHttpError(errors.userAlreadyExists) } },
|
|
795
|
+
},
|
|
796
|
+
userCannotBeUpdated: {
|
|
797
|
+
description: 'The user cannot be updated.',
|
|
798
|
+
content: { 'application/json': { schema: specificHttpError(errors.userCannotBeUpdated) } },
|
|
799
|
+
},
|
|
800
|
+
userCannotBeDeleted: {
|
|
801
|
+
description: 'The user cannot be deleted.',
|
|
802
|
+
content: { 'application/json': { schema: specificHttpError(errors.userCannotBeDeleted) } },
|
|
803
|
+
},
|
|
804
|
+
networkDoesNotExist: {
|
|
805
|
+
description: 'The network does not exist.',
|
|
806
|
+
content: { 'application/json': { schema: specificHttpError(errors.networkDoesNotExist) } },
|
|
807
|
+
},
|
|
808
|
+
networkAlreadyExists: {
|
|
809
|
+
description: 'The network already exists.',
|
|
810
|
+
content: { 'application/json': { schema: specificHttpError(errors.networkAlreadyExists) } },
|
|
811
|
+
},
|
|
812
|
+
networkCannotBeDeleted: {
|
|
813
|
+
description: 'The network cannot be deleted.',
|
|
814
|
+
content: { 'application/json': { schema: specificHttpError(errors.networkCannotBeDeleted) } },
|
|
815
|
+
},
|
|
816
|
+
shopDoesNotExist: {
|
|
817
|
+
description: 'The shop does not exist.',
|
|
818
|
+
content: { 'application/json': { schema: specificHttpError(errors.shopDoesNotExist) } },
|
|
819
|
+
},
|
|
820
|
+
shopAlreadyExists: {
|
|
821
|
+
description: 'The shop already exists.',
|
|
822
|
+
content: { 'application/json': { schema: specificHttpError(errors.shopAlreadyExists) } },
|
|
823
|
+
},
|
|
824
|
+
shopCannotBeDeleted: {
|
|
825
|
+
description: 'The shop cannot be deleted.',
|
|
826
|
+
content: { 'application/json': { schema: specificHttpError(errors.shopCannotBeDeleted) } },
|
|
827
|
+
},
|
|
828
|
+
shopNotEnabled: {
|
|
829
|
+
description: 'The shop is not enabled.',
|
|
830
|
+
content: { 'application/json': { schema: specificHttpError(errors.shopNotEnabled) } },
|
|
831
|
+
},
|
|
832
|
+
wrongPassword: {
|
|
833
|
+
description: 'The provided password is not the right one.',
|
|
834
|
+
content: { 'application/json': { schema: specificHttpError(errors.wrongPassword) } },
|
|
835
|
+
},
|
|
836
|
+
expeditionDoesNotExist: {
|
|
837
|
+
description: 'The expedition does not exist.',
|
|
838
|
+
content: { 'application/json': { schema: specificHttpError(errors.expeditionDoesNotExist) } },
|
|
839
|
+
},
|
|
840
|
+
expeditionAlreadyExists: {
|
|
841
|
+
description: 'The expedition already exists.',
|
|
842
|
+
content: { 'application/json': { schema: specificHttpError(errors.expeditionAlreadyExists) } },
|
|
843
|
+
},
|
|
844
|
+
expeditionCannotBeUpdated: {
|
|
845
|
+
description: 'The expedition cannot be updated.',
|
|
846
|
+
content: { 'application/json': { schema: specificHttpError(errors.expeditionCannotBeUpdated) } },
|
|
847
|
+
},
|
|
848
|
+
expeditionCannotBeDeleted: {
|
|
849
|
+
description: 'The expedition cannot be deleted.',
|
|
850
|
+
content: { 'application/json': { schema: specificHttpError(errors.expeditionCannotBeDeleted) } },
|
|
851
|
+
},
|
|
852
|
+
defaultsDoNotExist: {
|
|
853
|
+
description: 'The defaults do not exist.',
|
|
854
|
+
content: { 'application/json': { schema: specificHttpError(errors.defaultsDoNotExist) } },
|
|
855
|
+
},
|
|
856
|
+
representativeDoesNotExist: {
|
|
857
|
+
description: 'The representative does not exist.',
|
|
858
|
+
content: { 'application/json': { schema: specificHttpError(errors.representativeDoesNotExist) } },
|
|
859
|
+
},
|
|
860
|
+
representativeAlreadyExists: {
|
|
861
|
+
description: 'The representative already exists.',
|
|
862
|
+
content: { 'application/json': { schema: specificHttpError(errors.representativeAlreadyExists) } },
|
|
863
|
+
},
|
|
864
|
+
representativeCannotBeDeleted: {
|
|
865
|
+
description: 'The representative cannot be deleted.',
|
|
866
|
+
content: { 'application/json': { schema: specificHttpError(errors.representativeCannotBeDeleted) } },
|
|
867
|
+
},
|
|
868
|
+
zoneDoesNotExist: {
|
|
869
|
+
description: 'The zone does not exist.',
|
|
870
|
+
content: { 'application/json': { schema: specificHttpError(errors.zoneDoesNotExist) } },
|
|
871
|
+
},
|
|
872
|
+
zoneAlreadyExists: {
|
|
873
|
+
description: 'The zone already exists.',
|
|
874
|
+
content: { 'application/json': { schema: specificHttpError(errors.zoneAlreadyExists) } },
|
|
875
|
+
},
|
|
876
|
+
zoneCannotBeDeleted: {
|
|
877
|
+
description: 'The zone cannot be deleted.',
|
|
878
|
+
content: { 'application/json': { schema: specificHttpError(errors.zoneCannotBeDeleted) } },
|
|
879
|
+
},
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
const securitySchemes = {
|
|
883
|
+
emptyDatabase: '_**Authorization required:** none, but will only work if the database is completely empty._',
|
|
884
|
+
basicAuth: '_**Authorization required:** HTTP basic auth header._',
|
|
885
|
+
tokens: '_**Authentication required:** `x-access-token` cookie and `x-csrf-token` header._',
|
|
886
|
+
superAdminRole: '_**Authorization required:** `superAdmin` role._',
|
|
887
|
+
superAdminOrNetworkAdminRole: '_**Authorization required:** `superAdmin` or `networkAdmin` role._',
|
|
888
|
+
anyRole: '_**Authorization required:** `superAdmin`, `networkAdmin` or `shopUser` role._',
|
|
889
|
+
networkAdminRole: '_**Authorization required:** `networkAdmin` role._',
|
|
890
|
+
shopUserRole: '_**Authorization required:** `shopUser` role._',
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
const descriptions = {
|
|
894
|
+
createIdIsOptional: `
|
|
895
|
+
The \`_id\` is optional and if not provided the API will create one automatically and return it in the response. Provide
|
|
896
|
+
it when you want to recover a deleted resource with the same \`_id\` it had, or when you have this resource on another
|
|
897
|
+
system and you want both systems to use the same \`_id\`.`,
|
|
898
|
+
findLimitTip: `
|
|
899
|
+
Tip: if you want to count how many there are but do not need the data itself, set limit to 0.`,
|
|
900
|
+
updateSetAddOrRemove: `
|
|
901
|
+
You can do only one of the following in a single operation:
|
|
902
|
+
- Replace properties with \`set\`.
|
|
903
|
+
- Complex properties like objects or arrays will be completely replaced.
|
|
904
|
+
- Properties that accept \`null\` can be removed by setting them to it.
|
|
905
|
+
- Add values to array properties with \`add\`.
|
|
906
|
+
- Remove values from array properties with \`remove\`.
|
|
907
|
+
|
|
908
|
+
To replace an entire array of values or rearrange their order use \`set\`.`,
|
|
909
|
+
optionalArrayPropertiesEmptyByDefault: `
|
|
910
|
+
Any optional array property that is not provided will default to an empty array.`,
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
openApiSpec.components = {
|
|
914
|
+
schemas: {
|
|
915
|
+
errorResponse: errorResponse(),
|
|
916
|
+
superAdmin: superAdmin(),
|
|
917
|
+
networkAdmin: networkAdmin(),
|
|
918
|
+
shopUser: shopUser(),
|
|
919
|
+
network: network(),
|
|
920
|
+
shop: shop(),
|
|
921
|
+
expedition: expedition(),
|
|
922
|
+
pod: pod(),
|
|
923
|
+
receiveFromDriverEvent: receiveFromDriverEvent(),
|
|
924
|
+
receiveFromCustomerEvent: receiveFromCustomerEvent(),
|
|
925
|
+
giveToCustomerEvent: giveToCustomerEvent(),
|
|
926
|
+
giveToDriverEvent: giveToDriverEvent(),
|
|
927
|
+
expirationReminderEvent: expirationReminderEvent(),
|
|
928
|
+
expiredEvent: expiredEvent(),
|
|
929
|
+
priceEvent: priceEvent(),
|
|
930
|
+
upsertShopEvent: upsertShopEvent(),
|
|
931
|
+
upsertNetworkEvent: upsertNetworkEvent(),
|
|
932
|
+
timezoneNames: timezoneNames(),
|
|
933
|
+
representative: representative(),
|
|
934
|
+
zone: zone(),
|
|
935
|
+
},
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
openApiSpec.paths = {
|
|
939
|
+
'/login': {
|
|
940
|
+
get: {
|
|
941
|
+
tags: ['Authentication'],
|
|
942
|
+
summary: '[SNU] Login',
|
|
943
|
+
description: `
|
|
944
|
+
Authenticates a user, allowing him to access the rest of the API.
|
|
945
|
+
|
|
946
|
+
Depending on the user role the response body may include additional information:
|
|
947
|
+
|
|
948
|
+
- All users will have a \`user\` field with their user information.
|
|
949
|
+
- Network admins and shop users will also have a \`network\` field with their full network information.
|
|
950
|
+
- Shop users will also have a \`shop\` field with their full shop information.
|
|
951
|
+
|
|
952
|
+
If a user references a network or shop that do not exist, the API will return a \`500 NetworkDoesNotExistError\` or a
|
|
953
|
+
\`500 ShopDoesNotExistError\`.
|
|
954
|
+
|
|
955
|
+
${securitySchemes.basicAuth}
|
|
956
|
+
${securitySchemes.anyRole}`,
|
|
957
|
+
responses: {
|
|
958
|
+
' 200': {
|
|
959
|
+
description: 'Contains the authenticated user and any additional information required.',
|
|
960
|
+
headers: {
|
|
961
|
+
'Set-Cookie': headers.setAccessTokenCookie,
|
|
962
|
+
'Set-Cookie\0': headers.setCSRFTokenCookie,
|
|
963
|
+
},
|
|
964
|
+
content: { 'application/json': { schema: loginResponse() } },
|
|
965
|
+
},
|
|
966
|
+
' 401': responses.invalidUsernameOrPassword,
|
|
967
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
968
|
+
' 500': responses.internalServerError,
|
|
969
|
+
' 500 ': responses.networkDoesNotExist,
|
|
970
|
+
' 500 ': responses.shopDoesNotExist,
|
|
971
|
+
},
|
|
972
|
+
},
|
|
973
|
+
},
|
|
974
|
+
'/logout': {
|
|
975
|
+
get: {
|
|
976
|
+
tags: ['Authentication'],
|
|
977
|
+
summary: '[SNU] Logout',
|
|
978
|
+
description: `
|
|
979
|
+
Logs out an authenticated user by clearing the authentication cookies.
|
|
980
|
+
|
|
981
|
+
The cookies are cleared by deleting their value and setting their expiration time in the past.
|
|
982
|
+
|
|
983
|
+
${securitySchemes.tokens}
|
|
984
|
+
${securitySchemes.anyRole}`,
|
|
985
|
+
responses: {
|
|
986
|
+
' 200': {
|
|
987
|
+
description: 'Acknowledgement of the log out.',
|
|
988
|
+
headers: {
|
|
989
|
+
'Set-Cookie': headers.clearAccessTokenCookie,
|
|
990
|
+
'Set-Cookie\0': headers.clearCSRFTokenCookie,
|
|
991
|
+
},
|
|
992
|
+
content: { 'application/json': { schema: logoutResponse() } },
|
|
993
|
+
},
|
|
994
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
995
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
996
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
997
|
+
' 401 ': responses.unauthorized,
|
|
998
|
+
' 500': responses.internalServerError,
|
|
999
|
+
' 500 ': responses.networkDoesNotExist,
|
|
1000
|
+
' 500 ': responses.shopDoesNotExist,
|
|
1001
|
+
},
|
|
1002
|
+
},
|
|
1003
|
+
},
|
|
1004
|
+
'/self': {
|
|
1005
|
+
get: {
|
|
1006
|
+
tags: ['Authentication'],
|
|
1007
|
+
summary: '[SNU] Self',
|
|
1008
|
+
description: `
|
|
1009
|
+
Gets the currently authenticated user and any additional information about him, just like a
|
|
1010
|
+
[login](#tag/Authentication/paths/~1login/get) would do.
|
|
1011
|
+
|
|
1012
|
+
This can be useful to refresh the user information once logged in.
|
|
1013
|
+
|
|
1014
|
+
${securitySchemes.tokens}
|
|
1015
|
+
${securitySchemes.anyRole}`,
|
|
1016
|
+
responses: {
|
|
1017
|
+
' 200': {
|
|
1018
|
+
description: 'Contains the authenticated user and any additional information required.',
|
|
1019
|
+
content: { 'application/json': { schema: loginResponse() } },
|
|
1020
|
+
},
|
|
1021
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1022
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1023
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1024
|
+
' 401 ': responses.unauthorized,
|
|
1025
|
+
' 500': responses.internalServerError,
|
|
1026
|
+
' 500 ': responses.networkDoesNotExist,
|
|
1027
|
+
' 500 ': responses.shopDoesNotExist,
|
|
1028
|
+
},
|
|
1029
|
+
},
|
|
1030
|
+
},
|
|
1031
|
+
'/become': {
|
|
1032
|
+
post: {
|
|
1033
|
+
tags: ['Authentication'],
|
|
1034
|
+
summary: '[S] Become',
|
|
1035
|
+
description: `
|
|
1036
|
+
Allows a logged in super admin to become any other user.
|
|
1037
|
+
|
|
1038
|
+
The response is exactly the same as if that user had logged in using [login](#tag/Authentication/paths/~1login/get).
|
|
1039
|
+
|
|
1040
|
+
If the user wants to go back to being the original super admin he must log in again with his super admin credentials.
|
|
1041
|
+
|
|
1042
|
+
${securitySchemes.tokens}
|
|
1043
|
+
${securitySchemes.superAdminRole}`,
|
|
1044
|
+
requestBody: {
|
|
1045
|
+
content: { 'application/json': { schema: becomeRequest() } },
|
|
1046
|
+
required: true,
|
|
1047
|
+
},
|
|
1048
|
+
responses: {
|
|
1049
|
+
' 200': {
|
|
1050
|
+
description: 'Contains the authenticated user and any additional information required.',
|
|
1051
|
+
headers: {
|
|
1052
|
+
'Set-Cookie': headers.setAccessTokenCookie,
|
|
1053
|
+
'Set-Cookie\0': headers.setCSRFTokenCookie,
|
|
1054
|
+
},
|
|
1055
|
+
content: { 'application/json': { schema: loginResponse() } },
|
|
1056
|
+
},
|
|
1057
|
+
' 400': responses.badRequest,
|
|
1058
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1059
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1060
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1061
|
+
' 401 ': responses.unauthorized,
|
|
1062
|
+
' 403': responses.forbidden,
|
|
1063
|
+
' 415': responses.unsupportedMediaType,
|
|
1064
|
+
' 500': responses.internalServerError,
|
|
1065
|
+
' 500 ': responses.userDoesNotExist,
|
|
1066
|
+
' 500 ': responses.networkDoesNotExist,
|
|
1067
|
+
' 500 ': responses.shopDoesNotExist,
|
|
1068
|
+
},
|
|
1069
|
+
},
|
|
1070
|
+
},
|
|
1071
|
+
'/help/documentation': {
|
|
1072
|
+
get: {
|
|
1073
|
+
tags: ['Documentation'],
|
|
1074
|
+
summary: '[SNU] View documentation',
|
|
1075
|
+
description: `
|
|
1076
|
+
Returns this HTML documentation.
|
|
1077
|
+
|
|
1078
|
+
If this endpoint is called from the browser and there is no HTTP basic auth header, it will ask for the username and password.
|
|
1079
|
+
|
|
1080
|
+
${securitySchemes.basicAuth}`,
|
|
1081
|
+
responses: {
|
|
1082
|
+
' 200': {
|
|
1083
|
+
description: 'This HTML documentation.',
|
|
1084
|
+
content: { 'text/html': { schema: { type: 'string' } } },
|
|
1085
|
+
},
|
|
1086
|
+
' 401': responses.invalidUsernameOrPassword,
|
|
1087
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1088
|
+
' 500': responses.internalServerError,
|
|
1089
|
+
},
|
|
1090
|
+
},
|
|
1091
|
+
},
|
|
1092
|
+
'/config/init': {
|
|
1093
|
+
post: {
|
|
1094
|
+
tags: ['Config'],
|
|
1095
|
+
summary: '[!] Init API deployment',
|
|
1096
|
+
description: `
|
|
1097
|
+
Initializes and sets up the API when deployed in a new environment.
|
|
1098
|
+
|
|
1099
|
+
This initial super admin cannot be deleted later. You can add more super admins and disable this one's login though.
|
|
1100
|
+
|
|
1101
|
+
${securitySchemes.emptyDatabase}`,
|
|
1102
|
+
requestBody: {
|
|
1103
|
+
content: { 'application/json': { schema: initRequest() } },
|
|
1104
|
+
required: true,
|
|
1105
|
+
},
|
|
1106
|
+
responses: {
|
|
1107
|
+
' 200': {
|
|
1108
|
+
description: 'Contains the created super admin and default values.',
|
|
1109
|
+
content: { 'application/json': { schema: initResponse() } },
|
|
1110
|
+
},
|
|
1111
|
+
' 400': responses.badRequest,
|
|
1112
|
+
' 415': responses.unsupportedMediaType,
|
|
1113
|
+
' 500': responses.internalServerError,
|
|
1114
|
+
' 500 ': responses.databaseNotEmpty,
|
|
1115
|
+
},
|
|
1116
|
+
},
|
|
1117
|
+
},
|
|
1118
|
+
'/config/defaults/get': {
|
|
1119
|
+
get: {
|
|
1120
|
+
tags: ['Config'],
|
|
1121
|
+
summary: '[S] Get defaults',
|
|
1122
|
+
description: `
|
|
1123
|
+
Get the default settings.
|
|
1124
|
+
|
|
1125
|
+
${securitySchemes.tokens}
|
|
1126
|
+
${securitySchemes.superAdminRole}`,
|
|
1127
|
+
responses: {
|
|
1128
|
+
' 200': {
|
|
1129
|
+
description: 'Contains the default settings.',
|
|
1130
|
+
content: { 'application/json': { schema: getDefaultsResponse() } },
|
|
1131
|
+
},
|
|
1132
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1133
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1134
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1135
|
+
' 401 ': responses.unauthorized,
|
|
1136
|
+
' 403': responses.forbidden,
|
|
1137
|
+
' 500': responses.internalServerError,
|
|
1138
|
+
' 500 ': responses.defaultsDoNotExist,
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
'/config/defaults/update': {
|
|
1143
|
+
post: {
|
|
1144
|
+
tags: ['Config'],
|
|
1145
|
+
summary: '[S] Update defaults',
|
|
1146
|
+
description: `
|
|
1147
|
+
Update the default settings.
|
|
1148
|
+
|
|
1149
|
+
The update will propagate to the \`defaults\` property of all networks and shops.
|
|
1150
|
+
|
|
1151
|
+
${securitySchemes.tokens}
|
|
1152
|
+
${securitySchemes.superAdminRole}`,
|
|
1153
|
+
requestBody: {
|
|
1154
|
+
content: { 'application/json': { schema: updateDefaultsRequest() } },
|
|
1155
|
+
required: true,
|
|
1156
|
+
},
|
|
1157
|
+
responses: {
|
|
1158
|
+
' 200': {
|
|
1159
|
+
description: 'Contains the updated default settings.',
|
|
1160
|
+
content: { 'application/json': { schema: updateDefaultsResponse() } },
|
|
1161
|
+
},
|
|
1162
|
+
' 400': responses.badRequest,
|
|
1163
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1164
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1165
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1166
|
+
' 401 ': responses.unauthorized,
|
|
1167
|
+
' 403': responses.forbidden,
|
|
1168
|
+
' 415': responses.unsupportedMediaType,
|
|
1169
|
+
' 500': responses.internalServerError,
|
|
1170
|
+
' 500 ': responses.defaultsDoNotExist,
|
|
1171
|
+
},
|
|
1172
|
+
},
|
|
1173
|
+
},
|
|
1174
|
+
'/jobs/findNetworks': {
|
|
1175
|
+
post: {
|
|
1176
|
+
tags: ['Background jobs'],
|
|
1177
|
+
summary: '[S] Find network jobs',
|
|
1178
|
+
description: `
|
|
1179
|
+
Finds the status of background jobs related to networks.
|
|
1180
|
+
|
|
1181
|
+
The \`payload\` property of the job contains the created or updated network.
|
|
1182
|
+
|
|
1183
|
+
${securitySchemes.tokens}
|
|
1184
|
+
${securitySchemes.superAdminRole}`,
|
|
1185
|
+
requestBody: {
|
|
1186
|
+
content: { 'application/json': { schema: findJobsRequest() } },
|
|
1187
|
+
required: true,
|
|
1188
|
+
},
|
|
1189
|
+
responses: {
|
|
1190
|
+
' 200': {
|
|
1191
|
+
description: 'Contains the found jobs.',
|
|
1192
|
+
content: { 'application/json': { schema: findNetworksJobsResponse() } },
|
|
1193
|
+
},
|
|
1194
|
+
' 400': responses.badRequest,
|
|
1195
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1196
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1197
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1198
|
+
' 401 ': responses.unauthorized,
|
|
1199
|
+
' 403': responses.forbidden,
|
|
1200
|
+
' 415': responses.unsupportedMediaType,
|
|
1201
|
+
' 500': responses.internalServerError,
|
|
1202
|
+
},
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
'/jobs/findShops': {
|
|
1206
|
+
post: {
|
|
1207
|
+
tags: ['Background jobs'],
|
|
1208
|
+
summary: '[S] Find shop jobs',
|
|
1209
|
+
description: `
|
|
1210
|
+
Finds the status of background jobs related to shops.
|
|
1211
|
+
|
|
1212
|
+
The \`payload\` property of the job contains the created or updated shop.
|
|
1213
|
+
|
|
1214
|
+
${securitySchemes.tokens}
|
|
1215
|
+
${securitySchemes.superAdminRole}`,
|
|
1216
|
+
requestBody: {
|
|
1217
|
+
content: { 'application/json': { schema: findJobsRequest() } },
|
|
1218
|
+
required: true,
|
|
1219
|
+
},
|
|
1220
|
+
responses: {
|
|
1221
|
+
' 200': {
|
|
1222
|
+
description: 'Contains the found jobs.',
|
|
1223
|
+
content: { 'application/json': { schema: findShopsJobsResponse() } },
|
|
1224
|
+
},
|
|
1225
|
+
' 400': responses.badRequest,
|
|
1226
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1227
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1228
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1229
|
+
' 401 ': responses.unauthorized,
|
|
1230
|
+
' 403': responses.forbidden,
|
|
1231
|
+
' 415': responses.unsupportedMediaType,
|
|
1232
|
+
' 500': responses.internalServerError,
|
|
1233
|
+
},
|
|
1234
|
+
},
|
|
1235
|
+
},
|
|
1236
|
+
'/jobs/findExpeditions': {
|
|
1237
|
+
post: {
|
|
1238
|
+
tags: ['Background jobs'],
|
|
1239
|
+
summary: '[S] Find expedition jobs',
|
|
1240
|
+
description: `
|
|
1241
|
+
Finds the status of background jobs related to expeditions.
|
|
1242
|
+
|
|
1243
|
+
The \`payload\` property of the job contains the \`_id\` of the affected expedition and an additional property that depends on the kind of job:
|
|
1244
|
+
|
|
1245
|
+
| Payload property | Type of job | Source |
|
|
1246
|
+
| :--- | :--- | :--- |
|
|
1247
|
+
| receiveFromDriver | An expedition has been received from a driver | Request to [receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) |
|
|
1248
|
+
| receiveFromCustomer | An expedition has been received from a customer | Request to [receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post) |
|
|
1249
|
+
| giveToCustomer | An expedition has been given to the customer | Request to [giveToCustomer](#tag/Expeditions/paths/~1expeditions~1giveToCustomer/post) |
|
|
1250
|
+
| giveToDriver | An expedition has been given to the driver | Request to [giveToDriver](#tag/Expeditions/paths/~1expeditions~1giveToDriver/post) |
|
|
1251
|
+
| expirationReminder | A reminder to pickup an expedition needs to be sent | Daily background check for expiration reminders |
|
|
1252
|
+
| expired | An expedition has expired and needs to be retired by the driver | Daily background check for expired expeditions |
|
|
1253
|
+
| price | An expedition price has been calculated or has changed | Request to [receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post), [receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post), or [update](#tag/Expeditions/paths/~1expeditions~1update/post) |
|
|
1254
|
+
|
|
1255
|
+
${securitySchemes.tokens}
|
|
1256
|
+
${securitySchemes.superAdminRole}`,
|
|
1257
|
+
requestBody: {
|
|
1258
|
+
content: { 'application/json': { schema: findJobsRequest() } },
|
|
1259
|
+
required: true,
|
|
1260
|
+
},
|
|
1261
|
+
responses: {
|
|
1262
|
+
' 200': {
|
|
1263
|
+
description: 'Contains the found jobs.',
|
|
1264
|
+
content: { 'application/json': { schema: findExpeditionJobsResponse() } },
|
|
1265
|
+
},
|
|
1266
|
+
' 400': responses.badRequest,
|
|
1267
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1268
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1269
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1270
|
+
' 401 ': responses.unauthorized,
|
|
1271
|
+
' 403': responses.forbidden,
|
|
1272
|
+
' 415': responses.unsupportedMediaType,
|
|
1273
|
+
' 500': responses.internalServerError,
|
|
1274
|
+
},
|
|
1275
|
+
},
|
|
1276
|
+
},
|
|
1277
|
+
'/superAdmins/create': {
|
|
1278
|
+
post: {
|
|
1279
|
+
tags: ['Super admins'],
|
|
1280
|
+
summary: '[S] Create',
|
|
1281
|
+
description: `
|
|
1282
|
+
Creates a new super admin.
|
|
1283
|
+
|
|
1284
|
+
${descriptions.createIdIsOptional}
|
|
1285
|
+
|
|
1286
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
1287
|
+
|
|
1288
|
+
The only value in the \`integrations\` property applicable to super admins is \`glsApi\`, as explained in the [GLS integration](#tag/GLS)
|
|
1289
|
+
section.
|
|
1290
|
+
|
|
1291
|
+
${securitySchemes.tokens}
|
|
1292
|
+
${securitySchemes.superAdminRole}`,
|
|
1293
|
+
requestBody: {
|
|
1294
|
+
content: { 'application/json': { schema: createSuperAdminRequest() } },
|
|
1295
|
+
required: true,
|
|
1296
|
+
},
|
|
1297
|
+
responses: {
|
|
1298
|
+
' 200': {
|
|
1299
|
+
description: 'Contains the created super admin.',
|
|
1300
|
+
content: { 'application/json': { schema: createSuperAdminResponse() } },
|
|
1301
|
+
},
|
|
1302
|
+
' 400': responses.badRequest,
|
|
1303
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1304
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1305
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1306
|
+
' 401 ': responses.unauthorized,
|
|
1307
|
+
' 403': responses.forbidden,
|
|
1308
|
+
' 415': responses.unsupportedMediaType,
|
|
1309
|
+
' 500': responses.internalServerError,
|
|
1310
|
+
' 500 ': responses.userAlreadyExists,
|
|
1311
|
+
},
|
|
1312
|
+
},
|
|
1313
|
+
},
|
|
1314
|
+
'/superAdmins/find': {
|
|
1315
|
+
post: {
|
|
1316
|
+
tags: ['Super admins'],
|
|
1317
|
+
summary: '[S] Find',
|
|
1318
|
+
description: `
|
|
1319
|
+
Finds super admins by one of several filters.
|
|
1320
|
+
|
|
1321
|
+
${descriptions.findLimitTip}
|
|
1322
|
+
|
|
1323
|
+
${securitySchemes.tokens}
|
|
1324
|
+
${securitySchemes.superAdminRole}`,
|
|
1325
|
+
requestBody: {
|
|
1326
|
+
content: { 'application/json': { schema: findSuperAdminsRequest() } },
|
|
1327
|
+
required: true,
|
|
1328
|
+
},
|
|
1329
|
+
responses: {
|
|
1330
|
+
' 200': {
|
|
1331
|
+
description: 'Contains the found super admins.',
|
|
1332
|
+
content: { 'application/json': { schema: findSuperAdminsResponse() } },
|
|
1333
|
+
},
|
|
1334
|
+
' 400': responses.badRequest,
|
|
1335
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1336
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1337
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1338
|
+
' 401 ': responses.unauthorized,
|
|
1339
|
+
' 403': responses.forbidden,
|
|
1340
|
+
' 415': responses.unsupportedMediaType,
|
|
1341
|
+
' 500': responses.internalServerError,
|
|
1342
|
+
},
|
|
1343
|
+
},
|
|
1344
|
+
},
|
|
1345
|
+
'/superAdmins/update': {
|
|
1346
|
+
post: {
|
|
1347
|
+
tags: ['Super admins'],
|
|
1348
|
+
summary: '[S] Update',
|
|
1349
|
+
description: `
|
|
1350
|
+
Finds a super admin and updates the provided properties.
|
|
1351
|
+
|
|
1352
|
+
${descriptions.updateSetAddOrRemove}
|
|
1353
|
+
|
|
1354
|
+
A super admin that tries to set \`loginEnabled\` to \`false\` on himself will receive a \`500 UserCannotBeUpdatedError\`.
|
|
1355
|
+
This is to prevent situations where there is no super admin left that can login.
|
|
1356
|
+
|
|
1357
|
+
${securitySchemes.tokens}
|
|
1358
|
+
${securitySchemes.superAdminRole}`,
|
|
1359
|
+
requestBody: {
|
|
1360
|
+
content: { 'application/json': { schema: updateSuperAdminRequest() } },
|
|
1361
|
+
required: true,
|
|
1362
|
+
},
|
|
1363
|
+
responses: {
|
|
1364
|
+
' 200': {
|
|
1365
|
+
description: 'Contains the updated super admin.',
|
|
1366
|
+
content: { 'application/json': { schema: updateSuperAdminResponse() } },
|
|
1367
|
+
},
|
|
1368
|
+
' 400': responses.badRequest,
|
|
1369
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1370
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1371
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1372
|
+
' 401 ': responses.unauthorized,
|
|
1373
|
+
' 403': responses.forbidden,
|
|
1374
|
+
' 415': responses.unsupportedMediaType,
|
|
1375
|
+
' 500': responses.internalServerError,
|
|
1376
|
+
' 500 ': responses.userDoesNotExist,
|
|
1377
|
+
' 500 ': responses.userCannotBeUpdated,
|
|
1378
|
+
},
|
|
1379
|
+
},
|
|
1380
|
+
},
|
|
1381
|
+
'/superAdmins/delete': {
|
|
1382
|
+
post: {
|
|
1383
|
+
tags: ['Super admins'],
|
|
1384
|
+
summary: '[S] Delete',
|
|
1385
|
+
description: `
|
|
1386
|
+
Deletes a super admin.
|
|
1387
|
+
|
|
1388
|
+
A super admin cannot be deleted in certain situations:
|
|
1389
|
+
|
|
1390
|
+
- A super admin cannot delete himself.
|
|
1391
|
+
- The initial super admin created along the database cannot be deleted.
|
|
1392
|
+
|
|
1393
|
+
In these cases the API will return a \`500 UserCannotBeDeletedError\`.
|
|
1394
|
+
|
|
1395
|
+
${securitySchemes.tokens}
|
|
1396
|
+
${securitySchemes.superAdminRole}`,
|
|
1397
|
+
requestBody: {
|
|
1398
|
+
content: { 'application/json': { schema: deleteSuperAdminRequest() } },
|
|
1399
|
+
required: true,
|
|
1400
|
+
},
|
|
1401
|
+
responses: {
|
|
1402
|
+
' 200': {
|
|
1403
|
+
description: 'Contains the deleted super admin.',
|
|
1404
|
+
content: { 'application/json': { schema: deleteSuperAdminResponse() } },
|
|
1405
|
+
},
|
|
1406
|
+
' 400': responses.badRequest,
|
|
1407
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1408
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1409
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1410
|
+
' 401 ': responses.unauthorized,
|
|
1411
|
+
' 403': responses.forbidden,
|
|
1412
|
+
' 415': responses.unsupportedMediaType,
|
|
1413
|
+
' 500': responses.internalServerError,
|
|
1414
|
+
' 500 ': responses.userDoesNotExist,
|
|
1415
|
+
' 500 ': responses.userCannotBeDeleted,
|
|
1416
|
+
},
|
|
1417
|
+
},
|
|
1418
|
+
},
|
|
1419
|
+
'/networks/create': {
|
|
1420
|
+
post: {
|
|
1421
|
+
tags: ['Networks'],
|
|
1422
|
+
summary: '[S] Create',
|
|
1423
|
+
description: `
|
|
1424
|
+
Creates a new network.
|
|
1425
|
+
|
|
1426
|
+
${descriptions.createIdIsOptional}
|
|
1427
|
+
|
|
1428
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
1429
|
+
|
|
1430
|
+
To set custom \`derivationSettings\` and \`expirationSettings\` provide theses properties, or do not provide them and the values under the
|
|
1431
|
+
\`defaults\` property will be used.
|
|
1432
|
+
|
|
1433
|
+
See the [GLS integration](#tag/GLS) section for more information about the \`integrations\` property.
|
|
1434
|
+
|
|
1435
|
+
${securitySchemes.tokens}
|
|
1436
|
+
${securitySchemes.superAdminRole}`,
|
|
1437
|
+
requestBody: {
|
|
1438
|
+
content: { 'application/json': { schema: createNetworkRequest() } },
|
|
1439
|
+
required: true,
|
|
1440
|
+
},
|
|
1441
|
+
responses: {
|
|
1442
|
+
' 200': {
|
|
1443
|
+
description: 'Contains the created network.',
|
|
1444
|
+
content: { 'application/json': { schema: createNetworkResponse() } },
|
|
1445
|
+
},
|
|
1446
|
+
' 400': responses.badRequest,
|
|
1447
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1448
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1449
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1450
|
+
' 401 ': responses.unauthorized,
|
|
1451
|
+
' 403': responses.forbidden,
|
|
1452
|
+
' 415': responses.unsupportedMediaType,
|
|
1453
|
+
' 500': responses.internalServerError,
|
|
1454
|
+
' 500 ': responses.networkAlreadyExists,
|
|
1455
|
+
},
|
|
1456
|
+
},
|
|
1457
|
+
},
|
|
1458
|
+
'/networks/listNames': {
|
|
1459
|
+
get: {
|
|
1460
|
+
tags: ['Networks'],
|
|
1461
|
+
summary: '[S] List names',
|
|
1462
|
+
description: `
|
|
1463
|
+
Finds networks and returns only the \`_id\` and \`name\` properties for each one.
|
|
1464
|
+
|
|
1465
|
+
${securitySchemes.tokens}
|
|
1466
|
+
${securitySchemes.superAdminRole}`,
|
|
1467
|
+
responses: {
|
|
1468
|
+
' 200': {
|
|
1469
|
+
description: 'Contains the found networks names.',
|
|
1470
|
+
content: { 'application/json': { schema: listNetworksNamesResponse() } },
|
|
1471
|
+
},
|
|
1472
|
+
' 400': responses.badRequest,
|
|
1473
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1474
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1475
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1476
|
+
' 401 ': responses.unauthorized,
|
|
1477
|
+
' 403': responses.forbidden,
|
|
1478
|
+
' 415': responses.unsupportedMediaType,
|
|
1479
|
+
' 500': responses.internalServerError,
|
|
1480
|
+
},
|
|
1481
|
+
},
|
|
1482
|
+
},
|
|
1483
|
+
'/networks/find': {
|
|
1484
|
+
post: {
|
|
1485
|
+
tags: ['Networks'],
|
|
1486
|
+
summary: '[S] Find',
|
|
1487
|
+
description: `
|
|
1488
|
+
Finds networks by one of several filters.
|
|
1489
|
+
|
|
1490
|
+
${descriptions.findLimitTip}
|
|
1491
|
+
|
|
1492
|
+
${securitySchemes.tokens}
|
|
1493
|
+
${securitySchemes.superAdminRole}`,
|
|
1494
|
+
requestBody: {
|
|
1495
|
+
content: { 'application/json': { schema: findNetworksRequest() } },
|
|
1496
|
+
required: true,
|
|
1497
|
+
},
|
|
1498
|
+
responses: {
|
|
1499
|
+
' 200': {
|
|
1500
|
+
description: 'Contains the found networks.',
|
|
1501
|
+
content: { 'application/json': { schema: findNetworksResponse() } },
|
|
1502
|
+
},
|
|
1503
|
+
' 400': responses.badRequest,
|
|
1504
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1505
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1506
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1507
|
+
' 401 ': responses.unauthorized,
|
|
1508
|
+
' 403': responses.forbidden,
|
|
1509
|
+
' 415': responses.unsupportedMediaType,
|
|
1510
|
+
' 500': responses.internalServerError,
|
|
1511
|
+
},
|
|
1512
|
+
},
|
|
1513
|
+
},
|
|
1514
|
+
'/networks/update': {
|
|
1515
|
+
post: {
|
|
1516
|
+
tags: ['Networks'],
|
|
1517
|
+
summary: '[S] Update',
|
|
1518
|
+
description: `
|
|
1519
|
+
Finds a network and updates the provided properties.
|
|
1520
|
+
|
|
1521
|
+
${descriptions.updateSetAddOrRemove}
|
|
1522
|
+
|
|
1523
|
+
The \`derivationSettings\` and \`expirationSettings\` properties can be updated with a value or with \`null\`, which will remove them. The
|
|
1524
|
+
update will propagate to the \`network\` property of all the shops in the network.
|
|
1525
|
+
|
|
1526
|
+
${securitySchemes.tokens}
|
|
1527
|
+
${securitySchemes.superAdminRole}`,
|
|
1528
|
+
requestBody: {
|
|
1529
|
+
content: { 'application/json': { schema: updateNetworkRequest() } },
|
|
1530
|
+
required: true,
|
|
1531
|
+
},
|
|
1532
|
+
responses: {
|
|
1533
|
+
' 200': {
|
|
1534
|
+
description: 'Contains the updated network.',
|
|
1535
|
+
content: { 'application/json': { schema: updateNetworkResponse() } },
|
|
1536
|
+
},
|
|
1537
|
+
' 400': responses.badRequest,
|
|
1538
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1539
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1540
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1541
|
+
' 401 ': responses.unauthorized,
|
|
1542
|
+
' 403': responses.forbidden,
|
|
1543
|
+
' 415': responses.unsupportedMediaType,
|
|
1544
|
+
' 500': responses.internalServerError,
|
|
1545
|
+
' 500 ': responses.networkDoesNotExist,
|
|
1546
|
+
},
|
|
1547
|
+
},
|
|
1548
|
+
},
|
|
1549
|
+
'/networks/delete': {
|
|
1550
|
+
post: {
|
|
1551
|
+
tags: ['Networks'],
|
|
1552
|
+
summary: '[S] Delete',
|
|
1553
|
+
description: `
|
|
1554
|
+
Deletes a network.
|
|
1555
|
+
|
|
1556
|
+
A network whose \`deletable\` property is \`false\` cannot be deleted because it has admins or shops associated to it.
|
|
1557
|
+
If you try the API will return a \`500 NetworkCannotBeDeletedError\`.
|
|
1558
|
+
|
|
1559
|
+
${securitySchemes.tokens}
|
|
1560
|
+
${securitySchemes.superAdminRole}`,
|
|
1561
|
+
requestBody: {
|
|
1562
|
+
content: { 'application/json': { schema: deleteNetworkRequest() } },
|
|
1563
|
+
required: true,
|
|
1564
|
+
},
|
|
1565
|
+
responses: {
|
|
1566
|
+
' 200': {
|
|
1567
|
+
description: 'Contains the deleted network.',
|
|
1568
|
+
content: { 'application/json': { schema: deleteNetworkResponse() } },
|
|
1569
|
+
},
|
|
1570
|
+
' 400': responses.badRequest,
|
|
1571
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1572
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1573
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1574
|
+
' 401 ': responses.unauthorized,
|
|
1575
|
+
' 403': responses.forbidden,
|
|
1576
|
+
' 415': responses.unsupportedMediaType,
|
|
1577
|
+
' 500': responses.internalServerError,
|
|
1578
|
+
' 500 ': responses.networkDoesNotExist,
|
|
1579
|
+
' 500 ': responses.networkCannotBeDeleted,
|
|
1580
|
+
},
|
|
1581
|
+
},
|
|
1582
|
+
},
|
|
1583
|
+
'/networkAdmins/create': {
|
|
1584
|
+
post: {
|
|
1585
|
+
tags: ['Network admins'],
|
|
1586
|
+
summary: '[S] Create',
|
|
1587
|
+
description: `
|
|
1588
|
+
Creates a new network admin.
|
|
1589
|
+
|
|
1590
|
+
${descriptions.createIdIsOptional}
|
|
1591
|
+
|
|
1592
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
1593
|
+
|
|
1594
|
+
The \`network._id\` property that associates a network admin with his network cannot be changed after creation.
|
|
1595
|
+
If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
|
|
1596
|
+
|
|
1597
|
+
The \`integrations\` property is not used yet for network admins, leave it empty for now.
|
|
1598
|
+
|
|
1599
|
+
${securitySchemes.tokens}
|
|
1600
|
+
${securitySchemes.superAdminRole}`,
|
|
1601
|
+
requestBody: {
|
|
1602
|
+
content: { 'application/json': { schema: createNetworkAdminRequest() } },
|
|
1603
|
+
required: true,
|
|
1604
|
+
},
|
|
1605
|
+
responses: {
|
|
1606
|
+
' 200': {
|
|
1607
|
+
description: 'Contains the created network admin.',
|
|
1608
|
+
content: { 'application/json': { schema: createNetworkAdminResponse() } },
|
|
1609
|
+
},
|
|
1610
|
+
' 400': responses.badRequest,
|
|
1611
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1612
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1613
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1614
|
+
' 401 ': responses.unauthorized,
|
|
1615
|
+
' 403': responses.forbidden,
|
|
1616
|
+
' 415': responses.unsupportedMediaType,
|
|
1617
|
+
' 500': responses.internalServerError,
|
|
1618
|
+
' 500 ': responses.userAlreadyExists,
|
|
1619
|
+
' 500 ': responses.networkDoesNotExist,
|
|
1620
|
+
},
|
|
1621
|
+
},
|
|
1622
|
+
},
|
|
1623
|
+
'/networkAdmins/find': {
|
|
1624
|
+
post: {
|
|
1625
|
+
tags: ['Network admins'],
|
|
1626
|
+
summary: '[S] Find',
|
|
1627
|
+
description: `
|
|
1628
|
+
Finds network admins by one of several filters.
|
|
1629
|
+
|
|
1630
|
+
${descriptions.findLimitTip}
|
|
1631
|
+
|
|
1632
|
+
${securitySchemes.tokens}
|
|
1633
|
+
${securitySchemes.superAdminRole}`,
|
|
1634
|
+
requestBody: {
|
|
1635
|
+
content: { 'application/json': { schema: findNetworkAdminsRequest() } },
|
|
1636
|
+
required: true,
|
|
1637
|
+
},
|
|
1638
|
+
responses: {
|
|
1639
|
+
' 200': {
|
|
1640
|
+
description: 'Contains the found network admins.',
|
|
1641
|
+
content: { 'application/json': { schema: findNetworkAdminsResponse() } },
|
|
1642
|
+
},
|
|
1643
|
+
' 400': responses.badRequest,
|
|
1644
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1645
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1646
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1647
|
+
' 401 ': responses.unauthorized,
|
|
1648
|
+
' 403': responses.forbidden,
|
|
1649
|
+
' 415': responses.unsupportedMediaType,
|
|
1650
|
+
' 500': responses.internalServerError,
|
|
1651
|
+
},
|
|
1652
|
+
},
|
|
1653
|
+
},
|
|
1654
|
+
'/networkAdmins/update': {
|
|
1655
|
+
post: {
|
|
1656
|
+
tags: ['Network admins'],
|
|
1657
|
+
summary: '[S] Update',
|
|
1658
|
+
description: `
|
|
1659
|
+
Finds a network admin and updates the provided properties.
|
|
1660
|
+
|
|
1661
|
+
${descriptions.updateSetAddOrRemove}
|
|
1662
|
+
|
|
1663
|
+
${securitySchemes.tokens}
|
|
1664
|
+
${securitySchemes.superAdminRole}`,
|
|
1665
|
+
requestBody: {
|
|
1666
|
+
content: { 'application/json': { schema: updateNetworkAdminRequest() } },
|
|
1667
|
+
required: true,
|
|
1668
|
+
},
|
|
1669
|
+
responses: {
|
|
1670
|
+
' 200': {
|
|
1671
|
+
description: 'Contains the updated network admin.',
|
|
1672
|
+
content: { 'application/json': { schema: updateNetworkAdminResponse() } },
|
|
1673
|
+
},
|
|
1674
|
+
' 400': responses.badRequest,
|
|
1675
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1676
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1677
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1678
|
+
' 401 ': responses.unauthorized,
|
|
1679
|
+
' 403': responses.forbidden,
|
|
1680
|
+
' 415': responses.unsupportedMediaType,
|
|
1681
|
+
' 500': responses.internalServerError,
|
|
1682
|
+
' 500 ': responses.userDoesNotExist,
|
|
1683
|
+
},
|
|
1684
|
+
},
|
|
1685
|
+
},
|
|
1686
|
+
'/networkAdmins/updateSelf': {
|
|
1687
|
+
post: {
|
|
1688
|
+
tags: ['Network admins'],
|
|
1689
|
+
summary: '[N] Update self',
|
|
1690
|
+
description: `
|
|
1691
|
+
A network admin updates himself.
|
|
1692
|
+
|
|
1693
|
+
${descriptions.updateSetAddOrRemove}
|
|
1694
|
+
|
|
1695
|
+
If a network admin tries to update his password and the old password does not match, the API will return a \`500 WrongPasswordError\`.
|
|
1696
|
+
|
|
1697
|
+
${securitySchemes.tokens}
|
|
1698
|
+
${securitySchemes.networkAdminRole}`,
|
|
1699
|
+
requestBody: {
|
|
1700
|
+
content: { 'application/json': { schema: updateSelfNetworkAdminRequest() } },
|
|
1701
|
+
required: true,
|
|
1702
|
+
},
|
|
1703
|
+
responses: {
|
|
1704
|
+
' 200': {
|
|
1705
|
+
description: 'Contains the updated network admin.',
|
|
1706
|
+
content: { 'application/json': { schema: updateNetworkAdminResponse() } },
|
|
1707
|
+
},
|
|
1708
|
+
' 400': responses.badRequest,
|
|
1709
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1710
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1711
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1712
|
+
' 401 ': responses.unauthorized,
|
|
1713
|
+
' 403': responses.forbidden,
|
|
1714
|
+
' 415': responses.unsupportedMediaType,
|
|
1715
|
+
' 500': responses.internalServerError,
|
|
1716
|
+
' 500 ': responses.userDoesNotExist,
|
|
1717
|
+
' 500 ': responses.wrongPassword,
|
|
1718
|
+
},
|
|
1719
|
+
},
|
|
1720
|
+
},
|
|
1721
|
+
'/networkAdmins/delete': {
|
|
1722
|
+
post: {
|
|
1723
|
+
tags: ['Network admins'],
|
|
1724
|
+
summary: '[S] Delete',
|
|
1725
|
+
description: `
|
|
1726
|
+
Deletes a network admin.
|
|
1727
|
+
|
|
1728
|
+
${securitySchemes.tokens}
|
|
1729
|
+
${securitySchemes.superAdminRole}`,
|
|
1730
|
+
requestBody: {
|
|
1731
|
+
content: { 'application/json': { schema: deleteNetworkAdminRequest() } },
|
|
1732
|
+
required: true,
|
|
1733
|
+
},
|
|
1734
|
+
responses: {
|
|
1735
|
+
' 200': {
|
|
1736
|
+
description: 'Contains the deleted network admin.',
|
|
1737
|
+
content: { 'application/json': { schema: deleteNetworkAdminResponse() } },
|
|
1738
|
+
},
|
|
1739
|
+
' 400': responses.badRequest,
|
|
1740
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1741
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1742
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1743
|
+
' 401 ': responses.unauthorized,
|
|
1744
|
+
' 403': responses.forbidden,
|
|
1745
|
+
' 415': responses.unsupportedMediaType,
|
|
1746
|
+
' 500': responses.internalServerError,
|
|
1747
|
+
' 500 ': responses.userDoesNotExist,
|
|
1748
|
+
},
|
|
1749
|
+
},
|
|
1750
|
+
},
|
|
1751
|
+
'/zones/create': {
|
|
1752
|
+
post: {
|
|
1753
|
+
tags: ['Zones'],
|
|
1754
|
+
summary: '[S] Create',
|
|
1755
|
+
description: `
|
|
1756
|
+
Creates a new zone.
|
|
1757
|
+
|
|
1758
|
+
${descriptions.createIdIsOptional}
|
|
1759
|
+
|
|
1760
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
1761
|
+
|
|
1762
|
+
${securitySchemes.tokens}
|
|
1763
|
+
${securitySchemes.superAdminRole}`,
|
|
1764
|
+
requestBody: {
|
|
1765
|
+
content: { 'application/json': { schema: createZoneRequest() } },
|
|
1766
|
+
required: true,
|
|
1767
|
+
},
|
|
1768
|
+
responses: {
|
|
1769
|
+
' 200': {
|
|
1770
|
+
description: 'Contains the created zone.',
|
|
1771
|
+
content: { 'application/json': { schema: createZoneResponse() } },
|
|
1772
|
+
},
|
|
1773
|
+
' 400': responses.badRequest,
|
|
1774
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1775
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1776
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1777
|
+
' 401 ': responses.unauthorized,
|
|
1778
|
+
' 403': responses.forbidden,
|
|
1779
|
+
' 415': responses.unsupportedMediaType,
|
|
1780
|
+
' 500': responses.internalServerError,
|
|
1781
|
+
' 500 ': responses.zoneAlreadyExists,
|
|
1782
|
+
},
|
|
1783
|
+
},
|
|
1784
|
+
},
|
|
1785
|
+
'/zones/listNames': {
|
|
1786
|
+
get: {
|
|
1787
|
+
tags: ['Zones'],
|
|
1788
|
+
summary: '[S] List names',
|
|
1789
|
+
description: `
|
|
1790
|
+
Finds zones and returns only the \`_id\` and \`name\` properties for each one.
|
|
1791
|
+
|
|
1792
|
+
${securitySchemes.tokens}
|
|
1793
|
+
${securitySchemes.superAdminRole}`,
|
|
1794
|
+
responses: {
|
|
1795
|
+
' 200': {
|
|
1796
|
+
description: 'Contains the found zones names.',
|
|
1797
|
+
content: { 'application/json': { schema: listZonesNamesResponse() } },
|
|
1798
|
+
},
|
|
1799
|
+
' 400': responses.badRequest,
|
|
1800
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1801
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1802
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1803
|
+
' 401 ': responses.unauthorized,
|
|
1804
|
+
' 403': responses.forbidden,
|
|
1805
|
+
' 415': responses.unsupportedMediaType,
|
|
1806
|
+
' 500': responses.internalServerError,
|
|
1807
|
+
},
|
|
1808
|
+
},
|
|
1809
|
+
},
|
|
1810
|
+
'/zones/find': {
|
|
1811
|
+
post: {
|
|
1812
|
+
tags: ['Zones'],
|
|
1813
|
+
summary: '[S] Find',
|
|
1814
|
+
description: `
|
|
1815
|
+
Finds zones by one of several filters.
|
|
1816
|
+
|
|
1817
|
+
${descriptions.findLimitTip}
|
|
1818
|
+
|
|
1819
|
+
${securitySchemes.tokens}
|
|
1820
|
+
${securitySchemes.superAdminRole}`,
|
|
1821
|
+
requestBody: {
|
|
1822
|
+
content: { 'application/json': { schema: findZonesRequest() } },
|
|
1823
|
+
required: true,
|
|
1824
|
+
},
|
|
1825
|
+
responses: {
|
|
1826
|
+
' 200': {
|
|
1827
|
+
description: 'Contains the found zones.',
|
|
1828
|
+
content: { 'application/json': { schema: findZonesResponse() } },
|
|
1829
|
+
},
|
|
1830
|
+
' 400': responses.badRequest,
|
|
1831
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1832
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1833
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1834
|
+
' 401 ': responses.unauthorized,
|
|
1835
|
+
' 403': responses.forbidden,
|
|
1836
|
+
' 415': responses.unsupportedMediaType,
|
|
1837
|
+
' 500': responses.internalServerError,
|
|
1838
|
+
},
|
|
1839
|
+
},
|
|
1840
|
+
},
|
|
1841
|
+
'/zones/update': {
|
|
1842
|
+
post: {
|
|
1843
|
+
tags: ['Zones'],
|
|
1844
|
+
summary: '[S] Update',
|
|
1845
|
+
description: `
|
|
1846
|
+
Finds a zone and updates the provided properties.
|
|
1847
|
+
|
|
1848
|
+
${securitySchemes.tokens}
|
|
1849
|
+
${securitySchemes.superAdminRole}`,
|
|
1850
|
+
requestBody: {
|
|
1851
|
+
content: { 'application/json': { schema: updateZoneRequest() } },
|
|
1852
|
+
required: true,
|
|
1853
|
+
},
|
|
1854
|
+
responses: {
|
|
1855
|
+
' 200': {
|
|
1856
|
+
description: 'Contains the updated zone.',
|
|
1857
|
+
content: { 'application/json': { schema: updateZoneResponse() } },
|
|
1858
|
+
},
|
|
1859
|
+
' 400': responses.badRequest,
|
|
1860
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1861
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1862
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1863
|
+
' 401 ': responses.unauthorized,
|
|
1864
|
+
' 403': responses.forbidden,
|
|
1865
|
+
' 415': responses.unsupportedMediaType,
|
|
1866
|
+
' 500': responses.internalServerError,
|
|
1867
|
+
' 500 ': responses.zoneDoesNotExist,
|
|
1868
|
+
},
|
|
1869
|
+
},
|
|
1870
|
+
},
|
|
1871
|
+
'/zones/delete': {
|
|
1872
|
+
post: {
|
|
1873
|
+
tags: ['Zones'],
|
|
1874
|
+
summary: '[S] Delete',
|
|
1875
|
+
description: `
|
|
1876
|
+
Deletes a zone.
|
|
1877
|
+
|
|
1878
|
+
A zone whose \`deletable\` property is \`false\` cannot be deleted because it has shops or sales representatives associated to it.
|
|
1879
|
+
If you try the API will return a \`500 ZoneCannotBeDeletedError\`.
|
|
1880
|
+
|
|
1881
|
+
${securitySchemes.tokens}
|
|
1882
|
+
${securitySchemes.superAdminRole}`,
|
|
1883
|
+
requestBody: {
|
|
1884
|
+
content: { 'application/json': { schema: deleteZoneRequest() } },
|
|
1885
|
+
required: true,
|
|
1886
|
+
},
|
|
1887
|
+
responses: {
|
|
1888
|
+
' 200': {
|
|
1889
|
+
description: 'Contains the deleted zone.',
|
|
1890
|
+
content: { 'application/json': { schema: deleteZoneResponse() } },
|
|
1891
|
+
},
|
|
1892
|
+
' 400': responses.badRequest,
|
|
1893
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1894
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1895
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1896
|
+
' 401 ': responses.unauthorized,
|
|
1897
|
+
' 403': responses.forbidden,
|
|
1898
|
+
' 415': responses.unsupportedMediaType,
|
|
1899
|
+
' 500': responses.internalServerError,
|
|
1900
|
+
' 500 ': responses.zoneDoesNotExist,
|
|
1901
|
+
' 500 ': responses.zoneCannotBeDeleted,
|
|
1902
|
+
},
|
|
1903
|
+
},
|
|
1904
|
+
},
|
|
1905
|
+
'/shops/create': {
|
|
1906
|
+
post: {
|
|
1907
|
+
tags: ['Shops'],
|
|
1908
|
+
summary: '[S] Create',
|
|
1909
|
+
description: `
|
|
1910
|
+
Creates a new shop.
|
|
1911
|
+
|
|
1912
|
+
${descriptions.createIdIsOptional}
|
|
1913
|
+
|
|
1914
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
1915
|
+
|
|
1916
|
+
The \`network._id\` property that associates a shop with his network cannot be changed after creation.
|
|
1917
|
+
If the provided network does not exist the API will return a \`500 NetworkDoesNotExistError\`.
|
|
1918
|
+
|
|
1919
|
+
See [shops](#tag/Shops) for information about the \`status\` property.
|
|
1920
|
+
|
|
1921
|
+
To set custom \`derivationSettings\` and \`expirationSettings\` provide theses properties, or do not provide them and the values under the
|
|
1922
|
+
\`network\` or \`defaults\` properties will be used.
|
|
1923
|
+
|
|
1924
|
+
${securitySchemes.tokens}
|
|
1925
|
+
${securitySchemes.superAdminRole}`,
|
|
1926
|
+
requestBody: {
|
|
1927
|
+
content: { 'application/json': { schema: createShopRequest() } },
|
|
1928
|
+
required: true,
|
|
1929
|
+
},
|
|
1930
|
+
responses: {
|
|
1931
|
+
' 200': {
|
|
1932
|
+
description: 'Contains the created shop.',
|
|
1933
|
+
content: { 'application/json': { schema: createShopResponse() } },
|
|
1934
|
+
},
|
|
1935
|
+
' 400': responses.badRequest,
|
|
1936
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1937
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1938
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1939
|
+
' 401 ': responses.unauthorized,
|
|
1940
|
+
' 403': responses.forbidden,
|
|
1941
|
+
' 415': responses.unsupportedMediaType,
|
|
1942
|
+
' 500': responses.internalServerError,
|
|
1943
|
+
' 500 ': responses.networkDoesNotExist,
|
|
1944
|
+
' 500 ': responses.shopAlreadyExists,
|
|
1945
|
+
},
|
|
1946
|
+
},
|
|
1947
|
+
},
|
|
1948
|
+
'/shops/find': {
|
|
1949
|
+
post: {
|
|
1950
|
+
tags: ['Shops'],
|
|
1951
|
+
summary: '[S] Find',
|
|
1952
|
+
description: `
|
|
1953
|
+
Finds shops by one of several filters.
|
|
1954
|
+
|
|
1955
|
+
${descriptions.findLimitTip}
|
|
1956
|
+
|
|
1957
|
+
${securitySchemes.tokens}
|
|
1958
|
+
${securitySchemes.superAdminRole}`,
|
|
1959
|
+
requestBody: {
|
|
1960
|
+
content: { 'application/json': { schema: findShopsSuperAdminRequest() } },
|
|
1961
|
+
required: true,
|
|
1962
|
+
},
|
|
1963
|
+
responses: {
|
|
1964
|
+
' 200': {
|
|
1965
|
+
description: 'Contains the found shops.',
|
|
1966
|
+
content: { 'application/json': { schema: findShopsResponse() } },
|
|
1967
|
+
},
|
|
1968
|
+
' 400': responses.badRequest,
|
|
1969
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1970
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1971
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1972
|
+
' 401 ': responses.unauthorized,
|
|
1973
|
+
' 403': responses.forbidden,
|
|
1974
|
+
' 415': responses.unsupportedMediaType,
|
|
1975
|
+
' 500': responses.internalServerError,
|
|
1976
|
+
},
|
|
1977
|
+
},
|
|
1978
|
+
},
|
|
1979
|
+
'/shops/find ': {
|
|
1980
|
+
post: {
|
|
1981
|
+
tags: ['Shops'],
|
|
1982
|
+
summary: '[N] Find',
|
|
1983
|
+
description: `
|
|
1984
|
+
Finds shops by one of several filters.
|
|
1985
|
+
|
|
1986
|
+
${descriptions.findLimitTip}
|
|
1987
|
+
|
|
1988
|
+
All filters will find only in the network the network admin belongs to, so if for example the search is by \`_id\` and it belongs to a shop
|
|
1989
|
+
in another network, the find will return no results.
|
|
1990
|
+
|
|
1991
|
+
${securitySchemes.tokens}
|
|
1992
|
+
${securitySchemes.networkAdminRole}`,
|
|
1993
|
+
requestBody: {
|
|
1994
|
+
content: { 'application/json': { schema: findShopsNetworkAdminRequest() } },
|
|
1995
|
+
required: true,
|
|
1996
|
+
},
|
|
1997
|
+
responses: {
|
|
1998
|
+
' 200': {
|
|
1999
|
+
description: 'Contains the found shops.',
|
|
2000
|
+
content: { 'application/json': { schema: findShopsResponse() } },
|
|
2001
|
+
},
|
|
2002
|
+
' 400': responses.badRequest,
|
|
2003
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2004
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2005
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2006
|
+
' 401 ': responses.unauthorized,
|
|
2007
|
+
' 403': responses.forbidden,
|
|
2008
|
+
' 415': responses.unsupportedMediaType,
|
|
2009
|
+
' 500': responses.internalServerError,
|
|
2010
|
+
},
|
|
2011
|
+
},
|
|
2012
|
+
},
|
|
2013
|
+
'/shops/update': {
|
|
2014
|
+
post: {
|
|
2015
|
+
tags: ['Shops'],
|
|
2016
|
+
summary: '[S] Update',
|
|
2017
|
+
description: `
|
|
2018
|
+
Finds a shop and updates the provided properties.
|
|
2019
|
+
|
|
2020
|
+
${descriptions.updateSetAddOrRemove}
|
|
2021
|
+
|
|
2022
|
+
See [shops](#tag/Shops) for information about the \`status\` property.
|
|
2023
|
+
|
|
2024
|
+
${securitySchemes.tokens}
|
|
2025
|
+
${securitySchemes.superAdminRole}`,
|
|
2026
|
+
requestBody: {
|
|
2027
|
+
content: { 'application/json': { schema: updateShopRequest() } },
|
|
2028
|
+
required: true,
|
|
2029
|
+
},
|
|
2030
|
+
responses: {
|
|
2031
|
+
' 200': {
|
|
2032
|
+
description: 'Contains the updated shop.',
|
|
2033
|
+
content: { 'application/json': { schema: updateShopResponse() } },
|
|
2034
|
+
},
|
|
2035
|
+
' 400': responses.badRequest,
|
|
2036
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2037
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2038
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2039
|
+
' 401 ': responses.unauthorized,
|
|
2040
|
+
' 403': responses.forbidden,
|
|
2041
|
+
' 415': responses.unsupportedMediaType,
|
|
2042
|
+
' 500': responses.internalServerError,
|
|
2043
|
+
' 500 ': responses.shopDoesNotExist,
|
|
2044
|
+
},
|
|
2045
|
+
},
|
|
2046
|
+
},
|
|
2047
|
+
'/shops/delete': {
|
|
2048
|
+
post: {
|
|
2049
|
+
tags: ['Shops'],
|
|
2050
|
+
summary: '[S] Delete',
|
|
2051
|
+
description: `
|
|
2052
|
+
Deletes a shop.
|
|
2053
|
+
|
|
2054
|
+
A shop whose \`deletable\` property is \`false\` cannot be deleted because it has users associated to it.
|
|
2055
|
+
If you try the API will return a \`500 ShopCannotBeDeletedError\`.
|
|
2056
|
+
|
|
2057
|
+
${securitySchemes.tokens}
|
|
2058
|
+
${securitySchemes.superAdminRole}`,
|
|
2059
|
+
requestBody: {
|
|
2060
|
+
content: { 'application/json': { schema: deleteShopRequest() } },
|
|
2061
|
+
required: true,
|
|
2062
|
+
},
|
|
2063
|
+
responses: {
|
|
2064
|
+
' 200': {
|
|
2065
|
+
description: 'Contains the deleted shop.',
|
|
2066
|
+
content: { 'application/json': { schema: deleteShopResponse() } },
|
|
2067
|
+
},
|
|
2068
|
+
' 400': responses.badRequest,
|
|
2069
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2070
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2071
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2072
|
+
' 401 ': responses.unauthorized,
|
|
2073
|
+
' 403': responses.forbidden,
|
|
2074
|
+
' 415': responses.unsupportedMediaType,
|
|
2075
|
+
' 500': responses.internalServerError,
|
|
2076
|
+
' 500 ': responses.shopDoesNotExist,
|
|
2077
|
+
' 500 ': responses.shopCannotBeDeleted,
|
|
2078
|
+
},
|
|
2079
|
+
},
|
|
2080
|
+
},
|
|
2081
|
+
'/shopUsers/create': {
|
|
2082
|
+
post: {
|
|
2083
|
+
tags: ['Shop users'],
|
|
2084
|
+
summary: '[S] Create',
|
|
2085
|
+
description: `
|
|
2086
|
+
Creates a new shop user.
|
|
2087
|
+
|
|
2088
|
+
${descriptions.createIdIsOptional}
|
|
2089
|
+
|
|
2090
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
2091
|
+
|
|
2092
|
+
The \`network._id\` and \`shop._id\` properties associate a shop user with his network and shop, and cannot be changed after creation.
|
|
2093
|
+
If the provided network or shop do not exist the API will return a \`500 NetworkDoesNotExistError\` or a \`500 ShopDoesNotExistError\`.
|
|
2094
|
+
|
|
2095
|
+
The only value in the \`integrations\` property applicable to shop users is \`canReceiveAllFromDriver\`. Only those shop users that have it
|
|
2096
|
+
are authorized to call the [receiveAllFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveAllFromDriver/post) endpoint.
|
|
2097
|
+
|
|
2098
|
+
${securitySchemes.tokens}
|
|
2099
|
+
${securitySchemes.superAdminRole}`,
|
|
2100
|
+
requestBody: {
|
|
2101
|
+
content: { 'application/json': { schema: createShopUserRequest() } },
|
|
2102
|
+
required: true,
|
|
2103
|
+
},
|
|
2104
|
+
responses: {
|
|
2105
|
+
' 200': {
|
|
2106
|
+
description: 'Contains the created shop user.',
|
|
2107
|
+
content: { 'application/json': { schema: createShopUserResponse() } },
|
|
2108
|
+
},
|
|
2109
|
+
' 400': responses.badRequest,
|
|
2110
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2111
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2112
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2113
|
+
' 401 ': responses.unauthorized,
|
|
2114
|
+
' 403': responses.forbidden,
|
|
2115
|
+
' 415': responses.unsupportedMediaType,
|
|
2116
|
+
' 500': responses.internalServerError,
|
|
2117
|
+
' 500 ': responses.userAlreadyExists,
|
|
2118
|
+
' 500 ': responses.networkDoesNotExist,
|
|
2119
|
+
' 500 ': responses.shopDoesNotExist,
|
|
2120
|
+
},
|
|
2121
|
+
},
|
|
2122
|
+
},
|
|
2123
|
+
'/shopUsers/find': {
|
|
2124
|
+
post: {
|
|
2125
|
+
tags: ['Shop users'],
|
|
2126
|
+
summary: '[S] Find',
|
|
2127
|
+
description: `
|
|
2128
|
+
Finds shop users by one of several filters.
|
|
2129
|
+
|
|
2130
|
+
${descriptions.findLimitTip}
|
|
2131
|
+
|
|
2132
|
+
${securitySchemes.tokens}
|
|
2133
|
+
${securitySchemes.superAdminRole}`,
|
|
2134
|
+
requestBody: {
|
|
2135
|
+
content: { 'application/json': { schema: findShopUsersSuperAdminRequest() } },
|
|
2136
|
+
required: true,
|
|
2137
|
+
},
|
|
2138
|
+
responses: {
|
|
2139
|
+
' 200': {
|
|
2140
|
+
description: 'Contains the found shop users.',
|
|
2141
|
+
content: { 'application/json': { schema: findShopUsersResponse() } },
|
|
2142
|
+
},
|
|
2143
|
+
' 400': responses.badRequest,
|
|
2144
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2145
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2146
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2147
|
+
' 401 ': responses.unauthorized,
|
|
2148
|
+
' 403': responses.forbidden,
|
|
2149
|
+
' 415': responses.unsupportedMediaType,
|
|
2150
|
+
' 500': responses.internalServerError,
|
|
2151
|
+
},
|
|
2152
|
+
},
|
|
2153
|
+
},
|
|
2154
|
+
'/shopUsers/find ': {
|
|
2155
|
+
post: {
|
|
2156
|
+
tags: ['Shop users'],
|
|
2157
|
+
summary: '[N] Find',
|
|
2158
|
+
description: `
|
|
2159
|
+
Finds shop users by one of several filters.
|
|
2160
|
+
|
|
2161
|
+
${descriptions.findLimitTip}
|
|
2162
|
+
|
|
2163
|
+
All filters will find only in the network the network admin belongs to, so if for example the search is by \`_id\` and it belongs to a shop
|
|
2164
|
+
user in another network, the find will return no results.
|
|
2165
|
+
|
|
2166
|
+
${securitySchemes.tokens}
|
|
2167
|
+
${securitySchemes.networkAdminRole}`,
|
|
2168
|
+
requestBody: {
|
|
2169
|
+
content: { 'application/json': { schema: findShopUsersNetworkAdminRequest() } },
|
|
2170
|
+
required: true,
|
|
2171
|
+
},
|
|
2172
|
+
responses: {
|
|
2173
|
+
' 200': {
|
|
2174
|
+
description: 'Contains the found shop users.',
|
|
2175
|
+
content: { 'application/json': { schema: findShopUsersResponse() } },
|
|
2176
|
+
},
|
|
2177
|
+
' 400': responses.badRequest,
|
|
2178
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2179
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2180
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2181
|
+
' 401 ': responses.unauthorized,
|
|
2182
|
+
' 403': responses.forbidden,
|
|
2183
|
+
' 415': responses.unsupportedMediaType,
|
|
2184
|
+
' 500': responses.internalServerError,
|
|
2185
|
+
},
|
|
2186
|
+
},
|
|
2187
|
+
},
|
|
2188
|
+
'/shopUsers/update': {
|
|
2189
|
+
post: {
|
|
2190
|
+
tags: ['Shop users'],
|
|
2191
|
+
summary: '[S] Update',
|
|
2192
|
+
description: `
|
|
2193
|
+
Finds a shop user and updates the provided properties.
|
|
2194
|
+
|
|
2195
|
+
${descriptions.updateSetAddOrRemove}
|
|
2196
|
+
|
|
2197
|
+
${securitySchemes.tokens}
|
|
2198
|
+
${securitySchemes.superAdminRole}`,
|
|
2199
|
+
requestBody: {
|
|
2200
|
+
content: { 'application/json': { schema: updateShopUserRequest() } },
|
|
2201
|
+
required: true,
|
|
2202
|
+
},
|
|
2203
|
+
responses: {
|
|
2204
|
+
' 200': {
|
|
2205
|
+
description: 'Contains the updated shop user.',
|
|
2206
|
+
content: { 'application/json': { schema: updateShopUserResponse() } },
|
|
2207
|
+
},
|
|
2208
|
+
' 400': responses.badRequest,
|
|
2209
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2210
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2211
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2212
|
+
' 401 ': responses.unauthorized,
|
|
2213
|
+
' 403': responses.forbidden,
|
|
2214
|
+
' 415': responses.unsupportedMediaType,
|
|
2215
|
+
' 500': responses.internalServerError,
|
|
2216
|
+
' 500 ': responses.userDoesNotExist,
|
|
2217
|
+
},
|
|
2218
|
+
},
|
|
2219
|
+
},
|
|
2220
|
+
'/shopUsers/updateSelf': {
|
|
2221
|
+
post: {
|
|
2222
|
+
tags: ['Shop users'],
|
|
2223
|
+
summary: '[U] Update self',
|
|
2224
|
+
description: `
|
|
2225
|
+
A shop user updates himself.
|
|
2226
|
+
|
|
2227
|
+
${descriptions.updateSetAddOrRemove}
|
|
2228
|
+
|
|
2229
|
+
If a shop user tries to update his password and the old password does not match, the API will return a \`500 WrongPasswordError\`.
|
|
2230
|
+
|
|
2231
|
+
${securitySchemes.tokens}
|
|
2232
|
+
${securitySchemes.shopUserRole}`,
|
|
2233
|
+
requestBody: {
|
|
2234
|
+
content: { 'application/json': { schema: updateSelfShopUserRequest() } },
|
|
2235
|
+
required: true,
|
|
2236
|
+
},
|
|
2237
|
+
responses: {
|
|
2238
|
+
' 200': {
|
|
2239
|
+
description: 'Contains the updated shop user.',
|
|
2240
|
+
content: { 'application/json': { schema: updateShopUserResponse() } },
|
|
2241
|
+
},
|
|
2242
|
+
' 400': responses.badRequest,
|
|
2243
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2244
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2245
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2246
|
+
' 401 ': responses.unauthorized,
|
|
2247
|
+
' 403': responses.forbidden,
|
|
2248
|
+
' 415': responses.unsupportedMediaType,
|
|
2249
|
+
' 500': responses.internalServerError,
|
|
2250
|
+
' 500 ': responses.userDoesNotExist,
|
|
2251
|
+
' 500 ': responses.wrongPassword,
|
|
2252
|
+
},
|
|
2253
|
+
},
|
|
2254
|
+
},
|
|
2255
|
+
'/shopUsers/delete': {
|
|
2256
|
+
post: {
|
|
2257
|
+
tags: ['Shop users'],
|
|
2258
|
+
summary: '[S] Delete',
|
|
2259
|
+
description: `
|
|
2260
|
+
Deletes a shop user.
|
|
2261
|
+
|
|
2262
|
+
${securitySchemes.tokens}
|
|
2263
|
+
${securitySchemes.superAdminOrNetworkAdminRole}`,
|
|
2264
|
+
requestBody: {
|
|
2265
|
+
content: { 'application/json': { schema: deleteShopUserRequest() } },
|
|
2266
|
+
required: true,
|
|
2267
|
+
},
|
|
2268
|
+
responses: {
|
|
2269
|
+
' 200': {
|
|
2270
|
+
description: 'Contains the deleted shop user.',
|
|
2271
|
+
content: { 'application/json': { schema: deleteShopUserResponse() } },
|
|
2272
|
+
},
|
|
2273
|
+
' 400': responses.badRequest,
|
|
2274
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2275
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2276
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2277
|
+
' 401 ': responses.unauthorized,
|
|
2278
|
+
' 403': responses.forbidden,
|
|
2279
|
+
' 415': responses.unsupportedMediaType,
|
|
2280
|
+
' 500': responses.internalServerError,
|
|
2281
|
+
' 500 ': responses.userDoesNotExist,
|
|
2282
|
+
},
|
|
2283
|
+
},
|
|
2284
|
+
},
|
|
2285
|
+
'/expeditions/create': {
|
|
2286
|
+
post: {
|
|
2287
|
+
tags: ['Expeditions'],
|
|
2288
|
+
summary: '[S] Create',
|
|
2289
|
+
description: `
|
|
2290
|
+
Creates a new expedition.
|
|
2291
|
+
|
|
2292
|
+
This operation is intended to be used only by GLS when adding an expedition to the API.
|
|
2293
|
+
|
|
2294
|
+
${descriptions.createIdIsOptional}
|
|
2295
|
+
|
|
2296
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
2297
|
+
|
|
2298
|
+
The \`shop._id\` property associates an expedition with its shop, and can be changed later if an incoming expedition needs
|
|
2299
|
+
to be redirected to another shop. Only the shop needs to be provided, the network will be inserted automatically. If the
|
|
2300
|
+
provided shop does not exist the API will return a \`500 ShopDoesNotExistError\`, and if the shop is not enabled the API
|
|
2301
|
+
will return a \`500 ShopNotEnabledError\`.
|
|
2302
|
+
|
|
2303
|
+
The \`status.code\` of a new expedition cannot be specified and it will always be \`incoming\`.
|
|
2304
|
+
|
|
2305
|
+
${securitySchemes.tokens}
|
|
2306
|
+
${securitySchemes.superAdminRole}`,
|
|
2307
|
+
requestBody: {
|
|
2308
|
+
content: { 'application/json': { schema: createExpeditionRequest() } },
|
|
2309
|
+
required: true,
|
|
2310
|
+
},
|
|
2311
|
+
responses: {
|
|
2312
|
+
' 200': {
|
|
2313
|
+
description: 'Contains the created expedition.',
|
|
2314
|
+
content: { 'application/json': { schema: createExpeditionResponse() } },
|
|
2315
|
+
},
|
|
2316
|
+
' 400': responses.badRequest,
|
|
2317
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2318
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2319
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2320
|
+
' 401 ': responses.unauthorized,
|
|
2321
|
+
' 403': responses.forbidden,
|
|
2322
|
+
' 415': responses.unsupportedMediaType,
|
|
2323
|
+
' 500': responses.internalServerError,
|
|
2324
|
+
' 500 ': responses.expeditionAlreadyExists,
|
|
2325
|
+
' 500 ': responses.shopDoesNotExist,
|
|
2326
|
+
' 500 ': responses.shopNotEnabled,
|
|
2327
|
+
},
|
|
2328
|
+
},
|
|
2329
|
+
},
|
|
2330
|
+
'/expeditions/find': {
|
|
2331
|
+
post: {
|
|
2332
|
+
tags: ['Expeditions'],
|
|
2333
|
+
summary: '[SNU] Find',
|
|
2334
|
+
description: `
|
|
2335
|
+
Finds expeditions by one of several filters.
|
|
2336
|
+
|
|
2337
|
+
${descriptions.findLimitTip}
|
|
2338
|
+
|
|
2339
|
+
All roles can find by the same filters, but for network admins and shop users the results will be limited to their network or shop, so for
|
|
2340
|
+
example if a shop user finds by \`_id\` and the expedition is from another network or shop, the find will return no results.
|
|
2341
|
+
|
|
2342
|
+
${securitySchemes.tokens}
|
|
2343
|
+
${securitySchemes.anyRole}`,
|
|
2344
|
+
requestBody: {
|
|
2345
|
+
content: { 'application/json': { schema: findExpeditionsRequest() } },
|
|
2346
|
+
required: true,
|
|
2347
|
+
},
|
|
2348
|
+
responses: {
|
|
2349
|
+
' 200': {
|
|
2350
|
+
description: 'Contains the found expeditions.',
|
|
2351
|
+
content: { 'application/json': { schema: findExpeditionsResponse() } },
|
|
2352
|
+
},
|
|
2353
|
+
' 400': responses.badRequest,
|
|
2354
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2355
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2356
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2357
|
+
' 401 ': responses.unauthorized,
|
|
2358
|
+
' 403': responses.forbidden,
|
|
2359
|
+
' 415': responses.unsupportedMediaType,
|
|
2360
|
+
' 500': responses.internalServerError,
|
|
2361
|
+
},
|
|
2362
|
+
},
|
|
2363
|
+
},
|
|
2364
|
+
'/expeditions/update': {
|
|
2365
|
+
post: {
|
|
2366
|
+
tags: ['Expeditions'],
|
|
2367
|
+
summary: '[S] Update',
|
|
2368
|
+
description: `
|
|
2369
|
+
Finds an expedition and updates the provided properties.
|
|
2370
|
+
|
|
2371
|
+
${descriptions.updateSetAddOrRemove}
|
|
2372
|
+
|
|
2373
|
+
${securitySchemes.tokens}
|
|
2374
|
+
${securitySchemes.superAdminRole}`,
|
|
2375
|
+
requestBody: {
|
|
2376
|
+
content: { 'application/json': { schema: updateExpeditionRequest() } },
|
|
2377
|
+
required: true,
|
|
2378
|
+
},
|
|
2379
|
+
responses: {
|
|
2380
|
+
' 200': {
|
|
2381
|
+
description: 'Contains the updated expedition.',
|
|
2382
|
+
content: { 'application/json': { schema: updateExpeditionResponse() } },
|
|
2383
|
+
},
|
|
2384
|
+
' 400': responses.badRequest,
|
|
2385
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2386
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2387
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2388
|
+
' 401 ': responses.unauthorized,
|
|
2389
|
+
' 403': responses.forbidden,
|
|
2390
|
+
' 415': responses.unsupportedMediaType,
|
|
2391
|
+
' 500': responses.internalServerError,
|
|
2392
|
+
' 500 ': responses.expeditionDoesNotExist,
|
|
2393
|
+
},
|
|
2394
|
+
},
|
|
2395
|
+
},
|
|
2396
|
+
'/expeditions/delete': {
|
|
2397
|
+
post: {
|
|
2398
|
+
tags: ['Expeditions'],
|
|
2399
|
+
summary: '[S] Delete',
|
|
2400
|
+
description: `
|
|
2401
|
+
Deletes an expedition.
|
|
2402
|
+
|
|
2403
|
+
An expedition whose \`deletable\` property is \`false\` cannot be deleted because it has other resources associated to it.
|
|
2404
|
+
If you try the API will return a \`500 ExpeditionCannotBeDeletedError\`.
|
|
2405
|
+
|
|
2406
|
+
${securitySchemes.tokens}
|
|
2407
|
+
${securitySchemes.superAdminRole}`,
|
|
2408
|
+
requestBody: {
|
|
2409
|
+
content: { 'application/json': { schema: deleteExpeditionRequest() } },
|
|
2410
|
+
required: true,
|
|
2411
|
+
},
|
|
2412
|
+
responses: {
|
|
2413
|
+
' 200': {
|
|
2414
|
+
description: 'Contains the deleted expedition.',
|
|
2415
|
+
content: { 'application/json': { schema: deleteExpeditionResponse() } },
|
|
2416
|
+
},
|
|
2417
|
+
' 400': responses.badRequest,
|
|
2418
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2419
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2420
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2421
|
+
' 401 ': responses.unauthorized,
|
|
2422
|
+
' 403': responses.forbidden,
|
|
2423
|
+
' 415': responses.unsupportedMediaType,
|
|
2424
|
+
' 500': responses.internalServerError,
|
|
2425
|
+
' 500 ': responses.expeditionDoesNotExist,
|
|
2426
|
+
' 500 ': responses.expeditionCannotBeDeleted,
|
|
2427
|
+
},
|
|
2428
|
+
},
|
|
2429
|
+
},
|
|
2430
|
+
'/expeditions/scan': {
|
|
2431
|
+
post: {
|
|
2432
|
+
tags: ['Expeditions'],
|
|
2433
|
+
summary: '[U] Scan',
|
|
2434
|
+
description: `
|
|
2435
|
+
Scan a barcode or QR code and find the appropriate expedition.
|
|
2436
|
+
|
|
2437
|
+
It can return:
|
|
2438
|
+
|
|
2439
|
+
- \`ok\`: the barcode or QR match a single expedition from the same shop.
|
|
2440
|
+
- \`notFound\`: the expedition does not exist.
|
|
2441
|
+
- \`anotherShop\`: the expedition belongs to another shop.
|
|
2442
|
+
- \`multipleResults\`: the barcode or QR match more than one expedition (e.g. shared reference). Try scanning another barcode.
|
|
2443
|
+
- \`error\`: any other kind of error. You should retry the operation.
|
|
2444
|
+
|
|
2445
|
+
${securitySchemes.tokens}
|
|
2446
|
+
${securitySchemes.shopUserRole}`,
|
|
2447
|
+
requestBody: {
|
|
2448
|
+
content: { 'application/json': { schema: scanExpeditionRequest() } },
|
|
2449
|
+
required: true,
|
|
2450
|
+
},
|
|
2451
|
+
responses: {
|
|
2452
|
+
' 200': {
|
|
2453
|
+
description: 'Contains a single expedition or a code explaining why it cannot be returned.',
|
|
2454
|
+
content: { 'application/json': { schema: scanExpeditionResponse() } },
|
|
2455
|
+
},
|
|
2456
|
+
' 400': responses.badRequest,
|
|
2457
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2458
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2459
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2460
|
+
' 401 ': responses.unauthorized,
|
|
2461
|
+
' 403': responses.forbidden,
|
|
2462
|
+
' 415': responses.unsupportedMediaType,
|
|
2463
|
+
' 500': responses.internalServerError,
|
|
2464
|
+
},
|
|
2465
|
+
},
|
|
2466
|
+
},
|
|
2467
|
+
'/expeditions/receiveFromDriver': {
|
|
2468
|
+
post: {
|
|
2469
|
+
tags: ['Expeditions'],
|
|
2470
|
+
summary: '[U] Receive from driver',
|
|
2471
|
+
description: `
|
|
2472
|
+
Receives expeditions from a driver, changing their status code and adding more properties to status.
|
|
2473
|
+
|
|
2474
|
+
Each expedition is processed individually and its result returned, so it is possible that some expeditions are processed
|
|
2475
|
+
and some are not. The result for each expedition depends on its situation:
|
|
2476
|
+
|
|
2477
|
+
| Expedition | Type + Status code | Result | New status code | New status properties |
|
|
2478
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
2479
|
+
| found in same shop | delivery + incoming | ok | inShop | receivedFrom, expiration |
|
|
2480
|
+
| found in same shop | any other combination | another situation | - | - |
|
|
2481
|
+
| found in another shop | - | another shop | - | - |
|
|
2482
|
+
| not found | - | not found | - | - |
|
|
2483
|
+
| server error | - | error | - | - |
|
|
2484
|
+
|
|
2485
|
+
${securitySchemes.tokens}
|
|
2486
|
+
${securitySchemes.shopUserRole}`,
|
|
2487
|
+
requestBody: {
|
|
2488
|
+
content: { 'application/json': { schema: processExpeditionsWithDriverRequest() } },
|
|
2489
|
+
required: true,
|
|
2490
|
+
},
|
|
2491
|
+
responses: {
|
|
2492
|
+
' 200': {
|
|
2493
|
+
description: 'Contains the result of the processing for each expedition.',
|
|
2494
|
+
content: { 'application/json': { schema: processExpeditionsResponse() } },
|
|
2495
|
+
},
|
|
2496
|
+
' 400': responses.badRequest,
|
|
2497
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2498
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2499
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2500
|
+
' 401 ': responses.unauthorized,
|
|
2501
|
+
' 403': responses.forbidden,
|
|
2502
|
+
' 415': responses.unsupportedMediaType,
|
|
2503
|
+
' 500': responses.internalServerError,
|
|
2504
|
+
},
|
|
2505
|
+
},
|
|
2506
|
+
},
|
|
2507
|
+
'/expeditions/receiveAllFromDriver': {
|
|
2508
|
+
post: {
|
|
2509
|
+
tags: ['Expeditions'],
|
|
2510
|
+
summary: '[U] Receive all from driver',
|
|
2511
|
+
description: `
|
|
2512
|
+
Receives all the \`incoming\` expeditions for this shop.
|
|
2513
|
+
|
|
2514
|
+
Calling this endpoint is equivalent to calling [receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) with all
|
|
2515
|
+
the \`_ids\` of the \`incoming\` expeditions. It returns how many expeditions have been processed.
|
|
2516
|
+
|
|
2517
|
+
${securitySchemes.tokens}
|
|
2518
|
+
${securitySchemes.shopUserRole}`,
|
|
2519
|
+
requestBody: {
|
|
2520
|
+
content: { 'application/json': { schema: receiveAllExpeditionsFromDriverRequest() } },
|
|
2521
|
+
required: true,
|
|
2522
|
+
},
|
|
2523
|
+
responses: {
|
|
2524
|
+
' 200': {
|
|
2525
|
+
description: 'Contains how many expeditions have been processed.',
|
|
2526
|
+
content: { 'application/json': { schema: receiveAllExpeditionsFromDriverResponse() } },
|
|
2527
|
+
},
|
|
2528
|
+
' 400': responses.badRequest,
|
|
2529
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2530
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2531
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2532
|
+
' 401 ': responses.unauthorized,
|
|
2533
|
+
' 403': responses.forbidden,
|
|
2534
|
+
' 415': responses.unsupportedMediaType,
|
|
2535
|
+
' 500': responses.internalServerError,
|
|
2536
|
+
},
|
|
2537
|
+
},
|
|
2538
|
+
},
|
|
2539
|
+
'/expeditions/receiveFromCustomer': {
|
|
2540
|
+
post: {
|
|
2541
|
+
tags: ['Expeditions'],
|
|
2542
|
+
summary: '[U] Receive from customer',
|
|
2543
|
+
description: `
|
|
2544
|
+
Receives expeditions from a customer, changing their status code and adding more properties to status.
|
|
2545
|
+
|
|
2546
|
+
Each expedition is processed individually and its result returned, so it is possible that some expeditions are processed
|
|
2547
|
+
and some are not. The result for each expedition depends on its situation:
|
|
2548
|
+
|
|
2549
|
+
| Expedition | Type + Status code | Result | New status code | New status properties |
|
|
2550
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
2551
|
+
| found in same shop | pickup + incoming | ok | inShop | receivedFrom |
|
|
2552
|
+
| found in same shop | any other combination | another situation | - | - |
|
|
2553
|
+
| found in another shop | - | another shop | - | - |
|
|
2554
|
+
| not found | - | not found | - | - |
|
|
2555
|
+
| server error | - | error | - | - |
|
|
2556
|
+
|
|
2557
|
+
${securitySchemes.tokens}
|
|
2558
|
+
${securitySchemes.shopUserRole}`,
|
|
2559
|
+
requestBody: {
|
|
2560
|
+
content: { 'application/json': { schema: processExpeditionsWithCustomerRequest() } },
|
|
2561
|
+
required: true,
|
|
2562
|
+
},
|
|
2563
|
+
responses: {
|
|
2564
|
+
' 200': {
|
|
2565
|
+
description: 'Contains the result of the processing for each expedition.',
|
|
2566
|
+
content: { 'application/json': { schema: processExpeditionsResponse() } },
|
|
2567
|
+
},
|
|
2568
|
+
' 400': responses.badRequest,
|
|
2569
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2570
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2571
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2572
|
+
' 401 ': responses.unauthorized,
|
|
2573
|
+
' 403': responses.forbidden,
|
|
2574
|
+
' 415': responses.unsupportedMediaType,
|
|
2575
|
+
' 500': responses.internalServerError,
|
|
2576
|
+
},
|
|
2577
|
+
},
|
|
2578
|
+
},
|
|
2579
|
+
'/expeditions/giveToCustomer': {
|
|
2580
|
+
post: {
|
|
2581
|
+
tags: ['Expeditions'],
|
|
2582
|
+
summary: '[U] Give to customer',
|
|
2583
|
+
description: `
|
|
2584
|
+
Gives expeditions to a customer, changing their status code and adding more properties to status.
|
|
2585
|
+
|
|
2586
|
+
Each expedition is processed individually and its result returned, so it is possible that some expeditions are processed
|
|
2587
|
+
and some are not. The result for each expedition depends on its situation:
|
|
2588
|
+
|
|
2589
|
+
| Expedition | Type + Status code | Result | New status code | New status properties |
|
|
2590
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
2591
|
+
| found in same shop | delivery + inShop | ok | delivered | givenTo |
|
|
2592
|
+
| found in same shop | any other combination | another situation | - | - |
|
|
2593
|
+
| found in another shop | - | another shop | - | - |
|
|
2594
|
+
| not found | - | not found | - | - |
|
|
2595
|
+
| server error | - | error | - | - |
|
|
2596
|
+
|
|
2597
|
+
${securitySchemes.tokens}
|
|
2598
|
+
${securitySchemes.shopUserRole}`,
|
|
2599
|
+
requestBody: {
|
|
2600
|
+
content: { 'application/json': { schema: processExpeditionsWithCustomerRequest() } },
|
|
2601
|
+
required: true,
|
|
2602
|
+
},
|
|
2603
|
+
responses: {
|
|
2604
|
+
' 200': {
|
|
2605
|
+
description: 'Contains the result of the processing for each expedition.',
|
|
2606
|
+
content: { 'application/json': { schema: processExpeditionsResponse() } },
|
|
2607
|
+
},
|
|
2608
|
+
' 400': responses.badRequest,
|
|
2609
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2610
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2611
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2612
|
+
' 401 ': responses.unauthorized,
|
|
2613
|
+
' 403': responses.forbidden,
|
|
2614
|
+
' 415': responses.unsupportedMediaType,
|
|
2615
|
+
' 500': responses.internalServerError,
|
|
2616
|
+
},
|
|
2617
|
+
},
|
|
2618
|
+
},
|
|
2619
|
+
'/expeditions/giveToDriver': {
|
|
2620
|
+
post: {
|
|
2621
|
+
tags: ['Expeditions'],
|
|
2622
|
+
summary: '[U] Give to driver',
|
|
2623
|
+
description: `
|
|
2624
|
+
Gives expeditions to a driver, changing their status code and adding more properties to status.
|
|
2625
|
+
|
|
2626
|
+
Each expedition is processed individually and its result returned, so it is possible that some expeditions are processed
|
|
2627
|
+
and some are not. The result for each expedition depends on its situation:
|
|
2628
|
+
|
|
2629
|
+
| Expedition | Type + Status code | Result | New status code | New status properties |
|
|
2630
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
2631
|
+
| found in same shop | delivery + inShopExpired | ok | delivered | givenTo |
|
|
2632
|
+
| found in same shop | pickup + inShop | ok | delivered | givenTo |
|
|
2633
|
+
| found in same shop | any other combination | another situation | - | - |
|
|
2634
|
+
| found in another shop | - | another shop | - | - |
|
|
2635
|
+
| not found | - | not found | - | - |
|
|
2636
|
+
| server error | - | error | - | - |
|
|
2637
|
+
|
|
2638
|
+
${securitySchemes.tokens}
|
|
2639
|
+
${securitySchemes.shopUserRole}`,
|
|
2640
|
+
requestBody: {
|
|
2641
|
+
content: { 'application/json': { schema: processExpeditionsWithDriverRequest() } },
|
|
2642
|
+
required: true,
|
|
2643
|
+
},
|
|
2644
|
+
responses: {
|
|
2645
|
+
' 200': {
|
|
2646
|
+
description: 'Contains the result of the processing for each expedition.',
|
|
2647
|
+
content: { 'application/json': { schema: processExpeditionsResponse() } },
|
|
2648
|
+
},
|
|
2649
|
+
' 400': responses.badRequest,
|
|
2650
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2651
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2652
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2653
|
+
' 401 ': responses.unauthorized,
|
|
2654
|
+
' 403': responses.forbidden,
|
|
2655
|
+
' 415': responses.unsupportedMediaType,
|
|
2656
|
+
' 500': responses.internalServerError,
|
|
2657
|
+
},
|
|
2658
|
+
},
|
|
2659
|
+
},
|
|
2660
|
+
'/expeditions/redirect': {
|
|
2661
|
+
post: {
|
|
2662
|
+
tags: ['Expeditions'],
|
|
2663
|
+
summary: '[S] Redirect',
|
|
2664
|
+
description: `
|
|
2665
|
+
Moves an expedition from one shop to another, changing its network if necessary and resetting its status to \`incoming\`.
|
|
2666
|
+
It can be used to redirect the expedition to the same shop, effectively resetting it to its initial status.
|
|
2667
|
+
|
|
2668
|
+
${securitySchemes.tokens}
|
|
2669
|
+
${securitySchemes.superAdminRole}`,
|
|
2670
|
+
requestBody: {
|
|
2671
|
+
content: { 'application/json': { schema: redirectExpeditionRequest() } },
|
|
2672
|
+
required: true,
|
|
2673
|
+
},
|
|
2674
|
+
responses: {
|
|
2675
|
+
' 200': {
|
|
2676
|
+
description: 'Contains the updated expedition.',
|
|
2677
|
+
content: { 'application/json': { schema: redirectExpeditionResponse() } },
|
|
2678
|
+
},
|
|
2679
|
+
' 400': responses.badRequest,
|
|
2680
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2681
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2682
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2683
|
+
' 401 ': responses.unauthorized,
|
|
2684
|
+
' 403': responses.forbidden,
|
|
2685
|
+
' 415': responses.unsupportedMediaType,
|
|
2686
|
+
' 500': responses.internalServerError,
|
|
2687
|
+
' 500 ': responses.expeditionDoesNotExist,
|
|
2688
|
+
' 500 ': responses.shopDoesNotExist,
|
|
2689
|
+
' 500 ': responses.shopNotEnabled,
|
|
2690
|
+
},
|
|
2691
|
+
},
|
|
2692
|
+
},
|
|
2693
|
+
'/pods/find': {
|
|
2694
|
+
post: {
|
|
2695
|
+
tags: ['Pods'],
|
|
2696
|
+
summary: '[SNU] Find',
|
|
2697
|
+
description: `
|
|
2698
|
+
Finds PODs.
|
|
2699
|
+
|
|
2700
|
+
${descriptions.findLimitTip}
|
|
2701
|
+
|
|
2702
|
+
Super admins can find PODs from any expedition, but network admins and shop users can only find PODs from expeditions
|
|
2703
|
+
they have access to. If a network admin or a shop user tries to find a POD from an expedition they do not have access to,
|
|
2704
|
+
find will return no results.
|
|
2705
|
+
|
|
2706
|
+
${securitySchemes.tokens}
|
|
2707
|
+
${securitySchemes.anyRole}`,
|
|
2708
|
+
requestBody: {
|
|
2709
|
+
content: { 'application/json': { schema: findPodsRequest() } },
|
|
2710
|
+
required: true,
|
|
2711
|
+
},
|
|
2712
|
+
responses: {
|
|
2713
|
+
' 200': {
|
|
2714
|
+
description: 'Contains the found PODs.',
|
|
2715
|
+
content: { 'application/json': { schema: findPodsResponse() } },
|
|
2716
|
+
},
|
|
2717
|
+
' 400': responses.badRequest,
|
|
2718
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2719
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2720
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2721
|
+
' 401 ': responses.unauthorized,
|
|
2722
|
+
' 403': responses.forbidden,
|
|
2723
|
+
' 415': responses.unsupportedMediaType,
|
|
2724
|
+
' 500': responses.internalServerError,
|
|
2725
|
+
},
|
|
2726
|
+
},
|
|
2727
|
+
},
|
|
2728
|
+
'/representatives/create': {
|
|
2729
|
+
post: {
|
|
2730
|
+
tags: ['Sales representatives'],
|
|
2731
|
+
summary: '[S] Create',
|
|
2732
|
+
description: `
|
|
2733
|
+
Creates a new sales representative.
|
|
2734
|
+
|
|
2735
|
+
${descriptions.createIdIsOptional}
|
|
2736
|
+
|
|
2737
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
2738
|
+
|
|
2739
|
+
${securitySchemes.tokens}
|
|
2740
|
+
${securitySchemes.superAdminRole}`,
|
|
2741
|
+
requestBody: {
|
|
2742
|
+
content: { 'application/json': { schema: createRepresentativeRequest() } },
|
|
2743
|
+
required: true,
|
|
2744
|
+
},
|
|
2745
|
+
responses: {
|
|
2746
|
+
' 200': {
|
|
2747
|
+
description: 'Contains the created sales representative.',
|
|
2748
|
+
content: { 'application/json': { schema: createRepresentativeResponse() } },
|
|
2749
|
+
},
|
|
2750
|
+
' 400': responses.badRequest,
|
|
2751
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2752
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2753
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2754
|
+
' 401 ': responses.unauthorized,
|
|
2755
|
+
' 403': responses.forbidden,
|
|
2756
|
+
' 415': responses.unsupportedMediaType,
|
|
2757
|
+
' 500': responses.internalServerError,
|
|
2758
|
+
' 500 ': responses.representativeAlreadyExists,
|
|
2759
|
+
},
|
|
2760
|
+
},
|
|
2761
|
+
},
|
|
2762
|
+
'/representatives/listNames': {
|
|
2763
|
+
get: {
|
|
2764
|
+
tags: ['Sales representatives'],
|
|
2765
|
+
summary: '[S] List names',
|
|
2766
|
+
description: `
|
|
2767
|
+
Finds sales representatives and returns only the \`_id\` and \`name\` properties for each one.
|
|
2768
|
+
|
|
2769
|
+
${securitySchemes.tokens}
|
|
2770
|
+
${securitySchemes.superAdminRole}`,
|
|
2771
|
+
responses: {
|
|
2772
|
+
' 200': {
|
|
2773
|
+
description: 'Contains the found sales representatives names.',
|
|
2774
|
+
content: { 'application/json': { schema: listRepresentativesNamesResponse() } },
|
|
2775
|
+
},
|
|
2776
|
+
' 400': responses.badRequest,
|
|
2777
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2778
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2779
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2780
|
+
' 401 ': responses.unauthorized,
|
|
2781
|
+
' 403': responses.forbidden,
|
|
2782
|
+
' 415': responses.unsupportedMediaType,
|
|
2783
|
+
' 500': responses.internalServerError,
|
|
2784
|
+
},
|
|
2785
|
+
},
|
|
2786
|
+
},
|
|
2787
|
+
'/representatives/find': {
|
|
2788
|
+
post: {
|
|
2789
|
+
tags: ['Sales representatives'],
|
|
2790
|
+
summary: '[S] Find',
|
|
2791
|
+
description: `
|
|
2792
|
+
Finds sales representatives by one of several filters.
|
|
2793
|
+
|
|
2794
|
+
${descriptions.findLimitTip}
|
|
2795
|
+
|
|
2796
|
+
${securitySchemes.tokens}
|
|
2797
|
+
${securitySchemes.superAdminRole}`,
|
|
2798
|
+
requestBody: {
|
|
2799
|
+
content: { 'application/json': { schema: findRepresentativesRequest() } },
|
|
2800
|
+
required: true,
|
|
2801
|
+
},
|
|
2802
|
+
responses: {
|
|
2803
|
+
' 200': {
|
|
2804
|
+
description: 'Contains the found sales representatives.',
|
|
2805
|
+
content: { 'application/json': { schema: findRepresentativesResponse() } },
|
|
2806
|
+
},
|
|
2807
|
+
' 400': responses.badRequest,
|
|
2808
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2809
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2810
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2811
|
+
' 401 ': responses.unauthorized,
|
|
2812
|
+
' 403': responses.forbidden,
|
|
2813
|
+
' 415': responses.unsupportedMediaType,
|
|
2814
|
+
' 500': responses.internalServerError,
|
|
2815
|
+
},
|
|
2816
|
+
},
|
|
2817
|
+
},
|
|
2818
|
+
'/representatives/update': {
|
|
2819
|
+
post: {
|
|
2820
|
+
tags: ['Sales representatives'],
|
|
2821
|
+
summary: '[S] Update',
|
|
2822
|
+
description: `
|
|
2823
|
+
Finds a sales representative and updates the provided properties.
|
|
2824
|
+
|
|
2825
|
+
${descriptions.updateSetAddOrRemove}
|
|
2826
|
+
|
|
2827
|
+
${securitySchemes.tokens}
|
|
2828
|
+
${securitySchemes.superAdminRole}`,
|
|
2829
|
+
requestBody: {
|
|
2830
|
+
content: { 'application/json': { schema: updateRepresentativeRequest() } },
|
|
2831
|
+
required: true,
|
|
2832
|
+
},
|
|
2833
|
+
responses: {
|
|
2834
|
+
' 200': {
|
|
2835
|
+
description: 'Contains the updated sales representative.',
|
|
2836
|
+
content: { 'application/json': { schema: updateRepresentativeResponse() } },
|
|
2837
|
+
},
|
|
2838
|
+
' 400': responses.badRequest,
|
|
2839
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2840
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2841
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2842
|
+
' 401 ': responses.unauthorized,
|
|
2843
|
+
' 403': responses.forbidden,
|
|
2844
|
+
' 415': responses.unsupportedMediaType,
|
|
2845
|
+
' 500': responses.internalServerError,
|
|
2846
|
+
' 500 ': responses.representativeDoesNotExist,
|
|
2847
|
+
},
|
|
2848
|
+
},
|
|
2849
|
+
},
|
|
2850
|
+
'/representatives/getCommissions': {
|
|
2851
|
+
post: {
|
|
2852
|
+
tags: ['Sales representatives'],
|
|
2853
|
+
summary: '[S] Get commissions',
|
|
2854
|
+
description: `
|
|
2855
|
+
Gets the commissions earned by a representative between two dates.
|
|
2856
|
+
|
|
2857
|
+
The commissions are calculated by zones. For each zone the commissions include how many shops the representative has opened in that date
|
|
2858
|
+
range and how many shops he has been managing for more than X months. The minimum shops he has to open and for how long he has to manage
|
|
2859
|
+
shops is configured in the zone commissions.
|
|
2860
|
+
|
|
2861
|
+
${securitySchemes.tokens}
|
|
2862
|
+
${securitySchemes.superAdminRole}`,
|
|
2863
|
+
requestBody: {
|
|
2864
|
+
content: { 'application/json': { schema: getRepresentativeCommissionsRequest() } },
|
|
2865
|
+
required: true,
|
|
2866
|
+
},
|
|
2867
|
+
responses: {
|
|
2868
|
+
' 200': {
|
|
2869
|
+
description: 'Contains the commissions for that representative and date range.',
|
|
2870
|
+
content: { 'application/json': { schema: getRepresentativeCommissionsResponse() } },
|
|
2871
|
+
},
|
|
2872
|
+
' 400': responses.badRequest,
|
|
2873
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2874
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2875
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2876
|
+
' 401 ': responses.unauthorized,
|
|
2877
|
+
' 403': responses.forbidden,
|
|
2878
|
+
' 415': responses.unsupportedMediaType,
|
|
2879
|
+
' 500': responses.internalServerError,
|
|
2880
|
+
' 500 ': responses.representativeDoesNotExist,
|
|
2881
|
+
},
|
|
2882
|
+
},
|
|
2883
|
+
},
|
|
2884
|
+
'/representatives/delete': {
|
|
2885
|
+
post: {
|
|
2886
|
+
tags: ['Sales representatives'],
|
|
2887
|
+
summary: '[S] Delete',
|
|
2888
|
+
description: `
|
|
2889
|
+
Deletes a sales representative.
|
|
2890
|
+
|
|
2891
|
+
A sales representative whose \`deletable\` property is \`false\` cannot be deleted because it has shops associated to it.
|
|
2892
|
+
If you try the API will return a \`500 RepresentativeCannotBeDeletedError\`.
|
|
2893
|
+
|
|
2894
|
+
${securitySchemes.tokens}
|
|
2895
|
+
${securitySchemes.superAdminRole}`,
|
|
2896
|
+
requestBody: {
|
|
2897
|
+
content: { 'application/json': { schema: deleteRepresentativeRequest() } },
|
|
2898
|
+
required: true,
|
|
2899
|
+
},
|
|
2900
|
+
responses: {
|
|
2901
|
+
' 200': {
|
|
2902
|
+
description: 'Contains the deleted sales representative.',
|
|
2903
|
+
content: { 'application/json': { schema: deleteRepresentativeResponse() } },
|
|
2904
|
+
},
|
|
2905
|
+
' 400': responses.badRequest,
|
|
2906
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2907
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2908
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2909
|
+
' 401 ': responses.unauthorized,
|
|
2910
|
+
' 403': responses.forbidden,
|
|
2911
|
+
' 415': responses.unsupportedMediaType,
|
|
2912
|
+
' 500': responses.internalServerError,
|
|
2913
|
+
' 500 ': responses.representativeDoesNotExist,
|
|
2914
|
+
' 500 ': responses.representativeCannotBeDeleted,
|
|
2915
|
+
},
|
|
2916
|
+
},
|
|
2917
|
+
},
|
|
2918
|
+
};
|
|
2919
|
+
|
|
2920
|
+
module.exports = openApiSpec;
|