@gls_spain/gps-common 34.11.1 → 34.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -3
- package/open-api-spec/index.js +103 -1
- package/package.json +1 -1
- package/schemas/definitions/expeditions.js +12 -1
- package/schemas/definitions/shops.js +44 -0
- package/schemas/index.js +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
# [34.13.0](https://github.com/GLS-Spain/gps-common/compare/v34.12.0...v34.13.0) (2021-05-21)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* add new endpoint depositedFormDriver ([20f5035](https://github.com/GLS-Spain/gps-common/commit/20f5035ee16f1a5879ae064432a019284f0acc1e))
|
|
7
7
|
|
|
8
|
+
# [34.12.0](https://github.com/GLS-Spain/gps-common/compare/v34.11.1...v34.12.0) (2021-05-19)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* new end points ([6c82af3](https://github.com/GLS-Spain/gps-common/commit/6c82af32662a96ee6c01db2aff48e289cc9c1ea3))
|
|
14
|
+
|
|
15
|
+
## [34.11.1](https://github.com/GLS-Spain/gps-common/compare/v34.11.0...v34.11.1) (2021-05-17)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* problem to new endPoint ([2e46159](https://github.com/GLS-Spain/gps-common/commit/2e46159d6eeeb62eeaab0b7353dd75598e3295be))
|
|
21
|
+
|
|
8
22
|
# [34.11.0](https://github.com/GLS-Spain/gps-common/compare/v34.10.0...v34.11.0) (2021-05-10)
|
|
9
23
|
|
|
10
24
|
|
package/open-api-spec/index.js
CHANGED
|
@@ -105,6 +105,8 @@ const {
|
|
|
105
105
|
updateShopResponse,
|
|
106
106
|
deleteShopRequest,
|
|
107
107
|
deleteShopResponse,
|
|
108
|
+
upsertShopRequest,
|
|
109
|
+
upsertShopResponse
|
|
108
110
|
} = require('../schemas/definitions/shops');
|
|
109
111
|
const {
|
|
110
112
|
expedition,
|
|
@@ -132,7 +134,8 @@ const {
|
|
|
132
134
|
expireExpeditionRequest,
|
|
133
135
|
unexpireExpeditionRequest,
|
|
134
136
|
updateExpeditionDerivationRequest,
|
|
135
|
-
reminderResponse
|
|
137
|
+
reminderResponse,
|
|
138
|
+
processExpeditionsDepositedFromRequest
|
|
136
139
|
} = require('../schemas/definitions/expeditions');
|
|
137
140
|
const { defaults, getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('../schemas/definitions/defaults');
|
|
138
141
|
const { counters, getCountersResponse } = require('../schemas/definitions/counters');
|
|
@@ -148,6 +151,7 @@ const {
|
|
|
148
151
|
upsertShopEvent,
|
|
149
152
|
upsertNetworkEvent,
|
|
150
153
|
upsertSaleEvent,
|
|
154
|
+
depositedFromDriverEvent,
|
|
151
155
|
} = require('../schemas/definitions/gls-spain-integration-events');
|
|
152
156
|
const {
|
|
153
157
|
representative,
|
|
@@ -2295,6 +2299,61 @@ ${securitySchemes.superAdminRole}`,
|
|
|
2295
2299
|
},
|
|
2296
2300
|
},
|
|
2297
2301
|
},
|
|
2302
|
+
'/shops/upsert/{shopId}': {
|
|
2303
|
+
post: {
|
|
2304
|
+
tags: ['Shops'],
|
|
2305
|
+
summary: '[S] Upsert',
|
|
2306
|
+
description: `
|
|
2307
|
+
Upsert a shop.
|
|
2308
|
+
|
|
2309
|
+
${descriptions.createIdIsOptional}
|
|
2310
|
+
|
|
2311
|
+
${descriptions.optionalArrayPropertiesEmptyByDefault}
|
|
2312
|
+
|
|
2313
|
+
The \`network._id\` property that associates a shop with his network cannot be changed after creation. If the provided network does not
|
|
2314
|
+
exist the API will return a \`500 NetworkDoesNotExistError\`, and if it is readonly it will return a \`500 NetworkCannotBeUpdatedError\`.
|
|
2315
|
+
|
|
2316
|
+
The \`readonly\` property defaults to \`false\` if not provided.
|
|
2317
|
+
|
|
2318
|
+
See [shops](#tag/Shops) for information about the \`status\` property.
|
|
2319
|
+
|
|
2320
|
+
To set custom \`derivationSettings\` and \`expirationSettings\` provide theses properties, or do not provide them and the values under the
|
|
2321
|
+
\`network\` or \`defaults\` properties will be used.
|
|
2322
|
+
|
|
2323
|
+
${securitySchemes.tokens}
|
|
2324
|
+
${securitySchemes.superAdminRole}`,
|
|
2325
|
+
requestBody: {
|
|
2326
|
+
content: { 'application/json': { schema: upsertShopRequest() } },
|
|
2327
|
+
required: true,
|
|
2328
|
+
},
|
|
2329
|
+
responses: {
|
|
2330
|
+
' 200': {
|
|
2331
|
+
description: 'Contains the upsert shop.',
|
|
2332
|
+
content: { 'application/json': { schema: upsertShopResponse() } },
|
|
2333
|
+
},
|
|
2334
|
+
' 400': responses.badRequest,
|
|
2335
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2336
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2337
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2338
|
+
' 401 ': responses.unauthorized,
|
|
2339
|
+
' 403': responses.forbidden,
|
|
2340
|
+
' 415': responses.unsupportedMediaType,
|
|
2341
|
+
' 500': responses.internalServerError,
|
|
2342
|
+
' 500 ': responses.networkDoesNotExist,
|
|
2343
|
+
' 500 ': responses.networkCannotBeUpdated,
|
|
2344
|
+
' 500 ': responses.shopAlreadyExists,
|
|
2345
|
+
},
|
|
2346
|
+
},
|
|
2347
|
+
parameters: [
|
|
2348
|
+
{
|
|
2349
|
+
name: 'shopId',
|
|
2350
|
+
in: 'path',
|
|
2351
|
+
required: true,
|
|
2352
|
+
schema: { type: 'string' },
|
|
2353
|
+
description: `Shop Id to upsert`,
|
|
2354
|
+
}
|
|
2355
|
+
],
|
|
2356
|
+
},
|
|
2298
2357
|
'/shops/find': {
|
|
2299
2358
|
post: {
|
|
2300
2359
|
tags: ['Shops'],
|
|
@@ -2896,6 +2955,49 @@ ${securitySchemes.shopUserRole}`,
|
|
|
2896
2955
|
},
|
|
2897
2956
|
},
|
|
2898
2957
|
},
|
|
2958
|
+
'/expeditions/depositedFromDriver': {
|
|
2959
|
+
post: {
|
|
2960
|
+
tags: ['Expeditions'],
|
|
2961
|
+
summary: '[U] Deposited from driver',
|
|
2962
|
+
description: `
|
|
2963
|
+
Deposited expeditions from a driver, adding more properties to status.
|
|
2964
|
+
|
|
2965
|
+
Each expedition is processed individually and its result returned, so it is possible that some expeditions are processed
|
|
2966
|
+
and some are not. The result for each expedition depends on its situation:
|
|
2967
|
+
|
|
2968
|
+
| Expedition | Type + Status code | Result | New status properties |
|
|
2969
|
+
| :--- | :--- | :--- | :--- |
|
|
2970
|
+
| found in no shop (*)<br/>found in same shop | delivery + incoming | ok | depositedFrom |
|
|
2971
|
+
| found in no shop | any other combination | not found | - |
|
|
2972
|
+
| found in same shop | any other combination | another situation | - |
|
|
2973
|
+
| found in another shop | - | another shop | - |
|
|
2974
|
+
| not found | - | not found | - |
|
|
2975
|
+
| server error | - | error | - |
|
|
2976
|
+
|
|
2977
|
+
(*) If the expedition has no shop but it can be received in this network, then on reception its network and shop will be set to the receiving shop.
|
|
2978
|
+
|
|
2979
|
+
${securitySchemes.tokens}
|
|
2980
|
+
${securitySchemes.shopUserRole}`,
|
|
2981
|
+
requestBody: {
|
|
2982
|
+
content: { 'application/json': { schema: processExpeditionsDepositedFromRequest() } },
|
|
2983
|
+
required: true,
|
|
2984
|
+
},
|
|
2985
|
+
responses: {
|
|
2986
|
+
' 200': {
|
|
2987
|
+
description: 'Contains the result of the processing for each expedition.',
|
|
2988
|
+
content: { 'application/json': { schema: processExpeditionsResponse() } },
|
|
2989
|
+
},
|
|
2990
|
+
' 400': responses.badRequest,
|
|
2991
|
+
' 401': responses.invalidUserInCookieOrHeader,
|
|
2992
|
+
' 401 ': responses.invalidCookieOrHeader,
|
|
2993
|
+
' 401 ': responses.missingCookieOrHeader,
|
|
2994
|
+
' 401 ': responses.unauthorized,
|
|
2995
|
+
' 403': responses.forbidden,
|
|
2996
|
+
' 415': responses.unsupportedMediaType,
|
|
2997
|
+
' 500': responses.internalServerError,
|
|
2998
|
+
},
|
|
2999
|
+
},
|
|
3000
|
+
},
|
|
2899
3001
|
'/expeditions/receiveFromDriver': {
|
|
2900
3002
|
post: {
|
|
2901
3003
|
tags: ['Expeditions'],
|
package/package.json
CHANGED
|
@@ -719,6 +719,16 @@ const processExpeditionsWithCustomerRequest = () => ({
|
|
|
719
719
|
additionalProperties: false,
|
|
720
720
|
});
|
|
721
721
|
|
|
722
|
+
const processExpeditionsDepositedFromRequest = () => ({
|
|
723
|
+
type: 'object',
|
|
724
|
+
properties: {
|
|
725
|
+
expeditions: omit(findByIds(), 'title'),
|
|
726
|
+
driver: driver(),
|
|
727
|
+
},
|
|
728
|
+
required: ['expeditions', 'driver'],
|
|
729
|
+
additionalProperties: false,
|
|
730
|
+
});
|
|
731
|
+
|
|
722
732
|
const processExpeditionResultOk = () => mergeSchemas(objectWithUuid(), resultOk());
|
|
723
733
|
|
|
724
734
|
const processExpeditionResultNotFound = () => mergeSchemas(objectWithUuid(), resultNotFound());
|
|
@@ -883,5 +893,6 @@ module.exports = {
|
|
|
883
893
|
expireExpeditionRequest,
|
|
884
894
|
unexpireExpeditionRequest,
|
|
885
895
|
updateExpeditionDerivationRequest,
|
|
886
|
-
reminderResponse
|
|
896
|
+
reminderResponse,
|
|
897
|
+
processExpeditionsDepositedFromRequest
|
|
887
898
|
};
|
|
@@ -398,6 +398,48 @@ const deleteShopRequest = () => deleteRequest(findById());
|
|
|
398
398
|
|
|
399
399
|
const deleteShopResponse = () => deleteResponse(shop());
|
|
400
400
|
|
|
401
|
+
const upsertShopRequest = () => (
|
|
402
|
+
{
|
|
403
|
+
type: 'object',
|
|
404
|
+
properties: { upsert: {
|
|
405
|
+
title: 'upsert',
|
|
406
|
+
type: 'object',
|
|
407
|
+
properties: {
|
|
408
|
+
...pickProperties(shop(), ['_id', 'createdAt', 'readonly']),
|
|
409
|
+
network: objectWithUuid(),
|
|
410
|
+
zone: objectWithUuid(),
|
|
411
|
+
openingRepresentative: setShopRepresentative(),
|
|
412
|
+
managingRepresentative: setShopRepresentative(),
|
|
413
|
+
status: setShopStatus(),
|
|
414
|
+
...pickProperties(shop(), [
|
|
415
|
+
'name',
|
|
416
|
+
'address',
|
|
417
|
+
'capabilities',
|
|
418
|
+
'openingSchedule',
|
|
419
|
+
'timezone',
|
|
420
|
+
'contacts',
|
|
421
|
+
'fiscal',
|
|
422
|
+
'activity',
|
|
423
|
+
'notes',
|
|
424
|
+
'derivationSettings',
|
|
425
|
+
'expirationSettings',
|
|
426
|
+
]),
|
|
427
|
+
},
|
|
428
|
+
required: ['network', 'status', 'name', 'address'],
|
|
429
|
+
additionalProperties: false,
|
|
430
|
+
} },
|
|
431
|
+
required: ['upsert'],
|
|
432
|
+
additionalProperties: false,
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
const upsertShopResponse = () => (
|
|
436
|
+
{
|
|
437
|
+
type: 'object',
|
|
438
|
+
properties: { upsert: shop() },
|
|
439
|
+
required: ['upsert'],
|
|
440
|
+
additionalProperties: false
|
|
441
|
+
});
|
|
442
|
+
|
|
401
443
|
module.exports = {
|
|
402
444
|
shop,
|
|
403
445
|
objectWithShopId,
|
|
@@ -410,4 +452,6 @@ module.exports = {
|
|
|
410
452
|
updateShopResponse,
|
|
411
453
|
deleteShopRequest,
|
|
412
454
|
deleteShopResponse,
|
|
455
|
+
upsertShopResponse,
|
|
456
|
+
upsertShopRequest,
|
|
413
457
|
};
|
package/schemas/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { addMetadata, errorResponse: sourceErrorResponse } = require('@gls_spain/common-json-schemas');
|
|
1
|
+
const { addMetadata, errorResponse: sourceErrorResponse, upsertRequest } = require('@gls_spain/common-json-schemas');
|
|
2
2
|
const { getDefaultsResponse, updateDefaultsRequest, updateDefaultsResponse } = require('./definitions/defaults');
|
|
3
3
|
const { getCountersResponse } = require('./definitions/counters');
|
|
4
4
|
const { loginResponse: sourceLoginResponse } = require('./definitions/login');
|
|
@@ -54,6 +54,8 @@ const {
|
|
|
54
54
|
updateShopResponse,
|
|
55
55
|
deleteShopRequest,
|
|
56
56
|
deleteShopResponse,
|
|
57
|
+
upsertShopRequest,
|
|
58
|
+
upsertShopResponse
|
|
57
59
|
} = require('./definitions/shops');
|
|
58
60
|
const {
|
|
59
61
|
createExpeditionRequest,
|
|
@@ -195,6 +197,8 @@ const shopUsersUpdateSelfRequest = request(updateSelfShopUserRequest(), 'shopUse
|
|
|
195
197
|
const shopUsersUpdateResponse = response(updateShopUserResponse(), 'shopUsersUpdateResponse');
|
|
196
198
|
const shopUsersDeleteRequest = request(deleteShopUserRequest(), 'shopUsersDeleteRequest');
|
|
197
199
|
const shopUsersDeleteResponse = response(deleteShopUserResponse(), 'shopUsersDeleteResponse');
|
|
200
|
+
const shopUpsertRequest = request(upsertShopRequest(), 'shopUpsertRequest');
|
|
201
|
+
const shopUpsertResponse = response(upsertShopResponse(), 'shopUpsertResponse');
|
|
198
202
|
|
|
199
203
|
const expeditionsCreateRequest = request(createExpeditionRequest(), 'expeditionsCreateRequest');
|
|
200
204
|
const expeditionsCreateResponse = response(createExpeditionResponse(), 'expeditionsCreateResponse');
|
|
@@ -334,6 +338,8 @@ module.exports = {
|
|
|
334
338
|
shopUsersUpdateResponse,
|
|
335
339
|
shopUsersDeleteRequest,
|
|
336
340
|
shopUsersDeleteResponse,
|
|
341
|
+
shopUpsertRequest,
|
|
342
|
+
shopUpsertResponse,
|
|
337
343
|
|
|
338
344
|
expeditionsCreateRequest,
|
|
339
345
|
expeditionsCreateResponse,
|