@gls_spain/gps-common 32.5.0 → 33.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.
@@ -38,9 +38,11 @@ const {
38
38
  ZoneDoesNotExistError,
39
39
  ZoneAlreadyExistsError,
40
40
  ZoneCannotBeDeletedError,
41
+ SaleAlreadyExistsError,
42
+ InconsistentSalesSettingsError,
43
+ InvalidSaleDestinationError,
41
44
  } = require('../errors');
42
45
  const { timezoneNames } = require('../schemas/definitions/common');
43
- const { initRequest, initResponse } = require('../schemas/definitions/init');
44
46
  const { loginResponse } = require('../schemas/definitions/login');
45
47
  const { logoutResponse } = require('../schemas/definitions/logout');
46
48
  const { becomeRequest } = require('../schemas/definitions/become');
@@ -135,6 +137,7 @@ const {
135
137
  priceEvent,
136
138
  upsertShopEvent,
137
139
  upsertNetworkEvent,
140
+ upsertSaleEvent,
138
141
  } = require('../schemas/definitions/gls-spain-integration-events');
139
142
  const {
140
143
  representative,
@@ -164,6 +167,17 @@ const {
164
167
  } = require('../schemas/definitions/zones');
165
168
  const { integration, findIntegrationsRequest, findIntegrationsResponse } = require('../schemas/definitions/integrations');
166
169
  const { historicRecord, findHistoricRecordsRequest, findHistoricRecordsResponse } = require('../schemas/definitions/historic-records');
170
+ const {
171
+ sale,
172
+ createSaleRequest,
173
+ createSaleResponse,
174
+ findSalesSuperAdminRequest,
175
+ findSalesNetworkAdminRequest,
176
+ findSalesShopUserRequest,
177
+ findSalesResponse,
178
+ checkSalePriceRequest,
179
+ checkSalePriceResponse,
180
+ } = require('../schemas/definitions/sales');
167
181
 
168
182
  const openApiSpec = { openapi: '3.0.2' };
169
183
 
@@ -200,36 +214,20 @@ openApiSpec.servers = [
200
214
  openApiSpec['x-tagGroups'] = [
201
215
  {
202
216
  name: '',
203
- tags: ['Introduction', 'Errors', 'Data formats'],
217
+ tags: ['Introduction', 'Errors', 'Deleting', 'Data formats', 'Historic records introduction'],
204
218
  },
205
219
  {
206
- name: 'RESOURCES',
220
+ name: 'BACKGROUND PROCESSES',
207
221
  tags: [
208
- 'Defaults',
209
- 'Counters',
210
- 'Super admin',
211
- 'Network',
212
- 'Network admin',
213
- 'Zone',
214
- 'Sales representative',
215
- 'Shop',
216
- 'Shop user',
217
- 'Expedition',
218
- 'Pod',
222
+ 'Types of background processes',
223
+ 'Eventual consistency',
224
+ 'Expeditions expiration',
225
+ 'GLS Spain integration',
226
+ 'GLS International integration',
227
+ 'GLS SMS integration',
228
+ 'Ingenico integration',
219
229
  ],
220
230
  },
221
- {
222
- name: 'HISTORIC RECORDS',
223
- tags: ['Historic records introduction'],
224
- },
225
- {
226
- name: 'BACKGROUND WORK',
227
- tags: ['Background work', 'Eventual consistency', 'Expeditions expiration'],
228
- },
229
- {
230
- name: 'INTEGRATIONS',
231
- tags: ['Integrations introduction', 'GLS Spain'],
232
- },
233
231
  {
234
232
  name: 'ENDPOINTS',
235
233
  tags: [
@@ -245,6 +243,7 @@ openApiSpec['x-tagGroups'] = [
245
243
  'Shop users',
246
244
  'Expeditions',
247
245
  'Pods',
246
+ 'Sales',
248
247
  'Historic records',
249
248
  'Integrations',
250
249
  ],
@@ -257,29 +256,27 @@ openApiSpec.tags = [
257
256
  description: `
258
257
  This is the API for managing GLS parcel shops, which are establishments that can store packages for the customers to pick up.
259
258
 
260
- Parcel shops are grouped by networks, which are the companies or associations that have a deal with GLS to use their
261
- establishments as parcel shops.
259
+ Parcel shops are grouped by networks, which are the companies or associations that have a deal with GLS to use their establishments as
260
+ parcel shops.
262
261
 
263
262
  The API can be used by 3 kinds of users:
264
263
 
265
264
  - Super admins: these are the GLS staff that manage the entire API. They can:
266
265
 
267
266
  - Manage all kinds of users, including other super admins.
268
- - Manage networks.
269
- - Manage shops from any network.
267
+ - Manage networks, zones, representatives, historic records and integrations.
268
+ - Manage shops, expeditions and sales from any network.
270
269
 
271
270
  - Network admins: these are the managers of a single network. They can:
272
271
 
273
- - Manage shops from their network.
272
+ - Manage shops, expeditions and sales from their network.
274
273
  - Manage their shop users.
275
274
 
276
275
  - Shop users: these are the staff that work at the parcel shops. They can:
277
276
 
278
277
  - View the shop inventory.
279
- - Receive packages from GLS.
280
- - Deliver packages to customers.
281
- - Receive returns from customers.
282
- - Give returns to GLS drivers.
278
+ - Receive and deliver packages.
279
+ - Sell delivery services to people.
283
280
  - etc...
284
281
 
285
282
  Every endpoint of this documentation has a caption before its name indicating who can use it: **[S]** for super admins,
@@ -303,6 +300,16 @@ An endpoint can return more than one error with the same HTTP status, e.g.:
303
300
  - \`500 UserCannotBeDeletedError\`.
304
301
 
305
302
  You will need to look at the name to differentiate them.`,
303
+ },
304
+ {
305
+ name: 'Deleting',
306
+ description: `
307
+ All resources have a \`deletable\` field that indicates if they can be deleted. It starts as \`true\` when the resource is created and it
308
+ changes to \`false\` when it is referenced as a dependency by another resource. Once changed it never changes back to \`true\`, even if the
309
+ dependent is deleted.
310
+
311
+ Trying to delete a non deletable resource will throw a deletion error, for example \`500 ShopCannotBeDeletedError\` when it is a shop.
312
+ `,
306
313
  },
307
314
  {
308
315
  name: 'Data formats',
@@ -310,7 +317,7 @@ You will need to look at the name to differentiate them.`,
310
317
  The API follows the [OpenAPI specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md)
311
318
  and the [JSON Schema draft 7 standard](https://json-schema.org/understanding-json-schema/index.html) for data types.
312
319
 
313
- There are two string formats that require special consideration: \`uuid\` and \`date-time\`.
320
+ There are three string formats that require special consideration: \`uuid\`, \`date-time\` and \`timezone\`.
314
321
 
315
322
  #### Strings with uuid format
316
323
 
@@ -342,167 +349,39 @@ The full list of allowed timezone names is:
342
349
 
343
350
  <SchemaDefinition schemaRef="#/components/schemas/timezoneNames" />
344
351
  `,
345
- },
346
- {
347
- name: 'Defaults',
348
- description: `
349
- The API has some default settings for networks and shops that do not specify their own, like the rate prices for deliveries and pickups,
350
- the maximum number of days that an expedition can be in a shop before returning it, etc.
351
-
352
- Super administrators can view and update this default settings using the [config](#tag/Config) endpoints.
353
-
354
- <SchemaDefinition schemaRef="#/components/schemas/defaults" />`,
355
- },
356
- {
357
- name: 'Counters',
358
- description: `
359
- Some of the API resources have fields that are auto incremental values. The API keeps a counter for each of these fields to know what the
360
- next value to use is.
361
-
362
- Super administrators can view the last values used for each auto incremental field using the [config](#tag/Config) endpoints.
363
-
364
- <SchemaDefinition schemaRef="#/components/schemas/counters" />`,
365
- },
366
- {
367
- name: 'Super admin',
368
- description: `
369
- Super administrators can manage all the resources of the API.
370
-
371
- An initial super administrator is created when the API is deployed (see [config](#tag/Config)) and then that super administrator
372
- can create additional super administrators using the [super admins](#tag/Super-admins) endpoints.
373
-
374
- <SchemaDefinition schemaRef="#/components/schemas/superAdmin" />`,
375
- },
376
- {
377
- name: 'Network',
378
- description: `
379
- Networks represent the providers of parcel shops, e.g. the companies or associations that have a deal with GLS to use
380
- their establishments as parcel shops. Every parcel shop belongs to a single network.
381
-
382
- Super administrators can manage networks using the [networks](#tag/Networks) endpoints.
383
-
384
- <SchemaDefinition schemaRef="#/components/schemas/network" />`,
385
- },
386
- {
387
- name: 'Network admin',
388
- description: `
389
- Network administrators are associated with a single network and they can view the parcel shops that belong to their network.
390
-
391
- Super administrators can manage network administrators using the [network admins](#tag/Network-admins) endpoints.
392
-
393
- <SchemaDefinition schemaRef="#/components/schemas/networkAdmin" />`,
394
- },
395
- {
396
- name: 'Zone',
397
- description: `
398
- Zones are geographic areas that define the commissions that the sales representatives earn for their work on the shops in those areas.
399
-
400
- Super administrators can create and manage zones using the [zones](#tag/Zones) endpoints, and then associate them to parcel shops and sales
401
- representatives on creation or update.
402
-
403
- <SchemaDefinition schemaRef="#/components/schemas/zone" />`,
404
- },
405
- {
406
- name: 'Sales representative',
407
- description: `
408
- Sales representatives are the GLS staff that make deals with businesses to open establishments as parcel shops. Each parcel shop
409
- 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
410
- managing it.
411
-
412
- Super administrators can create and manage sales representatives using the [sales representatives](#tag/Sales-representatives)
413
- endpoints, and then associate them to parcel shops on creation or update.
414
-
415
- <SchemaDefinition schemaRef="#/components/schemas/representative" />`,
416
- },
417
- {
418
- name: 'Shop',
419
- description: `
420
- Parcel shops are the establishments that GLS and the customers can use to deliver and pickup expeditions instead of doing
421
- it at the customers home.
422
-
423
- Every parcel shop is associated to a network, and it must have at least one shop user associated to it for the parcel
424
- shop to function.
425
-
426
- Super administrators can manage shops from any network and network administrators can view shops from their own network
427
- using the [shops](#tag/Shops) endpoints.
428
-
429
- <SchemaDefinition schemaRef="#/components/schemas/shop" />`,
430
- },
431
- {
432
- name: 'Shop user',
433
- description: `
434
- Shop users are associated with a single shop and they have limited capabilities to manage the shop and its expeditions,
435
- e.g. they can edit some of the shop properties or receive and deliver expeditions, but not edit anything else about them.
436
-
437
- Super administrators can manage shop users from any network and network administrators can view shop users from their
438
- own network using the [shop users](#tag/Shop-users) endpoints.
439
-
440
- <SchemaDefinition schemaRef="#/components/schemas/shopUser" />`,
441
- },
442
- {
443
- name: 'Expedition',
444
- description: `
445
- Expeditions are the packages that are delivered and picked up at parcel shops.
446
-
447
- Super administrators can manage expeditions using the [expeditions](#tag/Expeditions) endpoints. Shop users can also use
448
- some of those endpoints to receive and give expeditions from and to GLS and customers.
449
-
450
- <SchemaDefinition schemaRef="#/components/schemas/expedition" />`,
451
- },
452
- {
453
- name: 'Pod',
454
- description: `
455
- Expeditions that have been picked up by or delivered to a customer have a POD (Proof Of Delivery) associated to them that contains the
456
- signature of the customer.
457
-
458
- Pods are created automatically by the API when an expedition is picked up by or delivered to a customer.
459
-
460
- Super administrators, network administrators and shop users can use the [pods](#tag/Pods) endpoints to find the pods of the
461
- expeditions they have access to.
462
-
463
- <SchemaDefinition schemaRef="#/components/schemas/pod" />`,
464
352
  },
465
353
  {
466
354
  name: 'Historic records introduction',
467
355
  'x-displayName': 'Historic records',
468
356
  description: `
469
- Every time the API creates, updates or deletes a resource it stores a historic record of the action, the full document as it was after
470
- the action, the time it occurred and the user that made it.
471
-
472
- The only exception are \`pods\` which have no records because they are created when their expeditions are delivered and they are never
473
- updated. They are also never deleted because they need to remain accessible via the historic records of expeditions.
357
+ Every time the API creates, updates or deletes a resource it creates a historic record that stores the action taken (create, update, or
358
+ delete), the full document as it was after the action, the time it occurred and the user that made it.
474
359
 
475
360
  These historic records serve two purposes:
476
361
 
477
- - They allow to track the full history of a document.
478
- - They are the basis for the [integrations](#tag/Integrations-introduction) with other systems.
362
+ - They allow to track the full history of a resource.
363
+ - They are the basis for the [background processes](#tag/Types-of-background-processes) of the API.
479
364
 
480
- The \`actionKeys\` lists the paths of the updated fields for an \`update\` action. The depth of the paths may vary:
481
-
482
- - Usually it is just the root key, for example an update of any field in a shop address is just \`address\`.
483
- - Some updated are more specific, for example delivering an expedition is \`status.code\` and \`status.givenTo\`.
484
-
485
- The \`integrations\` field is where each integration stores what it did with it. Its properties are the names of the integrations and
486
- their values the result of that integration for that record.
487
-
488
- Super administrators can search the historic records using the [historic records](#tag/Historic-records) endpoints.
489
-
490
- <SchemaDefinition schemaRef="#/components/schemas/historicRecord" />`,
365
+ See the [historic records](#tag/Historic-records) endpoints for more information.`,
491
366
  },
492
367
  {
493
- name: 'Background work',
368
+ name: 'Types of background processes',
494
369
  description: `
495
- Besides responding to requests made to its endpoints, this API also performs some background work. This section explains this work except
496
- for the integrations with other systems, which have their own [section](#tag/Integrations-introduction).`,
370
+ The API runs two types of processes in the background:
371
+
372
+ - Some processes execute an action at regular time intervals.
373
+ - Some processes execute an action every time a new historic record is created.
374
+
375
+ This section explains what each kind of background process does.`,
497
376
  },
498
377
  {
499
378
  name: 'Eventual consistency',
500
379
  description: `
501
- Some of the resources in this API depend on others. In these situations the dependent resources store a reference to the \`_id\` of their
502
- dependency, for example each shop stores the network it belong to in its \`network._id\` field.
380
+ When one resource depends on another it stores the \`_id\` of its dependency, for example each shop stores the network it belongs to in
381
+ its \`network._id\` field.
503
382
 
504
- There are other fields of the dependencies that are used so often that it makes sense to store them in the dependents too, for example each
505
- shop also stores the name of its network in its \`network.name\` field.
383
+ When a resource also needs other fields of its dependency very often it makes sense to store them with the \`_id\`, for example each shop
384
+ also stores the name of its network in its \`network.name\` field.
506
385
 
507
386
  This is called denormalization and it saves a lot of queries for the full dependency each time these fields are needed. The downside is
508
387
  that an update in the dependency requires updating the dependents too. There are two strategies to do this:
@@ -512,64 +391,53 @@ are thousands or millions of dependents.
512
391
  - **Eventual consistency**: only the dependency is updated immediately, and the dependents are updated later in the background. The update
513
392
  endpoint returns very fast but for a few seconds the dependents are outdated.
514
393
 
515
- This API uses eventual consistency because these denormalized fields are normally used for UI purposes and not for critical calculations
516
- that required strict consistency.`,
394
+ The API runs an eventual consistency background process that watches the historic records. When a record updates the appropriate field in
395
+ a dependency, the background process updates also all the relevant dependents.`,
517
396
  },
518
397
  {
519
398
  name: 'Expeditions expiration',
520
399
  description: `
521
- Delivery expeditions can only be in a shop for a certain amount of time before GLS returns them to the sender. This information is
400
+ Delivery expeditions can only be in a shop for a certain amount of time before GLS returns them to the sender. This time limit is
522
401
  calculated when the expedition is received at a shop and stored in its \`status.expiration\` field.
523
402
 
524
- This expiration information includes two kind of values that need to be checked periodically: the list of moments when the customer needs
525
- to be reminded to pick up the expedition, and the moment the expedition expires.
403
+ There are two values that need to be checked periodically: a list of moments when the customer needs to be reminded to pick up the
404
+ expedition, and the moment the expedition expires.
526
405
 
527
- The API periodically checks these moments and when the time comes it updates the expedition and stores an historic record of the update. It
528
- is then the responsibility of some integration to respond to that historic record. See [integrations](#tag/Integrations-introduction)
529
- for more information.`,
530
- },
531
- {
532
- name: 'Integrations introduction',
533
- 'x-displayName': 'Integrations',
534
- description: `
535
- Some of the background work of this API are integrations with other systems. These integrations work by scanning the historic records in
536
- chronological order and deciding what to do for each one, if anything. The integrations store their results in the \`integrations\` field
537
- of each record.
538
-
539
- Super administrators can search the historic records by integration name and result to find for example those records where the integration
540
- failed and why. See the [historic records](#tag/Historic-records) endpoints for more information.
406
+ The API runs two background processes that check these two values at regular intervals:
541
407
 
542
- Each integration also has a corresponding \`integration\` document that stores its configuration, basically if it is enabled or not and
543
- what networks it applies to:
408
+ - One process checks when a reminder has expired and updates the expedition, moving said reminder from
409
+ \`status.expiration.pendingReminders\` to \`status.expiration.sentReminders\`.
410
+ - The other process checks when an expedition has expired and updates its \`status.code\` to \`expired\`.
544
411
 
545
- <SchemaDefinition schemaRef="#/components/schemas/integration" />
546
-
547
- See the [integrations](#tag/Integrations) endpoints for more information.`,
412
+ Both processes only update an expedition and create the appropriate historic record. It is then the responsibility of other background
413
+ processes to do something in response to those historic records being created.`,
548
414
  },
549
415
  {
550
- name: 'GLS Spain',
416
+ name: 'GLS Spain integration',
551
417
  description: `
552
- This API is integrated with the main systems of GLS Spain. The integration goes in both directions:
418
+ The API is integrated with the main systems of GLS Spain. The integration goes in both directions:
553
419
 
554
- - GLS Spain has a super admin user to access this API and manage its resources, e.g. creating expeditions.
555
- - This API scans the historic records and sends events to GLS Spain on certain situations, e.g. when a shop receives an expedition.
420
+ - GLS Spain has a super admin user to access the API and manage its resources, e.g. creating expeditions.
421
+ - The API runs a background process that watches the historic records and sends events to GLS.
556
422
 
557
423
  This integration configuration can be found using the [find integrations endpoint](#tag/Integrations/paths/~1integrations~1find/post),
558
- under the \`GLS Spain\` name. Its \`networks\` field lists the networks it applies to.
559
-
560
- The following table lists all the possible events along with the situations that causes them to be sent:
561
-
562
- | Event | Resource | Situation |
563
- | :--- | :--- | :--- |
564
- | upsert network | \`network\` | updated |
565
- | upsert shop | \`shop\` | created or updated |
566
- | receive from driver | \`expedition\` | received from driver |
567
- | receive from customer | \`expedition\` | received from customer |
568
- | give to customer | \`expedition\` | given to customer |
569
- | give to driver | \`expedition\` | given to driver |
570
- | expiration reminder | \`expedition\` | a pickup reminder needs to be sent |
571
- | expired | \`expedition\` | has expired |
572
- | price | \`expedition\` | received from driver or customer<br/>price changed after reception |
424
+ under the \`glsSpain\` name. Its \`networks\` field lists the networks that the shops, expeditions and sales must belong to for the events
425
+ to be sent. All other networks are ignored.
426
+
427
+ The following table lists the events that are sent along with the historic records that causes them:
428
+
429
+ | Event | Historic record |
430
+ | :--- | :--- |
431
+ | upsert network | Network update |
432
+ | upsert shop | Shop create or update |
433
+ | upsert sale | Sale create or update |
434
+ | receive from driver | Expedition update (received from driver) |
435
+ | receive from customer | Expedition update (received from customer) |
436
+ | give to customer | Expedition update (given to customer) |
437
+ | give to driver | Expedition update (given to driver) |
438
+ | expiration reminder | Expedition update (reminder moved from pending to sent) |
439
+ | expired | Expedition update (status changed to expired) |
440
+ | price | Expedition update (received from driver or customer)<br/>Expedition update (price changed after reception) |
573
441
 
574
442
  The following are the request bodies sent for each event:
575
443
 
@@ -585,6 +453,12 @@ Sent when a shop is created or updated.
585
453
 
586
454
  <SchemaDefinition schemaRef="#/components/schemas/upsertShopEvent" />
587
455
 
456
+ ## Upsert sale event
457
+
458
+ Sent when a sale is created or updated.
459
+
460
+ <SchemaDefinition schemaRef="#/components/schemas/upsertSaleEvent" />
461
+
588
462
  ## Receive from driver event
589
463
 
590
464
  Sent when a shop receives an expedition from a driver.
@@ -611,22 +485,42 @@ Sent when a shop delivers an expedition to a driver.
611
485
 
612
486
  ## Expiration reminder event
613
487
 
614
- Sent when the API detects in the background that it is time to remind the customer to pick up the expedition.
488
+ Sent when an expedition expiration reminder has been moved from pending to sent.
615
489
 
616
490
  <SchemaDefinition schemaRef="#/components/schemas/expirationReminderEvent" />
617
491
 
618
492
  ## Expired event
619
493
 
620
- Sent when the API detects in the background that the expedition has expired.
494
+ Sent when an expedtions status has been changed to expired.
621
495
 
622
496
  <SchemaDefinition schemaRef="#/components/schemas/expiredEvent" />
623
497
 
624
498
  ## Price event
625
499
 
626
- Sent for the first time when an expedition is received at a shop, and after that any time the weight or packages are updated.
500
+ Sent for the first time when an expedition is received at a shop, and after that any time the price is updated.
627
501
 
628
502
  <SchemaDefinition schemaRef="#/components/schemas/priceEvent" />`,
629
503
  },
504
+ {
505
+ name: 'GLS International integration',
506
+ description: `
507
+ The API is integrated with the GLS International ParcelShop API in order to export the shops in this API to the international database.
508
+
509
+ There is a background process that watches the historic records and each time a shop is created, updated or deleted, it is sent to the
510
+ international API.
511
+
512
+ This integration configuration can be found using the [find integrations endpoint](#tag/Integrations/paths/~1integrations~1find/post),
513
+ under the \`glsInternationalExport\` name. Its \`networks\` field lists the networks that the shops must belong to for them to be reported
514
+ to the international API. All other networks are ignored.`,
515
+ },
516
+ {
517
+ name: 'GLS SMS integration', // todo
518
+ description: `TODO`,
519
+ },
520
+ {
521
+ name: 'Ingenico integration', // todo
522
+ description: `TODO`,
523
+ },
630
524
  {
631
525
  name: 'Authentication',
632
526
  description: `
@@ -652,74 +546,107 @@ The endpoints that require so will indicate it in their description.`,
652
546
  { name: 'Documentation' },
653
547
  {
654
548
  name: 'Config',
655
- description: `API initialization and configuration.
549
+ description: `API global configuration.
550
+
551
+ This section contains the \`defaults\` object, which is a single object in the API that holds the configuration for:
552
+
553
+ - The derivation settings, which are the price rates for deliveries and pickups.
554
+ - The expiration settings, which include when do deliveries expire and when to send pickup reminders to the customers.
555
+ - The sales settings, which is the price table for sales based on the package size and destination.
556
+
557
+ The derivation and expiration settings can be overridden at the network and shop level if they need custom values other than the defaults.
558
+
559
+ The sales settings cannot be overridden at the network or shop levels. Instead, networks contain the percentages of the price that are paid
560
+ to the network and the shop.
656
561
 
657
- This section has an endpoint to initialize the API when deployed to a new environment.
562
+ This section also contains an endpoint to view the \`counters\` object, which keeps track of the last value used in each auto incremental
563
+ field used for any resource in the API.
658
564
 
659
- There are also endpoints to configure the default settings for networks and shops, like the rate prices for deliveries
660
- and pickups, the maximum number of days that an expedition can be in a shop before returning it, etc.
565
+ ## Defaults schema
661
566
 
662
- These settings can be set at various levels of specificity:
567
+ <SchemaDefinition schemaRef="#/components/schemas/defaults" />
663
568
 
664
- - Default values: these are set in this section and apply to networks and shops that do not have custom settings.
665
- - Network specific values: each network can have its custom settings, which override the default ones.
666
- - Shop specific values: each shop can have its custom settings, which override the network and default ones.
569
+ ## Counters schema
667
570
 
668
- There is also an endpoint to view the last value used for each auto incremental field`,
571
+ <SchemaDefinition schemaRef="#/components/schemas/counters" />`,
669
572
  },
670
573
  {
671
574
  name: 'Super admins',
672
575
  description: `Create and manage super admins.
673
576
 
674
- Super admins are the top level admins of the system and they can manage all kinds of resources.`,
577
+ Super administrators can manage all the resources of the API.
578
+
579
+ An initial super admin is created when the API is deployed and then that super admin can create additional super admins.
580
+
581
+ ## Super admin schema
582
+
583
+ <SchemaDefinition schemaRef="#/components/schemas/superAdmin" />
584
+ `,
675
585
  },
676
586
  {
677
587
  name: 'Networks',
678
588
  description: `Create and manage networks.
679
589
 
680
- Networks are collections of parcel shops that belong to the same provider.
681
-
682
- A network that has admins or parcel shops associated to it will have its \`deletable\` property automatically set to
683
- \`false\` and cannot be deleted.
590
+ Networks represent the providers of parcel shops, e.g. the companies or associations that have a deal with GLS to use their establishments
591
+ as parcel shops. Every parcel shop belongs to a single network.
684
592
 
685
593
  A network that has its \`readonly\` property set to \`true\` cannot be updated or have shops added to it. Readonly networks usually have
686
- their shops come from another source like an integration.
594
+ their shops come from an integration.
687
595
 
688
596
  A network may have custom derivation and expiration settings or use the defaults defined in [config](#tag/Config):
689
597
 
690
598
  - If it has \`derivationSettings\` or \`expirationSettings\` properties it means it has custom settings.
691
599
  - If not, then the values in its \`defaults\` property will be used, which are a copy of the default values.
692
-
693
- See [create](#tag/Networks/paths/~1networks~1create/post) and [update](#tag/Networks/paths/~1networks~1update/post) on
694
- how to set or remove the custom properties.
695
600
 
696
- See the [GLS integration](#tag/GLS) section for more information about the \`integrations\` property.`,
601
+ ## Network schema
602
+
603
+ <SchemaDefinition schemaRef="#/components/schemas/network" />`,
697
604
  },
698
605
  {
699
606
  name: 'Network admins',
700
607
  description: `Create and manage network admins.
701
608
 
702
- Network admins are associated to a particular network and can view its resources, like their shops and shop users.`,
609
+ Network admins are associated to a single network and can view its resources, like their shops and shop users.
610
+
611
+ ## Network admin schema
612
+
613
+ <SchemaDefinition schemaRef="#/components/schemas/networkAdmin" />`,
703
614
  },
704
615
  {
705
616
  name: 'Zones',
706
617
  description: `Create and manage zones.
707
618
 
708
619
  Zones define geographic areas that both the shops and the sales representatives are associated to. They define the commissions the sales
709
- representatives earn for the shops they open or manage.
710
- `,
620
+ representatives earn for the shops they open or manage in that area.
621
+
622
+ ## Zone schema
623
+
624
+ <SchemaDefinition schemaRef="#/components/schemas/zone" />`,
625
+ },
626
+ {
627
+ name: 'Sales representatives',
628
+ description: `Create and manage sales representatives.
629
+
630
+ Sales representatives are the GLS staff that make deals with businesses to open establishments as parcel shops. Each parcel shop in the API
631
+ has two representatives associated to it: the one that made the deal to open the shop and the one that is currently managing it. They can
632
+ be the same representative.
633
+
634
+ ## Sales representative schema
635
+
636
+ <SchemaDefinition schemaRef="#/components/schemas/representative" />`,
711
637
  },
712
638
  {
713
639
  name: 'Shops',
714
640
  description: `Create and manage shops.
715
641
 
716
- A shop is assigned to a network on creation and its network cannot be changed later.
642
+ Parcel shops are the establishments that GLS and the customers can use to deliver and pickup expeditions instead of doing
643
+ it at the customers home.
717
644
 
718
- A shop that has users or expeditions associated to it will have its \`deletable\` property automatically set to \`false\`
719
- and cannot be deleted.
645
+ Every parcel shop is associated to a network on creation, and it must have at least one shop user associated to it for the parcel
646
+ shop to function.
720
647
 
721
648
  A shop that has its \`readonly\` property set to \`true\` cannot be updated or have expeditions added to it. Readonly shops usually come
722
- from another source like an integration.
649
+ from an integration.
723
650
 
724
651
  A shop may have custom derivation and expiration settings, use its network values or use the defaults defined in [config](#tag/Config):
725
652
 
@@ -728,9 +655,6 @@ A shop may have custom derivation and expiration settings, use its network value
728
655
  - 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
729
656
  the default values.
730
657
 
731
- See [create](#tag/Shops/paths/~1shops~1create/post) and [update](#tag/Shops/paths/~1shops~1update/post) on how to set or remove
732
- the custom properties.
733
-
734
658
  ### Status
735
659
 
736
660
  A shop can be enabled or disabled as indicated by its \`status.code\` property. This property cannot be set directly,
@@ -742,30 +666,34 @@ instead its value depends on the other \`status\` properties:
742
666
  | X | √ | \`disabled\` |
743
667
  | X | X | \`enabled\` |
744
668
 
745
- `,
669
+ ## Shop schema
670
+
671
+ <SchemaDefinition schemaRef="#/components/schemas/shop" />`,
746
672
  },
747
673
  {
748
674
  name: 'Shop users',
749
675
  description: `Create and manage shop users.
750
676
 
751
- Shop users are associated with a single shop and they have limited capabilities to manage the shop and its expeditions`,
677
+ Shop users are associated with a single shop and they have limited capabilities to manage the shop expeditions, e.g. they can receive and
678
+ deliver expeditions, but not edit anything else about them.
679
+
680
+ ## Shop user schema
681
+
682
+ <SchemaDefinition schemaRef="#/components/schemas/shopUser" />`,
752
683
  },
753
684
  {
754
685
  name: 'Expeditions',
755
686
  description: `Create and manage expeditions.
756
687
 
757
- Expeditions are the packages that are delivered and picked up via the parcel shops. Each expedition can have more than one package.
758
-
759
- An expedition that has pods associated to it will have its \`deletable\` property automatically set to \`false\` and cannot be deleted.
688
+ Expeditions are the packages that are delivered and picked up at parcel shops.
760
689
 
761
690
  ### Types
762
691
 
763
- There are 3 kinds of expeditions, indicated in its \`type\` property:
692
+ There are 2 kinds of expeditions, indicated in its \`type\` property:
764
693
 
765
- - \`delivery\`: the most common situation where a driver leaves an expedition at a parcel shop for the customer to retrieve it later.
766
- - \`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.
767
- - \`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
768
- at the parcel shop for a driver to retrieve it later.
694
+ - \`delivery\`: when a driver leaves an expedition at a parcel shop for the customer to retrieve it later.
695
+ - \`pickup\`: when a customer leaves an expedition at a parcel shop for the driver to retrieve it later. It can be because of a return or
696
+ a sale.
769
697
 
770
698
  ### Status
771
699
 
@@ -777,9 +705,8 @@ The \`status.code\` property of an expedition indicates the situation of an expe
777
705
  The expedition is then scheduled to be given to the driver to return it to the original sender.
778
706
  - \`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.
779
707
 
780
- The \`status\` of an expedition cannot be updated with a regular [update](#tag/Expeditions/paths/~1expeditions~1update/post)
781
- because it has a predetermined life cycle. The following endpoints update an expedition status and add or remove additional
782
- \`status\` properties:
708
+ The \`status\` of an expedition cannot be updated with a regular [update](#tag/Expeditions/paths/~1expeditions~1update/post) because it has
709
+ a predetermined life cycle. The following endpoints update an expedition status and add or remove additional \`status\` properties:
783
710
 
784
711
  | Operation | Type | From status | To status | New status properties |
785
712
  | :--- | :--- | :--- | :--- | :--- |
@@ -790,25 +717,70 @@ because it has a predetermined life cycle. The following endpoints update an exp
790
717
  | [giveToDriver](#tag/Expeditions/paths/~1expeditions~1giveToDriver/post) | delivery<br/>pickup | inShopExpired<br/>inShop | delivered<br/>delivered | givenTo<br/>givenTo |
791
718
  | [redirect](#tag/Expeditions/paths/~1expeditions~1redirect/post) | any | any | incoming | clear everything |
792
719
 
793
- `,
720
+ ## Expedition schema
721
+
722
+ <SchemaDefinition schemaRef="#/components/schemas/expedition" />`,
794
723
  },
795
724
  {
796
725
  name: 'Pods',
797
- description: `Find expeditions PODS (Proof Of Delivery).`,
726
+ description: `Find expeditions PODS (Proof Of Delivery).
727
+
728
+ When an expedition is picked up by a customer or delivered to a customer, the API will automatically create a POD with the customer
729
+ signature and reference the POD from the expedition \`status.receivedFrom.customer.pod\` or \`status.givenTo.customer.pod\` fields.
730
+
731
+ PODs are never updated or deleted even if their expedition is deleted, since they still need to be accessed from that expedition historic
732
+ records. Since they are part of their expedition historic records, PODs do not have historic records on their own.
733
+
734
+ ## Pod schema
735
+
736
+ <SchemaDefinition schemaRef="#/components/schemas/pod" />`,
798
737
  },
799
738
  {
800
- name: 'Sales representatives',
801
- description: `Create and manage sales representatives.
739
+ name: 'Sales', // todo
740
+ description: `Create and find sales.
741
+
742
+ Customers can go to a parcel shop at any time and pay to have a package sent to an allowed destination.
743
+
744
+ The allowed destinations and the price of the service can be found in the [\`defaults\` object](#tag/Config/paths/~1config~1defaults~1get/get).
745
+
746
+ The process for a sale is the following:
747
+
748
+ - A shop user creates a sale by asking the customer for the destination and sender personal data, package size, etc.
749
+ - The API will use the Ingenico integration to prepare the payment and send the customer an SMS with a link where he can pay for the service.
750
+ - If Ingenico responds that the customer has paid the API will use the GLS Spain integration to notify GLS of the new sale.
751
+ - GLS Spain will then create a pickup expedition associated to the sale which will be picked up by a driver.
752
+
753
+ ## Sale schema
802
754
 
803
- Once created, sales representatives can be associated to parcel shops.`,
755
+ <SchemaDefinition schemaRef="#/components/schemas/sale" />`,
804
756
  },
805
757
  {
806
758
  name: 'Historic records',
807
- description: `Find historic records.`,
759
+ description: `Find historic records.
760
+
761
+ The \`actionKeys\` field lists the paths of the updated fields for an \`update\` action. The depth of the paths may vary:
762
+
763
+ - Usually it is just the keys at the root of the document, for example an update of any field in a shop address is just \`address\`.
764
+ - Some updates are more specific, for example delivering an expedition is \`status.code\` and \`status.givenTo\`.
765
+
766
+ The \`integrations\` field is where each integration stores what it did with the historic record. Its properties are the names of the
767
+ integrations and their values the result of that integration for that historic record.
768
+
769
+ ## Historic record schema
770
+
771
+ <SchemaDefinition schemaRef="#/components/schemas/historicRecord" />`,
808
772
  },
809
773
  {
810
774
  name: 'Integrations',
811
- description: `Find integrations configurations.`,
775
+ description: `Find integrations configurations.
776
+
777
+ Some of the background work of this API are integrations with other systems. These integrations work by scanning the historic records in
778
+ chronological order and deciding what to do for each one, if anything. The integrations store their results in the \`integrations\` field
779
+ of each record.
780
+
781
+ ## Integration schema
782
+
783
+ <SchemaDefinition schemaRef="#/components/schemas/integration" />`,
812
784
  },
813
785
  ];
814
786
 
@@ -874,6 +846,9 @@ const errors = {
874
846
  zoneDoesNotExist: new ZoneDoesNotExistError(),
875
847
  zoneAlreadyExists: new ZoneAlreadyExistsError(),
876
848
  zoneCannotBeDeleted: new ZoneCannotBeDeletedError(),
849
+ saleAlreadyExists: new SaleAlreadyExistsError(),
850
+ inconsistentSalesSettings: new InconsistentSalesSettingsError(),
851
+ invalidSaleDestination: new InvalidSaleDestinationError(),
877
852
  };
878
853
 
879
854
  const responses = {
@@ -1021,6 +996,18 @@ const responses = {
1021
996
  description: 'The zone cannot be deleted.',
1022
997
  content: { 'application/json': { schema: specificHttpError(errors.zoneCannotBeDeleted) } },
1023
998
  },
999
+ saleAlreadyExists: {
1000
+ description: 'The sale already exists.',
1001
+ content: { 'application/json': { schema: specificHttpError(errors.saleAlreadyExists) } },
1002
+ },
1003
+ inconsistentSalesSettings: {
1004
+ description: 'The sales settings are inconsistent.',
1005
+ content: { 'application/json': { schema: specificHttpError(errors.inconsistentSalesSettings) } },
1006
+ },
1007
+ invalidSaleDestination: {
1008
+ description: 'The sale destination is invalid.',
1009
+ content: { 'application/json': { schema: specificHttpError(errors.invalidSaleDestination) } },
1010
+ },
1024
1011
  };
1025
1012
 
1026
1013
  const securitySchemes = {
@@ -1075,11 +1062,13 @@ openApiSpec.components = {
1075
1062
  priceEvent: priceEvent(),
1076
1063
  upsertShopEvent: upsertShopEvent(),
1077
1064
  upsertNetworkEvent: upsertNetworkEvent(),
1065
+ upsertSaleEvent: upsertSaleEvent(),
1078
1066
  timezoneNames: timezoneNames(),
1079
1067
  representative: representative(),
1080
1068
  zone: zone(),
1081
1069
  historicRecord: historicRecord(),
1082
1070
  integration: integration(),
1071
+ sale: sale(),
1083
1072
  },
1084
1073
  };
1085
1074
 
@@ -1237,32 +1226,6 @@ ${securitySchemes.basicAuth}`,
1237
1226
  },
1238
1227
  },
1239
1228
  },
1240
- '/config/init': {
1241
- post: {
1242
- tags: ['Config'],
1243
- summary: '[!] Init API deployment',
1244
- description: `
1245
- Initializes and sets up the API when deployed in a new environment.
1246
-
1247
- This initial super admin cannot be deleted later. You can add more super admins and disable this one's login though.
1248
-
1249
- ${securitySchemes.emptyDatabase}`,
1250
- requestBody: {
1251
- content: { 'application/json': { schema: initRequest() } },
1252
- required: true,
1253
- },
1254
- responses: {
1255
- ' 200': {
1256
- description: 'Contains the created super admin and default values.',
1257
- content: { 'application/json': { schema: initResponse() } },
1258
- },
1259
- ' 400': responses.badRequest,
1260
- ' 415': responses.unsupportedMediaType,
1261
- ' 500': responses.internalServerError,
1262
- ' 500 ': responses.databaseNotEmpty,
1263
- },
1264
- },
1265
- },
1266
1229
  '/config/defaults/get': {
1267
1230
  get: {
1268
1231
  tags: ['Config'],
@@ -1294,7 +1257,11 @@ ${securitySchemes.superAdminRole}`,
1294
1257
  description: `
1295
1258
  Update the default settings.
1296
1259
 
1297
- The update will propagate to the \`defaults\` property of all networks and shops.
1260
+ If the \`derivationSettings\` or \`expirationSettings\` are updated, the update will propagate to the \`defaults\` property of all networks
1261
+ and shops.
1262
+
1263
+ If the \`salesSettings\` contain duplicated zones, countries or postal codes, or if a country or postal codes references a non existent
1264
+ zone, the API will return a \`500 InconsistentSalesSettingsError\`.
1298
1265
 
1299
1266
  ${securitySchemes.tokens}
1300
1267
  ${securitySchemes.superAdminRole}`,
@@ -1316,6 +1283,7 @@ ${securitySchemes.superAdminRole}`,
1316
1283
  ' 415': responses.unsupportedMediaType,
1317
1284
  ' 500': responses.internalServerError,
1318
1285
  ' 500 ': responses.defaultsDoNotExist,
1286
+ ' 500 ': responses.inconsistentSalesSettings,
1319
1287
  },
1320
1288
  },
1321
1289
  },
@@ -1981,6 +1949,9 @@ ${descriptions.createIdIsOptional}
1981
1949
 
1982
1950
  ${descriptions.optionalArrayPropertiesEmptyByDefault}
1983
1951
 
1952
+ The \`zones\` property associates a representative with one or more zones. If any of the provided zones do not exist the API will return a
1953
+ \`500 ZoneDoesNotExistError\`.
1954
+
1984
1955
  ${securitySchemes.tokens}
1985
1956
  ${securitySchemes.superAdminRole}`,
1986
1957
  requestBody: {
@@ -2000,7 +1971,8 @@ ${securitySchemes.superAdminRole}`,
2000
1971
  ' 403': responses.forbidden,
2001
1972
  ' 415': responses.unsupportedMediaType,
2002
1973
  ' 500': responses.internalServerError,
2003
- ' 500 ': responses.representativeAlreadyExists,
1974
+ ' 500 ': responses.zoneDoesNotExist,
1975
+ ' 500 ': responses.representativeAlreadyExists,
2004
1976
  },
2005
1977
  },
2006
1978
  },
@@ -3068,6 +3040,181 @@ ${securitySchemes.anyRole}`,
3068
3040
  },
3069
3041
  },
3070
3042
  },
3043
+ '/sales/create': {
3044
+ post: {
3045
+ tags: ['Sales'],
3046
+ summary: '[U] Create',
3047
+ description: `
3048
+ Creates a new sale.
3049
+
3050
+ ${descriptions.createIdIsOptional}
3051
+
3052
+ ${descriptions.optionalArrayPropertiesEmptyByDefault}
3053
+
3054
+ The \`network\` and \`shop\` fields of the new sale will be the same as the shop user that creates it.
3055
+
3056
+ The \`status.code\` will be \`pending\`.
3057
+
3058
+ The \`settings\` field will be created by combining the \`salesSettings\` from the \`default\` object and the \`salesSettings\` from the
3059
+ sale \`network\` as they are when the sale is created. This way the sale will keep the right settings values even if the \`default\` or
3060
+ the \`network\` are updated later.
3061
+
3062
+ The \`price\` field will be calculated from the \`size\` and \`settings\` fields.
3063
+
3064
+ ${securitySchemes.tokens}
3065
+ ${securitySchemes.shopUserRole}`,
3066
+ requestBody: {
3067
+ content: { 'application/json': { schema: createSaleRequest() } },
3068
+ required: true,
3069
+ },
3070
+ responses: {
3071
+ ' 200': {
3072
+ description: 'Contains the created sale.',
3073
+ content: { 'application/json': { schema: createSaleResponse() } },
3074
+ },
3075
+ ' 400': responses.badRequest,
3076
+ ' 401': responses.invalidUserInCookieOrHeader,
3077
+ ' 401 ': responses.invalidCookieOrHeader,
3078
+ ' 401 ': responses.missingCookieOrHeader,
3079
+ ' 401 ': responses.unauthorized,
3080
+ ' 403': responses.forbidden,
3081
+ ' 415': responses.unsupportedMediaType,
3082
+ ' 500': responses.internalServerError,
3083
+ ' 500 ': responses.saleAlreadyExists,
3084
+ },
3085
+ },
3086
+ },
3087
+ '/sales/find': {
3088
+ post: {
3089
+ tags: ['Sales'],
3090
+ summary: '[S] Find',
3091
+ description: `
3092
+ Finds sales by one of several filters.
3093
+
3094
+ ${descriptions.findLimitTip}
3095
+
3096
+ ${securitySchemes.tokens}
3097
+ ${securitySchemes.superAdminRole}`,
3098
+ requestBody: {
3099
+ content: { 'application/json': { schema: findSalesSuperAdminRequest() } },
3100
+ required: true,
3101
+ },
3102
+ responses: {
3103
+ ' 200': {
3104
+ description: 'Contains the found sales.',
3105
+ content: { 'application/json': { schema: findSalesResponse() } },
3106
+ },
3107
+ ' 400': responses.badRequest,
3108
+ ' 401': responses.invalidUserInCookieOrHeader,
3109
+ ' 401 ': responses.invalidCookieOrHeader,
3110
+ ' 401 ': responses.missingCookieOrHeader,
3111
+ ' 401 ': responses.unauthorized,
3112
+ ' 403': responses.forbidden,
3113
+ ' 415': responses.unsupportedMediaType,
3114
+ ' 500': responses.internalServerError,
3115
+ },
3116
+ },
3117
+ },
3118
+ '/sales/find ': {
3119
+ post: {
3120
+ tags: ['Sales'],
3121
+ summary: '[N] Find',
3122
+ description: `
3123
+ Finds sales by one of several filters.
3124
+
3125
+ The results will be limited to the network the admin belongs to, so for example if he finds by \`_id\` and the sale is from another
3126
+ network, the find will return no results.
3127
+
3128
+ ${descriptions.findLimitTip}
3129
+
3130
+ ${securitySchemes.tokens}
3131
+ ${securitySchemes.networkAdminRole}`,
3132
+ requestBody: {
3133
+ content: { 'application/json': { schema: findSalesNetworkAdminRequest() } },
3134
+ required: true,
3135
+ },
3136
+ responses: {
3137
+ ' 200': {
3138
+ description: 'Contains the found sales.',
3139
+ content: { 'application/json': { schema: findSalesResponse() } },
3140
+ },
3141
+ ' 400': responses.badRequest,
3142
+ ' 401': responses.invalidUserInCookieOrHeader,
3143
+ ' 401 ': responses.invalidCookieOrHeader,
3144
+ ' 401 ': responses.missingCookieOrHeader,
3145
+ ' 401 ': responses.unauthorized,
3146
+ ' 403': responses.forbidden,
3147
+ ' 415': responses.unsupportedMediaType,
3148
+ ' 500': responses.internalServerError,
3149
+ },
3150
+ },
3151
+ },
3152
+ '/sales/find ': {
3153
+ post: {
3154
+ tags: ['Sales'],
3155
+ summary: '[U] Find',
3156
+ description: `
3157
+ Finds sales by one of several filters.
3158
+
3159
+ The results will be limited to the shop the user belongs to, so for example if he finds by \`_id\` and the sale is from another
3160
+ network or shop, the find will return no results.
3161
+
3162
+ ${descriptions.findLimitTip}
3163
+
3164
+ ${securitySchemes.tokens}
3165
+ ${securitySchemes.shopUserRole}`,
3166
+ requestBody: {
3167
+ content: { 'application/json': { schema: findSalesShopUserRequest() } },
3168
+ required: true,
3169
+ },
3170
+ responses: {
3171
+ ' 200': {
3172
+ description: 'Contains the found sales.',
3173
+ content: { 'application/json': { schema: findSalesResponse() } },
3174
+ },
3175
+ ' 400': responses.badRequest,
3176
+ ' 401': responses.invalidUserInCookieOrHeader,
3177
+ ' 401 ': responses.invalidCookieOrHeader,
3178
+ ' 401 ': responses.missingCookieOrHeader,
3179
+ ' 401 ': responses.unauthorized,
3180
+ ' 403': responses.forbidden,
3181
+ ' 415': responses.unsupportedMediaType,
3182
+ ' 500': responses.internalServerError,
3183
+ },
3184
+ },
3185
+ },
3186
+ '/sales/checkPrices': {
3187
+ post: {
3188
+ tags: ['Sales'],
3189
+ summary: '[SNU] Check prices',
3190
+ description: `
3191
+ Finds the price for a sale based on its package size and destination.
3192
+
3193
+ If the destination is invalid the API will return a \`500 InvalidSaleDestinationError\`.
3194
+
3195
+ ${securitySchemes.tokens}
3196
+ ${securitySchemes.anyRole}`,
3197
+ requestBody: {
3198
+ content: { 'application/json': { schema: checkSalePriceRequest() } },
3199
+ required: true,
3200
+ },
3201
+ responses: {
3202
+ ' 200': {
3203
+ description: 'Contains the price of the sale.',
3204
+ content: { 'application/json': { schema: checkSalePriceResponse() } },
3205
+ },
3206
+ ' 400': responses.badRequest,
3207
+ ' 401': responses.invalidUserInCookieOrHeader,
3208
+ ' 401 ': responses.invalidCookieOrHeader,
3209
+ ' 401 ': responses.missingCookieOrHeader,
3210
+ ' 401 ': responses.unauthorized,
3211
+ ' 403': responses.forbidden,
3212
+ ' 415': responses.unsupportedMediaType,
3213
+ ' 500': responses.internalServerError,
3214
+ ' 500 ': responses.invalidSaleDestination,
3215
+ },
3216
+ },
3217
+ },
3071
3218
  '/historicRecords/find': {
3072
3219
  post: {
3073
3220
  tags: ['Historic records'],
@@ -3109,8 +3256,7 @@ ${securitySchemes.superAdminRole}`,
3109
3256
  description: `
3110
3257
  Finds all the integrations of the API and what networks they apply to.
3111
3258
 
3112
- To see what each integration actually does read that integration documentation in the [integrations](#tag/Integrations-introduction)
3113
- section.
3259
+ To see what each integration does read the [background processes](#tag/Types-of-background-processes) section.
3114
3260
 
3115
3261
  ${descriptions.findLimitTip}
3116
3262