@gls_spain/gps-common 34.11.1 → 34.12.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 CHANGED
@@ -1,10 +1,17 @@
1
- ## [34.11.1](https://github.com/GLS-Spain/gps-common/compare/v34.11.0...v34.11.1) (2021-05-17)
1
+ # [34.12.0](https://github.com/GLS-Spain/gps-common/compare/v34.11.1...v34.12.0) (2021-05-19)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Features
5
5
 
6
- * problem to new endPoint ([2e46159](https://github.com/GLS-Spain/gps-common/commit/2e46159d6eeeb62eeaab0b7353dd75598e3295be))
6
+ * new end points ([6c82af3](https://github.com/GLS-Spain/gps-common/commit/6c82af32662a96ee6c01db2aff48e289cc9c1ea3))
7
7
 
8
+ ## [34.11.1](https://github.com/GLS-Spain/gps-common/compare/v34.11.0...v34.11.1) (2021-05-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * problem to new endPoint ([2e46159](https://github.com/GLS-Spain/gps-common/commit/2e46159d6eeeb62eeaab0b7353dd75598e3295be))
14
+
8
15
  # [34.11.0](https://github.com/GLS-Spain/gps-common/compare/v34.10.0...v34.11.0) (2021-05-10)
9
16
 
10
17
 
@@ -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,
@@ -2295,6 +2297,61 @@ ${securitySchemes.superAdminRole}`,
2295
2297
  },
2296
2298
  },
2297
2299
  },
2300
+ '/shops/upsert/{shopId}': {
2301
+ post: {
2302
+ tags: ['Shops'],
2303
+ summary: '[S] Upsert',
2304
+ description: `
2305
+ Upsert a shop.
2306
+
2307
+ ${descriptions.createIdIsOptional}
2308
+
2309
+ ${descriptions.optionalArrayPropertiesEmptyByDefault}
2310
+
2311
+ The \`network._id\` property that associates a shop with his network cannot be changed after creation. If the provided network does not
2312
+ exist the API will return a \`500 NetworkDoesNotExistError\`, and if it is readonly it will return a \`500 NetworkCannotBeUpdatedError\`.
2313
+
2314
+ The \`readonly\` property defaults to \`false\` if not provided.
2315
+
2316
+ See [shops](#tag/Shops) for information about the \`status\` property.
2317
+
2318
+ To set custom \`derivationSettings\` and \`expirationSettings\` provide theses properties, or do not provide them and the values under the
2319
+ \`network\` or \`defaults\` properties will be used.
2320
+
2321
+ ${securitySchemes.tokens}
2322
+ ${securitySchemes.superAdminRole}`,
2323
+ requestBody: {
2324
+ content: { 'application/json': { schema: upsertShopRequest() } },
2325
+ required: true,
2326
+ },
2327
+ responses: {
2328
+ ' 200': {
2329
+ description: 'Contains the upsert shop.',
2330
+ content: { 'application/json': { schema: upsertShopResponse() } },
2331
+ },
2332
+ ' 400': responses.badRequest,
2333
+ ' 401': responses.invalidUserInCookieOrHeader,
2334
+ ' 401 ': responses.invalidCookieOrHeader,
2335
+ ' 401 ': responses.missingCookieOrHeader,
2336
+ ' 401 ': responses.unauthorized,
2337
+ ' 403': responses.forbidden,
2338
+ ' 415': responses.unsupportedMediaType,
2339
+ ' 500': responses.internalServerError,
2340
+ ' 500 ': responses.networkDoesNotExist,
2341
+ ' 500 ': responses.networkCannotBeUpdated,
2342
+ ' 500 ': responses.shopAlreadyExists,
2343
+ },
2344
+ },
2345
+ parameters: [
2346
+ {
2347
+ name: 'shopId',
2348
+ in: 'path',
2349
+ required: true,
2350
+ schema: { type: 'string' },
2351
+ description: `Shop Id to upsert`,
2352
+ }
2353
+ ],
2354
+ },
2298
2355
  '/shops/find': {
2299
2356
  post: {
2300
2357
  tags: ['Shops'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gls_spain/gps-common",
3
- "version": "34.11.1",
3
+ "version": "34.12.0",
4
4
  "description": "Errors, schemas and documentation for the Parcel Shops project",
5
5
  "keywords": [
6
6
  "gls"
@@ -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,