@gls_spain/gps-common 29.0.0 → 30.0.1
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/.idea/workspace.xml +19 -16
- package/CHANGELOG.md +19 -0
- package/open-api-spec/index.js +280 -291
- package/package.json +1 -1
- package/schemas/definitions/defaults.js +6 -2
- package/schemas/definitions/historic-records.js +46 -68
- package/schemas/definitions/networks.js +6 -1
- package/schemas/definitions/shops.js +6 -1
package/.idea/workspace.xml
CHANGED
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ChangeListManager">
|
|
4
4
|
<list default="true" id="c2833e40-3178-44f3-9bc5-203849985c7f" name="Default Changelist" comment="">
|
|
5
|
-
<change beforePath="$PROJECT_DIR$/
|
|
6
|
-
<change beforePath="$PROJECT_DIR$/schemas/definitions/expeditions.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/expeditions.js" afterDir="false" />
|
|
7
|
-
<change beforePath="$PROJECT_DIR$/schemas/definitions/networks.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/networks.js" afterDir="false" />
|
|
8
|
-
<change beforePath="$PROJECT_DIR$/schemas/definitions/representatives.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/representatives.js" afterDir="false" />
|
|
9
|
-
<change beforePath="$PROJECT_DIR$/schemas/definitions/shops.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/shops.js" afterDir="false" />
|
|
10
|
-
<change beforePath="$PROJECT_DIR$/schemas/definitions/users.js" beforeDir="false" afterPath="$PROJECT_DIR$/schemas/definitions/users.js" afterDir="false" />
|
|
5
|
+
<change beforePath="$PROJECT_DIR$/open-api-spec/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/open-api-spec/index.js" afterDir="false" />
|
|
11
6
|
</list>
|
|
12
7
|
<option name="SHOW_DIALOG" value="false" />
|
|
13
8
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -130,8 +125,8 @@
|
|
|
130
125
|
</configuration>
|
|
131
126
|
<recent_temporary>
|
|
132
127
|
<list>
|
|
133
|
-
<item itemvalue="JavaScript Debug.documentation.html (1)" />
|
|
134
128
|
<item itemvalue="npm.build-documentation" />
|
|
129
|
+
<item itemvalue="JavaScript Debug.documentation.html (1)" />
|
|
135
130
|
<item itemvalue="npm.test" />
|
|
136
131
|
<item itemvalue="Jest.index.test.js" />
|
|
137
132
|
<item itemvalue="Jest.#errors" />
|
|
@@ -506,7 +501,15 @@
|
|
|
506
501
|
<workItem from="1584283992678" duration="388000" />
|
|
507
502
|
<workItem from="1584288029270" duration="191000" />
|
|
508
503
|
<workItem from="1584291295326" duration="639000" />
|
|
509
|
-
<workItem from="1584346563581" duration="
|
|
504
|
+
<workItem from="1584346563581" duration="3782000" />
|
|
505
|
+
<workItem from="1584431456137" duration="91000" />
|
|
506
|
+
<workItem from="1584450804621" duration="5722000" />
|
|
507
|
+
<workItem from="1584513827612" duration="583000" />
|
|
508
|
+
<workItem from="1584535774211" duration="830000" />
|
|
509
|
+
<workItem from="1584549919776" duration="870000" />
|
|
510
|
+
<workItem from="1584562718815" duration="955000" />
|
|
511
|
+
<workItem from="1584605080897" duration="682000" />
|
|
512
|
+
<workItem from="1584606282127" duration="169000" />
|
|
510
513
|
</task>
|
|
511
514
|
<servers />
|
|
512
515
|
</component>
|
|
@@ -558,22 +561,22 @@
|
|
|
558
561
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
559
562
|
</state>
|
|
560
563
|
<state x="606" y="280" key="EditFileWatcherDialog/0.23.2048.1129@0.23.2048.1129" timestamp="1580283934403" />
|
|
561
|
-
<state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="
|
|
564
|
+
<state width="2006" height="269" key="GridCell.Tab.0.bottom" timestamp="1584615888745">
|
|
562
565
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
563
566
|
</state>
|
|
564
|
-
<state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
565
|
-
<state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="
|
|
567
|
+
<state width="2006" height="269" key="GridCell.Tab.0.bottom/0.23.2048.1129@0.23.2048.1129" timestamp="1584615888745" />
|
|
568
|
+
<state width="2006" height="269" key="GridCell.Tab.0.center" timestamp="1584615888744">
|
|
566
569
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
567
570
|
</state>
|
|
568
|
-
<state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
569
|
-
<state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="
|
|
571
|
+
<state width="2006" height="269" key="GridCell.Tab.0.center/0.23.2048.1129@0.23.2048.1129" timestamp="1584615888744" />
|
|
572
|
+
<state width="2006" height="269" key="GridCell.Tab.0.left" timestamp="1584615888744">
|
|
570
573
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
571
574
|
</state>
|
|
572
|
-
<state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
573
|
-
<state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="
|
|
575
|
+
<state width="2006" height="269" key="GridCell.Tab.0.left/0.23.2048.1129@0.23.2048.1129" timestamp="1584615888744" />
|
|
576
|
+
<state width="2006" height="269" key="GridCell.Tab.0.right" timestamp="1584615888744">
|
|
574
577
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
575
578
|
</state>
|
|
576
|
-
<state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="
|
|
579
|
+
<state width="2006" height="269" key="GridCell.Tab.0.right/0.23.2048.1129@0.23.2048.1129" timestamp="1584615888744" />
|
|
577
580
|
<state x="0" y="23" width="2048" height="1129" key="SettingsEditor" timestamp="1580283935326">
|
|
578
581
|
<screen x="0" y="23" width="2048" height="1129" />
|
|
579
582
|
</state>
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [30.0.1](https://github.com/GLS-Spain/gps-common/compare/v30.0.0...v30.0.1) (2020-03-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix defaults denormalization in network and shop schemas ([d7984fb](https://github.com/GLS-Spain/gps-common/commit/d7984fb32b4db683777b7587b989a2f464c2c29b))
|
|
7
|
+
|
|
8
|
+
# [30.0.0](https://github.com/GLS-Spain/gps-common/compare/v29.0.0...v30.0.0) (2020-03-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* historic records are now created for all resources except pods ([1ab3a02](https://github.com/GLS-Spain/gps-common/commit/1ab3a02ef81f9f93ee2524a187bd313df5281cba))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* historic records are no longer only for networks, shops and expeditions
|
|
19
|
+
|
|
1
20
|
# [29.0.0](https://github.com/GLS-Spain/gps-common/compare/v28.0.1...v29.0.0) (2020-03-16)
|
|
2
21
|
|
|
3
22
|
|
package/open-api-spec/index.js
CHANGED
|
@@ -118,7 +118,7 @@ const {
|
|
|
118
118
|
receiveAllExpeditionsFromDriverRequest,
|
|
119
119
|
receiveAllExpeditionsFromDriverResponse,
|
|
120
120
|
} = require('../schemas/definitions/expeditions');
|
|
121
|
-
const { getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
|
|
121
|
+
const { defaults, getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
|
|
122
122
|
const { pod, findPodsRequest, findPodsResponse } = require('../schemas/definitions/pods');
|
|
123
123
|
const {
|
|
124
124
|
receiveFromDriverEvent,
|
|
@@ -158,13 +158,7 @@ const {
|
|
|
158
158
|
deleteZoneResponse,
|
|
159
159
|
} = require('../schemas/definitions/zones');
|
|
160
160
|
const { integration, findIntegrationsRequest, findIntegrationsResponse } = require('../schemas/definitions/integrations');
|
|
161
|
-
const {
|
|
162
|
-
networkHistoricRecord,
|
|
163
|
-
shopHistoricRecord,
|
|
164
|
-
expeditionHistoricRecord,
|
|
165
|
-
findHistoricRecordsRequest,
|
|
166
|
-
findHistoricRecordsResponse,
|
|
167
|
-
} = require('../schemas/definitions/historic-records');
|
|
161
|
+
const { historicRecord, findHistoricRecordsRequest, findHistoricRecordsResponse } = require('../schemas/definitions/historic-records');
|
|
168
162
|
|
|
169
163
|
const openApiSpec = { openapi: '3.0.2' };
|
|
170
164
|
|
|
@@ -205,11 +199,11 @@ openApiSpec['x-tagGroups'] = [
|
|
|
205
199
|
},
|
|
206
200
|
{
|
|
207
201
|
name: 'RESOURCES',
|
|
208
|
-
tags: ['Super admin', 'Network', 'Network admin', 'Zone', 'Shop', 'Shop user', 'Expedition', 'Pod'
|
|
202
|
+
tags: ['Defaults', 'Super admin', 'Network', 'Network admin', 'Zone', 'Sales representative', 'Shop', 'Shop user', 'Expedition', 'Pod'],
|
|
209
203
|
},
|
|
210
204
|
{
|
|
211
205
|
name: 'HISTORIC RECORDS',
|
|
212
|
-
tags: ['Historic records introduction'
|
|
206
|
+
tags: ['Historic records introduction'],
|
|
213
207
|
},
|
|
214
208
|
{
|
|
215
209
|
name: 'BACKGROUND WORK',
|
|
@@ -225,17 +219,17 @@ openApiSpec['x-tagGroups'] = [
|
|
|
225
219
|
'Authentication',
|
|
226
220
|
'Documentation',
|
|
227
221
|
'Config',
|
|
228
|
-
'Integrations',
|
|
229
222
|
'Super admins',
|
|
230
223
|
'Networks',
|
|
231
224
|
'Network admins',
|
|
232
225
|
'Zones',
|
|
226
|
+
'Sales representatives',
|
|
233
227
|
'Shops',
|
|
234
228
|
'Shop users',
|
|
235
229
|
'Expeditions',
|
|
236
230
|
'Pods',
|
|
237
|
-
'Sales representatives',
|
|
238
231
|
'Historic records',
|
|
232
|
+
'Integrations',
|
|
239
233
|
],
|
|
240
234
|
},
|
|
241
235
|
];
|
|
@@ -331,6 +325,16 @@ The full list of allowed timezone names is:
|
|
|
331
325
|
|
|
332
326
|
<SchemaDefinition schemaRef="#/components/schemas/timezoneNames" />
|
|
333
327
|
`,
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: 'Defaults',
|
|
331
|
+
description: `
|
|
332
|
+
The API has some default settings for networks and shops that do not specify their own, like the rate prices for deliveries and pickups,
|
|
333
|
+
the maximum number of days that an expedition can be in a shop before returning it, etc.
|
|
334
|
+
|
|
335
|
+
Super administrators can view and update this default settings using the [config](#tag/Config) endpoints.
|
|
336
|
+
|
|
337
|
+
<SchemaDefinition schemaRef="#/components/schemas/defaults" />`,
|
|
334
338
|
},
|
|
335
339
|
{
|
|
336
340
|
name: 'Super admin',
|
|
@@ -370,6 +374,18 @@ Super administrators can create and manage zones using the [zones](#tag/Zones) e
|
|
|
370
374
|
representatives on creation or update.
|
|
371
375
|
|
|
372
376
|
<SchemaDefinition schemaRef="#/components/schemas/zone" />`,
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: 'Sales representative',
|
|
380
|
+
description: `
|
|
381
|
+
Sales representatives are the GLS staff that make deals with businesses to open establishments as parcel shops. Each parcel shop
|
|
382
|
+
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
|
|
383
|
+
managing it.
|
|
384
|
+
|
|
385
|
+
Super administrators can create and manage sales representatives using the [sales representatives](#tag/Sales-representatives)
|
|
386
|
+
endpoints, and then associate them to parcel shops on creation or update.
|
|
387
|
+
|
|
388
|
+
<SchemaDefinition schemaRef="#/components/schemas/representative" />`,
|
|
373
389
|
},
|
|
374
390
|
{
|
|
375
391
|
name: 'Shop',
|
|
@@ -420,67 +436,36 @@ Super administrators, network administrators and shop users can use the [pods](#
|
|
|
420
436
|
expeditions they have access to.
|
|
421
437
|
|
|
422
438
|
<SchemaDefinition schemaRef="#/components/schemas/pod" />`,
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
name: 'Sales representative',
|
|
426
|
-
description: `
|
|
427
|
-
Sales representatives are the GLS staff that make deals with businesses to open establishments as parcel shops. Each parcel shop
|
|
428
|
-
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
|
|
429
|
-
managing it.
|
|
430
|
-
|
|
431
|
-
Super administrators can create and manage sales representatives using the [sales representatives](#tag/Sales-representatives)
|
|
432
|
-
endpoints, and then associate them to parcel shops on creation or update.
|
|
433
|
-
|
|
434
|
-
<SchemaDefinition schemaRef="#/components/schemas/representative" />`,
|
|
435
439
|
},
|
|
436
440
|
{
|
|
437
441
|
name: 'Historic records introduction',
|
|
438
442
|
'x-displayName': 'Historic records',
|
|
439
443
|
description: `
|
|
440
|
-
Every time the API creates, updates or deletes a
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
These historic records serve two purposes:
|
|
444
|
+
Every time the API creates, updates or deletes a resource, it stores a historic record of the action including the full document as it was
|
|
445
|
+
after the action, the time it occurred and the user that made it.
|
|
444
446
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
and deciding what to do with each action, if anything.
|
|
447
|
+
The only exception are \`pods\` which have no records because they are created when their expeditions are delivered and they are never
|
|
448
|
+
updated or deleted.
|
|
448
449
|
|
|
449
|
-
|
|
450
|
-
`,
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
name: 'Network record',
|
|
454
|
-
description: `
|
|
455
|
-
The API creates a record every time a network is created, updated or deleted.
|
|
456
|
-
|
|
457
|
-
Super administrators can search the historic records of networks using the [historic records](#tag/Historic-records) endpoints.
|
|
450
|
+
These historic records serve two purposes:
|
|
458
451
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
{
|
|
462
|
-
name: 'Shop record',
|
|
463
|
-
description: `
|
|
464
|
-
The API creates a record every time a shop is created, updated or deleted.
|
|
452
|
+
- They allow to track the full history of a document.
|
|
453
|
+
- They are the basis for the [integrations](#tag/Integrations-introduction) with other systems.
|
|
465
454
|
|
|
466
|
-
|
|
455
|
+
The \`actionDetails\` field adds more information about the action when necessary, for example:
|
|
467
456
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
name: 'Expedition record',
|
|
472
|
-
description: `
|
|
473
|
-
The API creates a record every time an expedition is created, updated, deleted, received, given or redirected.
|
|
457
|
+
- An expedition reception from a customer is an \`update\` action with the \`receiveFromCustomer\` and \`price\` details.
|
|
458
|
+
- An update of an expedition packages is an \`update\` action with a \`price\` detail.
|
|
459
|
+
- An automatic background expiration of an expedition is an \`update\` action with an \`expired\` detail.
|
|
474
460
|
|
|
475
|
-
The \`
|
|
461
|
+
The values in \`actionDetails\` only apply to certain combinations of \`type\` and \`action\`.
|
|
476
462
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
- An automatic background expiration of an expedition is an \`update\` action with an \`expired\` extra.
|
|
463
|
+
The \`integrations\` field is where each integration stores what it did with it. Its properties are the names of the integrations and
|
|
464
|
+
their values the result of that integration for that record.
|
|
480
465
|
|
|
481
|
-
Super administrators can search the historic records
|
|
466
|
+
Super administrators can search the historic records using the [historic records](#tag/Historic-records) endpoints.
|
|
482
467
|
|
|
483
|
-
<SchemaDefinition schemaRef="#/components/schemas/
|
|
468
|
+
<SchemaDefinition schemaRef="#/components/schemas/historicRecord" />`,
|
|
484
469
|
},
|
|
485
470
|
{
|
|
486
471
|
name: 'Background work',
|
|
@@ -525,9 +510,9 @@ for more information.`,
|
|
|
525
510
|
name: 'Integrations introduction',
|
|
526
511
|
'x-displayName': 'Integrations',
|
|
527
512
|
description: `
|
|
528
|
-
Some of the background work of this API are integrations with other systems. These integrations work by scanning the historic records
|
|
529
|
-
|
|
530
|
-
|
|
513
|
+
Some of the background work of this API are integrations with other systems. These integrations work by scanning the historic records in
|
|
514
|
+
chronological order and deciding what to do for each one, if anything. The integrations store their results in the \`integrations\` field
|
|
515
|
+
of each record.
|
|
531
516
|
|
|
532
517
|
Super administrators can search the historic records by integration name and result to find for example those records where the integration
|
|
533
518
|
failed and why. See the [historic records](#tag/Historic-records) endpoints for more information.
|
|
@@ -550,68 +535,73 @@ This API is integrated with the main systems of GLS Spain. The integration goes
|
|
|
550
535
|
This integration configuration can be found using the [find integrations endpoint](#tag/Integrations/paths/~1integrations~1find/post),
|
|
551
536
|
under the \`GLS Spain\` name. Its \`networks\` field lists the networks it applies to.
|
|
552
537
|
|
|
553
|
-
The
|
|
538
|
+
The following table lists all the possible events along with the historic record that causes them to be sent:
|
|
539
|
+
|
|
540
|
+
| Event | Record type | Record action | Record details |
|
|
541
|
+
| :--- | :--- | :--- | :--- |
|
|
542
|
+
| upsert network | \`network\` | \`update\` | - |
|
|
543
|
+
| upsert shop | \`shop\` | \`create\` or \`update\` | - |
|
|
544
|
+
| receive from driver | \`expedition\` | \`update\` | \`receiveFromDriver\` |
|
|
545
|
+
| receive from customer | \`expedition\` | \`update\` | \`receiveFromCustomer\` |
|
|
546
|
+
| give to customer | \`expedition\` | \`update\` | \`giveToCustomer\` |
|
|
547
|
+
| give to driver | \`expedition\` | \`update\` | \`giveToDriver\` |
|
|
548
|
+
| expiration reminder | \`expedition\` | \`update\` | \`expirationReminder\` |
|
|
549
|
+
| expired | \`expedition\` | \`update\` | \`expired\` |
|
|
550
|
+
| price | \`expedition\` | \`update\` | \`price\` |
|
|
551
|
+
|
|
552
|
+
The following are the request bodies sent for each event:
|
|
554
553
|
|
|
555
554
|
## Upsert network event
|
|
556
555
|
|
|
557
|
-
Sent when a network
|
|
558
|
-
endpoint is called.
|
|
556
|
+
Sent when a network is updated.
|
|
559
557
|
|
|
560
558
|
<SchemaDefinition schemaRef="#/components/schemas/upsertNetworkEvent" />
|
|
561
559
|
|
|
562
560
|
## Upsert shop event
|
|
563
561
|
|
|
564
|
-
Sent when a shop
|
|
565
|
-
[/shops/create](#tag/Shops/paths/~1shops~1create/post) or [/shops/update](#tag/Shops/paths/~1shops~1update/post) endpoints are called.
|
|
562
|
+
Sent when a shop is created or updated.
|
|
566
563
|
|
|
567
564
|
<SchemaDefinition schemaRef="#/components/schemas/upsertShopEvent" />
|
|
568
565
|
|
|
569
566
|
## Receive from driver event
|
|
570
567
|
|
|
571
|
-
Sent when
|
|
572
|
-
[/expeditions/receiveFromDriver](#tag/Expeditions/paths/~1expeditions~1receiveFromDriver/post) endpoint is called.
|
|
568
|
+
Sent when a shop receives an expedition from a driver.
|
|
573
569
|
|
|
574
570
|
<SchemaDefinition schemaRef="#/components/schemas/receiveFromDriverEvent" />
|
|
575
571
|
|
|
576
572
|
## Receive from customer event
|
|
577
573
|
|
|
578
|
-
Sent when
|
|
579
|
-
[/expeditions/receiveFromCustomer](#tag/Expeditions/paths/~1expeditions~1receiveFromCustomer/post) is called.
|
|
574
|
+
Sent when a shop receives an expedition from a customer.
|
|
580
575
|
|
|
581
576
|
<SchemaDefinition schemaRef="#/components/schemas/receiveFromCustomerEvent" />
|
|
582
577
|
|
|
583
578
|
## Give to customer event
|
|
584
579
|
|
|
585
|
-
Sent when
|
|
586
|
-
[/expeditions/giveToCustomer](#tag/Expeditions/paths/~1expeditions~1giveToCustomer/post) endpoint is called.
|
|
580
|
+
Sent when a shop delivers an expedition to a customer.
|
|
587
581
|
|
|
588
582
|
<SchemaDefinition schemaRef="#/components/schemas/giveToCustomerEvent" />
|
|
589
583
|
|
|
590
584
|
## Give to driver event
|
|
591
585
|
|
|
592
|
-
Sent when
|
|
593
|
-
[/expeditions/giveToDriver](#tag/Expeditions/paths/~1expeditions~1giveToDriver/post) endpoint is called.
|
|
586
|
+
Sent when a shop delivers an expedition to a driver.
|
|
594
587
|
|
|
595
588
|
<SchemaDefinition schemaRef="#/components/schemas/giveToDriverEvent" />
|
|
596
589
|
|
|
597
590
|
## Expiration reminder event
|
|
598
591
|
|
|
599
|
-
Sent when
|
|
600
|
-
background that it is time to remind the customer to pick up the expedition.
|
|
592
|
+
Sent when the API detects in the background that it is time to remind the customer to pick up the expedition and updates its status.
|
|
601
593
|
|
|
602
594
|
<SchemaDefinition schemaRef="#/components/schemas/expirationReminderEvent" />
|
|
603
595
|
|
|
604
596
|
## Expired event
|
|
605
597
|
|
|
606
|
-
Sent when
|
|
607
|
-
the expedition has expired and updates its status.
|
|
598
|
+
Sent when the API detects in the background that it is time to expire the expedition and updates its status.
|
|
608
599
|
|
|
609
600
|
<SchemaDefinition schemaRef="#/components/schemas/expiredEvent" />
|
|
610
601
|
|
|
611
602
|
## Price event
|
|
612
603
|
|
|
613
|
-
Sent when an expedition
|
|
614
|
-
that anytime the weight or packages are updated.
|
|
604
|
+
Sent for the first time when an expedition is received at a shop, and after that any time the weight or packages are updated.
|
|
615
605
|
|
|
616
606
|
<SchemaDefinition schemaRef="#/components/schemas/priceEvent" />`,
|
|
617
607
|
},
|
|
@@ -1022,6 +1012,7 @@ Any optional array property that is not provided will default to an empty array.
|
|
|
1022
1012
|
openApiSpec.components = {
|
|
1023
1013
|
schemas: {
|
|
1024
1014
|
errorResponse: errorResponse(),
|
|
1015
|
+
defaults: defaults(),
|
|
1025
1016
|
superAdmin: superAdmin(),
|
|
1026
1017
|
networkAdmin: networkAdmin(),
|
|
1027
1018
|
shopUser: shopUser(),
|
|
@@ -1041,9 +1032,7 @@ openApiSpec.components = {
|
|
|
1041
1032
|
timezoneNames: timezoneNames(),
|
|
1042
1033
|
representative: representative(),
|
|
1043
1034
|
zone: zone(),
|
|
1044
|
-
|
|
1045
|
-
shopHistoricRecord: shopHistoricRecord(),
|
|
1046
|
-
expeditionHistoricRecord: expeditionHistoricRecord(),
|
|
1035
|
+
historicRecord: historicRecord(),
|
|
1047
1036
|
integration: integration(),
|
|
1048
1037
|
},
|
|
1049
1038
|
};
|
|
@@ -1284,40 +1273,6 @@ ${securitySchemes.superAdminRole}`,
|
|
|
1284
1273
|
},
|
|
1285
1274
|
},
|
|
1286
1275
|
},
|
|
1287
|
-
'/integrations/find': {
|
|
1288
|
-
post: {
|
|
1289
|
-
tags: ['Integrations'],
|
|
1290
|
-
summary: '[S] Find',
|
|
1291
|
-
description: `
|
|
1292
|
-
Finds all the integrations of the API and what networks they apply to.
|
|
1293
|
-
|
|
1294
|
-
To see what each integration actually does read that integration documentation in the [integrations](#tag/Integrations-introduction)
|
|
1295
|
-
section.
|
|
1296
|
-
|
|
1297
|
-
${descriptions.findLimitTip}
|
|
1298
|
-
|
|
1299
|
-
${securitySchemes.tokens}
|
|
1300
|
-
${securitySchemes.superAdminRole}`,
|
|
1301
|
-
requestBody: {
|
|
1302
|
-
content: { 'application/json': { schema: findIntegrationsRequest() } },
|
|
1303
|
-
required: true,
|
|
1304
|
-
},
|
|
1305
|
-
responses: {
|
|
1306
|
-
' 200': {
|
|
1307
|
-
description: 'Contains the found integrations.',
|
|
1308
|
-
content: { 'application/json': { schema: findIntegrationsResponse() } },
|
|
1309
|
-
},
|
|
1310
|
-
' 400': responses.badRequest,
|
|
1311
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
1312
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
1313
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
1314
|
-
' 401 ': responses.unauthorized,
|
|
1315
|
-
' 403': responses.forbidden,
|
|
1316
|
-
' 415': responses.unsupportedMediaType,
|
|
1317
|
-
' 500': responses.internalServerError,
|
|
1318
|
-
},
|
|
1319
|
-
},
|
|
1320
|
-
},
|
|
1321
1276
|
'/superAdmins/create': {
|
|
1322
1277
|
post: {
|
|
1323
1278
|
tags: ['Super admins'],
|
|
@@ -1946,6 +1901,196 @@ ${securitySchemes.superAdminRole}`,
|
|
|
1946
1901
|
},
|
|
1947
1902
|
},
|
|
1948
1903
|
},
|
|
1904
|
+
'/representatives/create': {
|
|
1905
|
+
post: {
|
|
1906
|
+
tags: ['Sales representatives'],
|
|
1907
|
+
summary: '[S] Create',
|
|
1908
|
+
description: `
|
|
1909
|
+
Creates a new sales representative.
|
|
1910
|
+
|
|
1911
|
+
${descriptions.createIdIsOptional}
|
|
1912
|
+
|
|
1913
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
1914
|
+
|
|
1915
|
+
${securitySchemes.tokens}
|
|
1916
|
+
${securitySchemes.superAdminRole}`,
|
|
1917
|
+
requestBody: {
|
|
1918
|
+
content: { 'application/json': { schema: createRepresentativeRequest() } },
|
|
1919
|
+
required: true,
|
|
1920
|
+
},
|
|
1921
|
+
responses: {
|
|
1922
|
+
' 200': {
|
|
1923
|
+
description: 'Contains the created sales representative.',
|
|
1924
|
+
content: { 'application/json': { schema: createRepresentativeResponse() } },
|
|
1925
|
+
},
|
|
1926
|
+
' 400': responses.badRequest,
|
|
1927
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1928
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1929
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1930
|
+
' 401 ': responses.unauthorized,
|
|
1931
|
+
' 403': responses.forbidden,
|
|
1932
|
+
' 415': responses.unsupportedMediaType,
|
|
1933
|
+
' 500': responses.internalServerError,
|
|
1934
|
+
' 500 ': responses.representativeAlreadyExists,
|
|
1935
|
+
},
|
|
1936
|
+
},
|
|
1937
|
+
},
|
|
1938
|
+
'/representatives/listNames': {
|
|
1939
|
+
get: {
|
|
1940
|
+
tags: ['Sales representatives'],
|
|
1941
|
+
summary: '[S] List names',
|
|
1942
|
+
description: `
|
|
1943
|
+
Finds sales representatives and returns only the \`_id\` and \`name\` properties for each one.
|
|
1944
|
+
|
|
1945
|
+
${securitySchemes.tokens}
|
|
1946
|
+
${securitySchemes.superAdminRole}`,
|
|
1947
|
+
responses: {
|
|
1948
|
+
' 200': {
|
|
1949
|
+
description: 'Contains the found sales representatives names.',
|
|
1950
|
+
content: { 'application/json': { schema: listRepresentativesNamesResponse() } },
|
|
1951
|
+
},
|
|
1952
|
+
' 400': responses.badRequest,
|
|
1953
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1954
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1955
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1956
|
+
' 401 ': responses.unauthorized,
|
|
1957
|
+
' 403': responses.forbidden,
|
|
1958
|
+
' 415': responses.unsupportedMediaType,
|
|
1959
|
+
' 500': responses.internalServerError,
|
|
1960
|
+
},
|
|
1961
|
+
},
|
|
1962
|
+
},
|
|
1963
|
+
'/representatives/find': {
|
|
1964
|
+
post: {
|
|
1965
|
+
tags: ['Sales representatives'],
|
|
1966
|
+
summary: '[S] Find',
|
|
1967
|
+
description: `
|
|
1968
|
+
Finds sales representatives by one of several filters.
|
|
1969
|
+
|
|
1970
|
+
${descriptions.findLimitTip}
|
|
1971
|
+
|
|
1972
|
+
${securitySchemes.tokens}
|
|
1973
|
+
${securitySchemes.superAdminRole}`,
|
|
1974
|
+
requestBody: {
|
|
1975
|
+
content: { 'application/json': { schema: findRepresentativesRequest() } },
|
|
1976
|
+
required: true,
|
|
1977
|
+
},
|
|
1978
|
+
responses: {
|
|
1979
|
+
' 200': {
|
|
1980
|
+
description: 'Contains the found sales representatives.',
|
|
1981
|
+
content: { 'application/json': { schema: findRepresentativesResponse() } },
|
|
1982
|
+
},
|
|
1983
|
+
' 400': responses.badRequest,
|
|
1984
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
1985
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
1986
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
1987
|
+
' 401 ': responses.unauthorized,
|
|
1988
|
+
' 403': responses.forbidden,
|
|
1989
|
+
' 415': responses.unsupportedMediaType,
|
|
1990
|
+
' 500': responses.internalServerError,
|
|
1991
|
+
},
|
|
1992
|
+
},
|
|
1993
|
+
},
|
|
1994
|
+
'/representatives/update': {
|
|
1995
|
+
post: {
|
|
1996
|
+
tags: ['Sales representatives'],
|
|
1997
|
+
summary: '[S] Update',
|
|
1998
|
+
description: `
|
|
1999
|
+
Finds a sales representative and updates the provided properties.
|
|
2000
|
+
|
|
2001
|
+
${descriptions.updateSetAddOrRemove}
|
|
2002
|
+
|
|
2003
|
+
${securitySchemes.tokens}
|
|
2004
|
+
${securitySchemes.superAdminRole}`,
|
|
2005
|
+
requestBody: {
|
|
2006
|
+
content: { 'application/json': { schema: updateRepresentativeRequest() } },
|
|
2007
|
+
required: true,
|
|
2008
|
+
},
|
|
2009
|
+
responses: {
|
|
2010
|
+
' 200': {
|
|
2011
|
+
description: 'Contains the updated sales representative.',
|
|
2012
|
+
content: { 'application/json': { schema: updateRepresentativeResponse() } },
|
|
2013
|
+
},
|
|
2014
|
+
' 400': responses.badRequest,
|
|
2015
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2016
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2017
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2018
|
+
' 401 ': responses.unauthorized,
|
|
2019
|
+
' 403': responses.forbidden,
|
|
2020
|
+
' 415': responses.unsupportedMediaType,
|
|
2021
|
+
' 500': responses.internalServerError,
|
|
2022
|
+
' 500 ': responses.representativeDoesNotExist,
|
|
2023
|
+
},
|
|
2024
|
+
},
|
|
2025
|
+
},
|
|
2026
|
+
'/representatives/getCommissions': {
|
|
2027
|
+
post: {
|
|
2028
|
+
tags: ['Sales representatives'],
|
|
2029
|
+
summary: '[S] Get commissions',
|
|
2030
|
+
description: `
|
|
2031
|
+
Gets the commissions earned by a representative between two dates.
|
|
2032
|
+
|
|
2033
|
+
The commissions are calculated by zones. For each zone the commissions include how many shops the representative has opened in that date
|
|
2034
|
+
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
|
|
2035
|
+
shops is configured in the zone commissions.
|
|
2036
|
+
|
|
2037
|
+
${securitySchemes.tokens}
|
|
2038
|
+
${securitySchemes.superAdminRole}`,
|
|
2039
|
+
requestBody: {
|
|
2040
|
+
content: { 'application/json': { schema: getRepresentativeCommissionsRequest() } },
|
|
2041
|
+
required: true,
|
|
2042
|
+
},
|
|
2043
|
+
responses: {
|
|
2044
|
+
' 200': {
|
|
2045
|
+
description: 'Contains the commissions for that representative and date range.',
|
|
2046
|
+
content: { 'application/json': { schema: getRepresentativeCommissionsResponse() } },
|
|
2047
|
+
},
|
|
2048
|
+
' 400': responses.badRequest,
|
|
2049
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2050
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2051
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2052
|
+
' 401 ': responses.unauthorized,
|
|
2053
|
+
' 403': responses.forbidden,
|
|
2054
|
+
' 415': responses.unsupportedMediaType,
|
|
2055
|
+
' 500': responses.internalServerError,
|
|
2056
|
+
' 500 ': responses.representativeDoesNotExist,
|
|
2057
|
+
},
|
|
2058
|
+
},
|
|
2059
|
+
},
|
|
2060
|
+
'/representatives/delete': {
|
|
2061
|
+
post: {
|
|
2062
|
+
tags: ['Sales representatives'],
|
|
2063
|
+
summary: '[S] Delete',
|
|
2064
|
+
description: `
|
|
2065
|
+
Deletes a sales representative.
|
|
2066
|
+
|
|
2067
|
+
A sales representative whose \`deletable\` property is \`false\` cannot be deleted because it has shops associated to it.
|
|
2068
|
+
If you try the API will return a \`500 RepresentativeCannotBeDeletedError\`.
|
|
2069
|
+
|
|
2070
|
+
${securitySchemes.tokens}
|
|
2071
|
+
${securitySchemes.superAdminRole}`,
|
|
2072
|
+
requestBody: {
|
|
2073
|
+
content: { 'application/json': { schema: deleteRepresentativeRequest() } },
|
|
2074
|
+
required: true,
|
|
2075
|
+
},
|
|
2076
|
+
responses: {
|
|
2077
|
+
' 200': {
|
|
2078
|
+
description: 'Contains the deleted sales representative.',
|
|
2079
|
+
content: { 'application/json': { schema: deleteRepresentativeResponse() } },
|
|
2080
|
+
},
|
|
2081
|
+
' 400': responses.badRequest,
|
|
2082
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2083
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2084
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2085
|
+
' 401 ': responses.unauthorized,
|
|
2086
|
+
' 403': responses.forbidden,
|
|
2087
|
+
' 415': responses.unsupportedMediaType,
|
|
2088
|
+
' 500': responses.internalServerError,
|
|
2089
|
+
' 500 ': responses.representativeDoesNotExist,
|
|
2090
|
+
' 500 ': responses.representativeCannotBeDeleted,
|
|
2091
|
+
},
|
|
2092
|
+
},
|
|
2093
|
+
},
|
|
1949
2094
|
'/shops/create': {
|
|
1950
2095
|
post: {
|
|
1951
2096
|
tags: ['Shops'],
|
|
@@ -2814,182 +2959,28 @@ ${securitySchemes.anyRole}`,
|
|
|
2814
2959
|
},
|
|
2815
2960
|
},
|
|
2816
2961
|
},
|
|
2817
|
-
'/
|
|
2818
|
-
post: {
|
|
2819
|
-
tags: ['Sales representatives'],
|
|
2820
|
-
summary: '[S] Create',
|
|
2821
|
-
description: `
|
|
2822
|
-
Creates a new sales representative.
|
|
2823
|
-
|
|
2824
|
-
${descriptions.createIdIsOptional}
|
|
2825
|
-
|
|
2826
|
-
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
2827
|
-
|
|
2828
|
-
${securitySchemes.tokens}
|
|
2829
|
-
${securitySchemes.superAdminRole}`,
|
|
2830
|
-
requestBody: {
|
|
2831
|
-
content: { 'application/json': { schema: createRepresentativeRequest() } },
|
|
2832
|
-
required: true,
|
|
2833
|
-
},
|
|
2834
|
-
responses: {
|
|
2835
|
-
' 200': {
|
|
2836
|
-
description: 'Contains the created sales representative.',
|
|
2837
|
-
content: { 'application/json': { schema: createRepresentativeResponse() } },
|
|
2838
|
-
},
|
|
2839
|
-
' 400': responses.badRequest,
|
|
2840
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
2841
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
2842
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
2843
|
-
' 401 ': responses.unauthorized,
|
|
2844
|
-
' 403': responses.forbidden,
|
|
2845
|
-
' 415': responses.unsupportedMediaType,
|
|
2846
|
-
' 500': responses.internalServerError,
|
|
2847
|
-
' 500 ': responses.representativeAlreadyExists,
|
|
2848
|
-
},
|
|
2849
|
-
},
|
|
2850
|
-
},
|
|
2851
|
-
'/representatives/listNames': {
|
|
2852
|
-
get: {
|
|
2853
|
-
tags: ['Sales representatives'],
|
|
2854
|
-
summary: '[S] List names',
|
|
2855
|
-
description: `
|
|
2856
|
-
Finds sales representatives and returns only the \`_id\` and \`name\` properties for each one.
|
|
2857
|
-
|
|
2858
|
-
${securitySchemes.tokens}
|
|
2859
|
-
${securitySchemes.superAdminRole}`,
|
|
2860
|
-
responses: {
|
|
2861
|
-
' 200': {
|
|
2862
|
-
description: 'Contains the found sales representatives names.',
|
|
2863
|
-
content: { 'application/json': { schema: listRepresentativesNamesResponse() } },
|
|
2864
|
-
},
|
|
2865
|
-
' 400': responses.badRequest,
|
|
2866
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
2867
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
2868
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
2869
|
-
' 401 ': responses.unauthorized,
|
|
2870
|
-
' 403': responses.forbidden,
|
|
2871
|
-
' 415': responses.unsupportedMediaType,
|
|
2872
|
-
' 500': responses.internalServerError,
|
|
2873
|
-
},
|
|
2874
|
-
},
|
|
2875
|
-
},
|
|
2876
|
-
'/representatives/find': {
|
|
2962
|
+
'/historicRecords/find': {
|
|
2877
2963
|
post: {
|
|
2878
|
-
tags: ['
|
|
2964
|
+
tags: ['Historic records'],
|
|
2879
2965
|
summary: '[S] Find',
|
|
2880
2966
|
description: `
|
|
2881
|
-
Finds
|
|
2882
|
-
|
|
2883
|
-
${descriptions.findLimitTip}
|
|
2884
|
-
|
|
2885
|
-
${securitySchemes.tokens}
|
|
2886
|
-
${securitySchemes.superAdminRole}`,
|
|
2887
|
-
requestBody: {
|
|
2888
|
-
content: { 'application/json': { schema: findRepresentativesRequest() } },
|
|
2889
|
-
required: true,
|
|
2890
|
-
},
|
|
2891
|
-
responses: {
|
|
2892
|
-
' 200': {
|
|
2893
|
-
description: 'Contains the found sales representatives.',
|
|
2894
|
-
content: { 'application/json': { schema: findRepresentativesResponse() } },
|
|
2895
|
-
},
|
|
2896
|
-
' 400': responses.badRequest,
|
|
2897
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
2898
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
2899
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
2900
|
-
' 401 ': responses.unauthorized,
|
|
2901
|
-
' 403': responses.forbidden,
|
|
2902
|
-
' 415': responses.unsupportedMediaType,
|
|
2903
|
-
' 500': responses.internalServerError,
|
|
2904
|
-
},
|
|
2905
|
-
},
|
|
2906
|
-
},
|
|
2907
|
-
'/representatives/update': {
|
|
2908
|
-
post: {
|
|
2909
|
-
tags: ['Sales representatives'],
|
|
2910
|
-
summary: '[S] Update',
|
|
2911
|
-
description: `
|
|
2912
|
-
Finds a sales representative and updates the provided properties.
|
|
2913
|
-
|
|
2914
|
-
${descriptions.updateSetAddOrRemove}
|
|
2915
|
-
|
|
2916
|
-
${securitySchemes.tokens}
|
|
2917
|
-
${securitySchemes.superAdminRole}`,
|
|
2918
|
-
requestBody: {
|
|
2919
|
-
content: { 'application/json': { schema: updateRepresentativeRequest() } },
|
|
2920
|
-
required: true,
|
|
2921
|
-
},
|
|
2922
|
-
responses: {
|
|
2923
|
-
' 200': {
|
|
2924
|
-
description: 'Contains the updated sales representative.',
|
|
2925
|
-
content: { 'application/json': { schema: updateRepresentativeResponse() } },
|
|
2926
|
-
},
|
|
2927
|
-
' 400': responses.badRequest,
|
|
2928
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
2929
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
2930
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
2931
|
-
' 401 ': responses.unauthorized,
|
|
2932
|
-
' 403': responses.forbidden,
|
|
2933
|
-
' 415': responses.unsupportedMediaType,
|
|
2934
|
-
' 500': responses.internalServerError,
|
|
2935
|
-
' 500 ': responses.representativeDoesNotExist,
|
|
2936
|
-
},
|
|
2937
|
-
},
|
|
2938
|
-
},
|
|
2939
|
-
'/representatives/getCommissions': {
|
|
2940
|
-
post: {
|
|
2941
|
-
tags: ['Sales representatives'],
|
|
2942
|
-
summary: '[S] Get commissions',
|
|
2943
|
-
description: `
|
|
2944
|
-
Gets the commissions earned by a representative between two dates.
|
|
2967
|
+
Finds historic records of resources or integration results.
|
|
2945
2968
|
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
shops is configured in the zone commissions.
|
|
2969
|
+
You can find all the records for a single resource or all the records processed by a single integration and with a specific result,
|
|
2970
|
+
for example \`failed\`.
|
|
2949
2971
|
|
|
2950
|
-
${
|
|
2951
|
-
${securitySchemes.superAdminRole}`,
|
|
2952
|
-
requestBody: {
|
|
2953
|
-
content: { 'application/json': { schema: getRepresentativeCommissionsRequest() } },
|
|
2954
|
-
required: true,
|
|
2955
|
-
},
|
|
2956
|
-
responses: {
|
|
2957
|
-
' 200': {
|
|
2958
|
-
description: 'Contains the commissions for that representative and date range.',
|
|
2959
|
-
content: { 'application/json': { schema: getRepresentativeCommissionsResponse() } },
|
|
2960
|
-
},
|
|
2961
|
-
' 400': responses.badRequest,
|
|
2962
|
-
' 401': responses.invalidUserInCookieOrHeader,
|
|
2963
|
-
' 401 ': responses.invalidCookieOrHeader,
|
|
2964
|
-
' 401 ': responses.missingCookieOrHeader,
|
|
2965
|
-
' 401 ': responses.unauthorized,
|
|
2966
|
-
' 403': responses.forbidden,
|
|
2967
|
-
' 415': responses.unsupportedMediaType,
|
|
2968
|
-
' 500': responses.internalServerError,
|
|
2969
|
-
' 500 ': responses.representativeDoesNotExist,
|
|
2970
|
-
},
|
|
2971
|
-
},
|
|
2972
|
-
},
|
|
2973
|
-
'/representatives/delete': {
|
|
2974
|
-
post: {
|
|
2975
|
-
tags: ['Sales representatives'],
|
|
2976
|
-
summary: '[S] Delete',
|
|
2977
|
-
description: `
|
|
2978
|
-
Deletes a sales representative.
|
|
2979
|
-
|
|
2980
|
-
A sales representative whose \`deletable\` property is \`false\` cannot be deleted because it has shops associated to it.
|
|
2981
|
-
If you try the API will return a \`500 RepresentativeCannotBeDeletedError\`.
|
|
2972
|
+
${descriptions.findLimitTip}
|
|
2982
2973
|
|
|
2983
2974
|
${securitySchemes.tokens}
|
|
2984
2975
|
${securitySchemes.superAdminRole}`,
|
|
2985
2976
|
requestBody: {
|
|
2986
|
-
content: { 'application/json': { schema:
|
|
2977
|
+
content: { 'application/json': { schema: findHistoricRecordsRequest() } },
|
|
2987
2978
|
required: true,
|
|
2988
2979
|
},
|
|
2989
2980
|
responses: {
|
|
2990
2981
|
' 200': {
|
|
2991
|
-
description: 'Contains the
|
|
2992
|
-
content: { 'application/json': { schema:
|
|
2982
|
+
description: 'Contains the found historic records.',
|
|
2983
|
+
content: { 'application/json': { schema: findHistoricRecordsResponse() } },
|
|
2993
2984
|
},
|
|
2994
2985
|
' 400': responses.badRequest,
|
|
2995
2986
|
' 401': responses.invalidUserInCookieOrHeader,
|
|
@@ -2999,33 +2990,31 @@ ${securitySchemes.superAdminRole}`,
|
|
|
2999
2990
|
' 403': responses.forbidden,
|
|
3000
2991
|
' 415': responses.unsupportedMediaType,
|
|
3001
2992
|
' 500': responses.internalServerError,
|
|
3002
|
-
' 500 ': responses.representativeDoesNotExist,
|
|
3003
|
-
' 500 ': responses.representativeCannotBeDeleted,
|
|
3004
2993
|
},
|
|
3005
2994
|
},
|
|
3006
2995
|
},
|
|
3007
|
-
'/
|
|
2996
|
+
'/integrations/find': {
|
|
3008
2997
|
post: {
|
|
3009
|
-
tags: ['
|
|
2998
|
+
tags: ['Integrations'],
|
|
3010
2999
|
summary: '[S] Find',
|
|
3011
3000
|
description: `
|
|
3012
|
-
Finds
|
|
3001
|
+
Finds all the integrations of the API and what networks they apply to.
|
|
3013
3002
|
|
|
3014
|
-
|
|
3015
|
-
|
|
3003
|
+
To see what each integration actually does read that integration documentation in the [integrations](#tag/Integrations-introduction)
|
|
3004
|
+
section.
|
|
3016
3005
|
|
|
3017
3006
|
${descriptions.findLimitTip}
|
|
3018
3007
|
|
|
3019
3008
|
${securitySchemes.tokens}
|
|
3020
3009
|
${securitySchemes.superAdminRole}`,
|
|
3021
3010
|
requestBody: {
|
|
3022
|
-
content: { 'application/json': { schema:
|
|
3011
|
+
content: { 'application/json': { schema: findIntegrationsRequest() } },
|
|
3023
3012
|
required: true,
|
|
3024
3013
|
},
|
|
3025
3014
|
responses: {
|
|
3026
3015
|
' 200': {
|
|
3027
|
-
description: 'Contains the found
|
|
3028
|
-
content: { 'application/json': { schema:
|
|
3016
|
+
description: 'Contains the found integrations.',
|
|
3017
|
+
content: { 'application/json': { schema: findIntegrationsResponse() } },
|
|
3029
3018
|
},
|
|
3030
3019
|
' 400': responses.badRequest,
|
|
3031
3020
|
' 401': responses.invalidUserInCookieOrHeader,
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { money, updateSelfRequest, updateResponse, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
1
|
+
const { uuid, datetime, money, updateSelfRequest, updateResponse, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
2
2
|
|
|
3
3
|
const derivationRate = () => ({
|
|
4
4
|
title: 'derivation rate',
|
|
@@ -48,10 +48,14 @@ const defaults = () => ({
|
|
|
48
48
|
title: 'defaults',
|
|
49
49
|
type: 'object',
|
|
50
50
|
properties: {
|
|
51
|
+
_id: uuid(),
|
|
52
|
+
createdAt: datetime(),
|
|
53
|
+
updatedAt: datetime(),
|
|
54
|
+
deletable: { type: 'boolean' },
|
|
51
55
|
derivationSettings: derivationSettings(),
|
|
52
56
|
expirationSettings: expirationSettings(),
|
|
53
57
|
},
|
|
54
|
-
required: ['derivationSettings', 'expirationSettings'],
|
|
58
|
+
required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'derivationSettings', 'expirationSettings'],
|
|
55
59
|
additionalProperties: false,
|
|
56
60
|
});
|
|
57
61
|
|
|
@@ -1,19 +1,44 @@
|
|
|
1
|
-
const { uuid, datetime, findRequest, findResponse,
|
|
2
|
-
const {
|
|
3
|
-
const {
|
|
4
|
-
const {
|
|
1
|
+
const { uuid, datetime, objectWithUuid, findRequest, findResponse, pickProperties } = require('@gls_spain/common-json-schemas');
|
|
2
|
+
const { superAdmin, networkAdmin, shopUser } = require('./users');
|
|
3
|
+
const { defaults } = require('./defaults');
|
|
4
|
+
const { network } = require('./networks');
|
|
5
|
+
const { zone } = require('./zones');
|
|
6
|
+
const { representative } = require('./representatives');
|
|
7
|
+
const { shop } = require('./shops');
|
|
8
|
+
const { expedition } = require('./expeditions');
|
|
5
9
|
const { integration } = require('./integrations');
|
|
6
10
|
|
|
7
|
-
const
|
|
11
|
+
const historicRecord = () => ({
|
|
12
|
+
title: 'historicRecord',
|
|
8
13
|
type: 'object',
|
|
9
14
|
properties: {
|
|
10
15
|
_id: uuid(),
|
|
11
16
|
createdAt: datetime(),
|
|
12
17
|
updatedAt: datetime(),
|
|
13
18
|
deletable: { type: 'boolean' },
|
|
19
|
+
type: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
enum: ['defaults', 'superAdmin', 'network', 'networkAdmin', 'zone', 'representative', 'shop', 'shopUser', 'expedition'],
|
|
22
|
+
},
|
|
14
23
|
action: { type: 'string', enum: ['create', 'update', 'delete'] },
|
|
15
|
-
|
|
24
|
+
actionDetails: {
|
|
25
|
+
type: 'array',
|
|
26
|
+
items: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
enum: [
|
|
29
|
+
'receiveFromDriver',
|
|
30
|
+
'receiveFromCustomer',
|
|
31
|
+
'giveToDriver',
|
|
32
|
+
'giveToCustomer',
|
|
33
|
+
'redirect',
|
|
34
|
+
'expirationReminder',
|
|
35
|
+
'expired',
|
|
36
|
+
'price',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
16
40
|
actor: { type: 'string', description: 'the username of the user who made the action' },
|
|
41
|
+
document: { oneOf: [defaults(), superAdmin(), network(), networkAdmin(), zone(), representative(), shop(), shopUser(), expedition()] },
|
|
17
42
|
integrations: {
|
|
18
43
|
type: 'object',
|
|
19
44
|
additionalProperties: {
|
|
@@ -29,73 +54,30 @@ const baseHistoricRecord = () => ({
|
|
|
29
54
|
description: 'one property per integration where the property name is the name of the integration',
|
|
30
55
|
},
|
|
31
56
|
},
|
|
32
|
-
required: ['_id', 'createdAt', 'updatedAt', 'action', '
|
|
57
|
+
required: ['_id', 'createdAt', 'updatedAt', 'deletable', 'type', 'action', 'actionDetails', 'actor', 'document', 'integrations'],
|
|
33
58
|
additionalProperties: false,
|
|
34
59
|
});
|
|
35
60
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const shopHistoricRecord = () =>
|
|
47
|
-
mergeSchemas(baseHistoricRecord(), {
|
|
48
|
-
title: 'shop historic record',
|
|
49
|
-
properties: {
|
|
50
|
-
shop: shop(),
|
|
51
|
-
},
|
|
52
|
-
required: ['shop'],
|
|
53
|
-
additionalProperties: false,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const expeditionHistoricRecord = () =>
|
|
57
|
-
mergeSchemas(baseHistoricRecord(), {
|
|
58
|
-
title: 'expedition historic record',
|
|
59
|
-
properties: {
|
|
60
|
-
actionExtras: {
|
|
61
|
-
type: 'array',
|
|
62
|
-
items: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
enum: [
|
|
65
|
-
'receiveFromDriver',
|
|
66
|
-
'receiveFromCustomer',
|
|
67
|
-
'giveToDriver',
|
|
68
|
-
'giveToCustomer',
|
|
69
|
-
'redirect',
|
|
70
|
-
'expirationReminder',
|
|
71
|
-
'expired',
|
|
72
|
-
'price',
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
expedition: expedition(),
|
|
77
|
-
},
|
|
78
|
-
required: ['expedition'],
|
|
79
|
-
additionalProperties: false,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const historicRecord = () => ({ oneOf: [networkHistoricRecord(), shopHistoricRecord(), expeditionHistoricRecord()] });
|
|
83
|
-
|
|
84
|
-
const findByNetwork = () => mergeSchemas(objectWithNetworkId(), { title: 'find by network' });
|
|
85
|
-
|
|
86
|
-
const findByShop = () => mergeSchemas(objectWithShopId(), { title: 'find by shop' });
|
|
87
|
-
|
|
88
|
-
const findByExpedition = () => mergeSchemas(objectWithExpeditionId(), { title: 'find by expedition' });
|
|
61
|
+
const findByTypeAndDocumentId = () => ({
|
|
62
|
+
title: 'find by type and document _id',
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
...pickProperties(historicRecord(), ['type']),
|
|
66
|
+
document: objectWithUuid(),
|
|
67
|
+
},
|
|
68
|
+
required: ['type', 'document'],
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
});
|
|
89
71
|
|
|
90
|
-
const
|
|
91
|
-
title: 'find by integration and result',
|
|
72
|
+
const findByIntegrationNameAndResult = () => ({
|
|
73
|
+
title: 'find by integration name and result',
|
|
92
74
|
type: 'object',
|
|
93
75
|
properties: {
|
|
94
76
|
integration: {
|
|
95
77
|
type: 'object',
|
|
96
78
|
properties: {
|
|
97
79
|
...pickProperties(integration(), ['name']),
|
|
98
|
-
...pickProperties(
|
|
80
|
+
...pickProperties(historicRecord().properties.integrations.additionalProperties, ['result']),
|
|
99
81
|
},
|
|
100
82
|
required: ['name', 'result'],
|
|
101
83
|
additionalProperties: false,
|
|
@@ -105,15 +87,11 @@ const findByIntegrationAndResult = () => ({
|
|
|
105
87
|
additionalProperties: false,
|
|
106
88
|
});
|
|
107
89
|
|
|
108
|
-
const findHistoricRecordsRequest = () =>
|
|
109
|
-
findRequest({ oneOf: [findByNetwork(), findByShop(), findByExpedition(), findByIntegrationAndResult()] });
|
|
90
|
+
const findHistoricRecordsRequest = () => findRequest({ oneOf: [findByTypeAndDocumentId(), findByIntegrationNameAndResult()] });
|
|
110
91
|
|
|
111
92
|
const findHistoricRecordsResponse = () => findResponse(historicRecord());
|
|
112
93
|
|
|
113
94
|
module.exports = {
|
|
114
|
-
networkHistoricRecord,
|
|
115
|
-
shopHistoricRecord,
|
|
116
|
-
expeditionHistoricRecord,
|
|
117
95
|
historicRecord,
|
|
118
96
|
findHistoricRecordsRequest,
|
|
119
97
|
findHistoricRecordsResponse,
|
|
@@ -23,7 +23,12 @@ const network = () => ({
|
|
|
23
23
|
createdAt: datetime(),
|
|
24
24
|
updatedAt: datetime(),
|
|
25
25
|
deletable: { type: 'boolean' },
|
|
26
|
-
defaults:
|
|
26
|
+
defaults: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings']) },
|
|
29
|
+
required: ['derivationSettings', 'expirationSettings'],
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
},
|
|
27
32
|
name: { type: 'string', trim: true },
|
|
28
33
|
contacts: {
|
|
29
34
|
type: 'array',
|
|
@@ -92,7 +92,12 @@ const shop = () => ({
|
|
|
92
92
|
createdAt: datetime(),
|
|
93
93
|
updatedAt: datetime(),
|
|
94
94
|
deletable: { type: 'boolean' },
|
|
95
|
-
defaults:
|
|
95
|
+
defaults: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: { ...pickProperties(defaults(), ['derivationSettings', 'expirationSettings']) },
|
|
98
|
+
required: ['derivationSettings', 'expirationSettings'],
|
|
99
|
+
additionalProperties: false,
|
|
100
|
+
},
|
|
96
101
|
network: {
|
|
97
102
|
type: 'object',
|
|
98
103
|
properties: { ...pickProperties(network(), ['_id', 'name', 'derivationSettings', 'expirationSettings']) },
|