btrz-api-client 8.34.0 → 8.36.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.
Files changed (99) hide show
  1. package/lib/client-standalone-min.js +3 -3
  2. package/lib/client.js +4 -0
  3. package/lib/endpoints/inventory/banks.js +39 -21
  4. package/lib/endpoints/inventory/change-requests.js +59 -31
  5. package/lib/endpoints/inventory/control-classes.js +39 -20
  6. package/lib/endpoints/inventory/countries.js +25 -9
  7. package/lib/endpoints/inventory/custom-content.js +38 -21
  8. package/lib/endpoints/inventory/custom-fields.js +25 -17
  9. package/lib/endpoints/inventory/document-types.js +33 -42
  10. package/lib/endpoints/inventory/external-wallets.js +26 -20
  11. package/lib/endpoints/inventory/fees.js +24 -17
  12. package/lib/endpoints/inventory/filtered-trips.js +34 -8
  13. package/lib/endpoints/inventory/financing-costs.js +19 -14
  14. package/lib/endpoints/inventory/garages.js +19 -14
  15. package/lib/endpoints/inventory/getnet-terminals.js +20 -15
  16. package/lib/endpoints/inventory/gift-certificate-definitions.js +10 -5
  17. package/lib/endpoints/inventory/holidays.js +158 -0
  18. package/lib/endpoints/inventory/insurances.js +17 -13
  19. package/lib/endpoints/inventory/items.js +13 -9
  20. package/lib/endpoints/inventory/labels.js +16 -11
  21. package/lib/endpoints/inventory/marital-status.js +16 -11
  22. package/lib/endpoints/inventory/marketplace-modifiers.js +16 -11
  23. package/lib/endpoints/inventory/mit-terminal-settings.js +15 -10
  24. package/lib/endpoints/inventory/mit-terminals.js +16 -11
  25. package/lib/endpoints/inventory/operation-messages.js +18 -12
  26. package/lib/endpoints/inventory/operation-reasons.js +15 -10
  27. package/lib/endpoints/inventory/pay-on-accounts.js +5 -4
  28. package/lib/endpoints/inventory/payment-terminals.js +15 -10
  29. package/lib/endpoints/inventory/products.js +22 -10
  30. package/lib/endpoints/inventory/promos.js +27 -18
  31. package/lib/endpoints/inventory/station-groups.js +2 -4
  32. package/lib/endpoints/inventory/taxes.js +11 -2
  33. package/lib/endpoints/inventory/traveller-card-providers-types.js +6 -6
  34. package/lib/endpoints/inventory/vehicle-types.js +2 -5
  35. package/lib/endpoints/inventory/vehicles.js +4 -2
  36. package/lib/endpoints/notifications/customers.js +1 -1
  37. package/lib/endpoints/notifications/external-customers.js +54 -0
  38. package/lib/endpoints/notifications/pdfs.js +0 -3
  39. package/lib/endpoints/operations/accounting_items.js +7 -1
  40. package/lib/endpoints/operations/flexpasses.js +9 -7
  41. package/lib/endpoints/operations/gift-certificates.js +53 -0
  42. package/lib/endpoints/operations/loans.js +16 -10
  43. package/lib/endpoints/operations/movements.js +17 -6
  44. package/lib/endpoints/operations/pago-express.js +96 -0
  45. package/lib/endpoints/operations/parcels.js +11 -11
  46. package/lib/endpoints/operations/parcels_manifests.js +7 -4
  47. package/package.json +1 -1
  48. package/src/client.js +4 -0
  49. package/src/endpoints/inventory/banks.js +39 -21
  50. package/src/endpoints/inventory/change-requests.js +59 -31
  51. package/src/endpoints/inventory/control-classes.js +39 -20
  52. package/src/endpoints/inventory/countries.js +25 -10
  53. package/src/endpoints/inventory/custom-content.js +38 -22
  54. package/src/endpoints/inventory/custom-fields.js +25 -19
  55. package/src/endpoints/inventory/document-types.js +34 -33
  56. package/src/endpoints/inventory/external-wallets.js +25 -20
  57. package/src/endpoints/inventory/fees.js +24 -18
  58. package/src/endpoints/inventory/filtered-trips.js +29 -8
  59. package/src/endpoints/inventory/financing-costs.js +19 -14
  60. package/src/endpoints/inventory/garages.js +19 -14
  61. package/src/endpoints/inventory/getnet-terminals.js +20 -15
  62. package/src/endpoints/inventory/gift-certificate-definitions.js +10 -5
  63. package/src/endpoints/inventory/holidays.js +121 -0
  64. package/src/endpoints/inventory/insurances.js +17 -13
  65. package/src/endpoints/inventory/items.js +13 -9
  66. package/src/endpoints/inventory/labels.js +16 -11
  67. package/src/endpoints/inventory/marital-status.js +16 -11
  68. package/src/endpoints/inventory/marketplace-modifiers.js +16 -11
  69. package/src/endpoints/inventory/mit-terminal-settings.js +15 -10
  70. package/src/endpoints/inventory/mit-terminals.js +16 -11
  71. package/src/endpoints/inventory/operation-messages.js +18 -12
  72. package/src/endpoints/inventory/operation-reasons.js +15 -10
  73. package/src/endpoints/inventory/pay-on-accounts.js +5 -4
  74. package/src/endpoints/inventory/payment-terminals.js +15 -10
  75. package/src/endpoints/inventory/products.js +22 -10
  76. package/src/endpoints/inventory/promos.js +27 -18
  77. package/src/endpoints/inventory/station-groups.js +2 -4
  78. package/src/endpoints/inventory/taxes.js +11 -2
  79. package/src/endpoints/inventory/traveller-card-providers-types.js +6 -5
  80. package/src/endpoints/inventory/vehicle-types.js +3 -4
  81. package/src/endpoints/inventory/vehicles.js +4 -3
  82. package/src/endpoints/notifications/customers.js +1 -1
  83. package/src/endpoints/notifications/external-customers.js +41 -0
  84. package/src/endpoints/notifications/pdfs.js +0 -3
  85. package/src/endpoints/operations/accounting_items.js +7 -2
  86. package/src/endpoints/operations/flexpasses.js +9 -7
  87. package/src/endpoints/operations/gift-certificates.js +39 -0
  88. package/src/endpoints/operations/loans.js +16 -11
  89. package/src/endpoints/operations/movements.js +17 -6
  90. package/src/endpoints/operations/pago-express.js +73 -0
  91. package/src/endpoints/operations/parcels.js +11 -11
  92. package/src/endpoints/operations/parcels_manifests.js +7 -5
  93. package/test/endpoints/inventory/banks.test.js +8 -10
  94. package/test/endpoints/inventory/filtered-trips.test.js +6 -0
  95. package/test/endpoints/inventory/holidays.test.js +52 -0
  96. package/test/endpoints/inventory/traveller-card-providers-types.test.js +3 -2
  97. package/test/endpoints/notifications/external-customers.test.js +30 -0
  98. package/test/endpoints/operations/gift_certificates.test.js +37 -0
  99. package/test/endpoints/operations/operations.test.js +30 -0
@@ -17,17 +17,18 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
17
17
  * @param {Object} deps
18
18
  * @param {import("axios").AxiosInstance} deps.client
19
19
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
20
- * @returns {{ all: function, create: function }}
20
+ * @returns {{ all: function, create: function, remove: function }}
21
21
  */
22
22
  function filteredTripsFactory({client, internalAuthTokenProvider}) {
23
23
  /**
24
- * GET /filtered-trips - list filtered trips.
24
+ * GET /filtered-trips - list filtered trips (paginated).
25
25
  * @param {Object} opts
26
26
  * @param {string} [opts.token] - API key
27
27
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
28
- * @param {FilteredTripsListQuery} [opts.query] - Query params (providerIds, productId, originId, destinationId, page, orderBy, orderDir)
28
+ * @param {FilteredTripsListQuery} [opts.query] - Query params
29
29
  * @param {Object} [opts.headers] - Optional headers
30
- * @returns {Promise<import("axios").AxiosResponse>}
30
+ * @returns {Promise<import("axios").AxiosResponse<{ filteredTrips: Array, next?: string, previous?: string, count: number }>>}
31
+ * @throws When response is 4xx/5xx (401, 500)
31
32
  */
32
33
  function all({token, jwtToken, query = {}, headers}) {
33
34
  return client.get("/filtered-trips", {
@@ -37,13 +38,14 @@ function filteredTripsFactory({client, internalAuthTokenProvider}) {
37
38
  }
38
39
 
39
40
  /**
40
- * POST /filtered-trips - create filtered trip. API does not accept query params.
41
+ * POST /filtered-trips - add a trip to the blacklist (filtered trips).
41
42
  * @param {Object} opts
42
43
  * @param {string} [opts.token] - API key
43
44
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
44
- * @param {Object} opts.tripSegmentsId - Trip segments id payload
45
+ * @param {string} opts.tripSegmentsId - Base64-encoded JSON (FilteredTripRequest: productId, segments)
45
46
  * @param {Object} [opts.headers] - Optional headers
46
- * @returns {Promise<import("axios").AxiosResponse>}
47
+ * @returns {Promise<import("axios").AxiosResponse<{ filteredTrip: Object }>>}
48
+ * @throws When response is 4xx/5xx (400, 401, 409 TRIP_ALREADY_FILTERED, 500)
47
49
  */
48
50
  function create({token, jwtToken, tripSegmentsId, headers}) {
49
51
  return client({
@@ -54,9 +56,28 @@ function filteredTripsFactory({client, internalAuthTokenProvider}) {
54
56
  });
55
57
  }
56
58
 
59
+ /**
60
+ * DELETE /filtered-trip/:filteredTripId - remove a filtered trip from the blacklist.
61
+ * @param {Object} opts
62
+ * @param {string} [opts.token] - API key
63
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
64
+ * @param {string} opts.filteredTripId - Filtered trip id (24 hex characters)
65
+ * @param {Object} [opts.headers] - Optional headers
66
+ * @returns {Promise<import("axios").AxiosResponse<void>>}
67
+ * @throws When response is 4xx/5xx (400, 401, 500)
68
+ */
69
+ function remove({token, jwtToken, filteredTripId, headers}) {
70
+ return client({
71
+ url: `/filtered-trip/${filteredTripId}`,
72
+ method: "delete",
73
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
74
+ });
75
+ }
76
+
57
77
  return {
58
78
  all,
59
- create
79
+ create,
80
+ remove
60
81
  };
61
82
  }
62
83
 
@@ -24,13 +24,14 @@ const {
24
24
  */
25
25
  function financingCostsFactory({client, internalAuthTokenProvider}) {
26
26
  /**
27
- * GET /financing-costs - list financing costs.
27
+ * GET /financing-costs - list financing costs (paginated).
28
28
  * @param {Object} opts
29
29
  * @param {string} [opts.token] - API key
30
30
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
31
31
  * @param {FinancingCostsListQuery} [opts.query] - Query params (page, providerId)
32
32
  * @param {Object} [opts.headers] - Optional headers
33
- * @returns {Promise<import("axios").AxiosResponse>}
33
+ * @returns {Promise<import("axios").AxiosResponse<{ financingcosts: Array, next: string, previous: string, count: number }>>}
34
+ * @throws When response is 4xx/5xx (400 INVALID_PAGE, 401, 500)
34
35
  */
35
36
  function all({
36
37
  token,
@@ -49,10 +50,11 @@ function financingCostsFactory({client, internalAuthTokenProvider}) {
49
50
  * @param {Object} opts
50
51
  * @param {string} [opts.token] - API key
51
52
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
52
- * @param {string} opts.id - Financing cost id
53
+ * @param {string} opts.id - Financing cost id (24 hex characters)
53
54
  * @param {FinancingCostGetQuery} [opts.query] - Query params (providerId)
54
55
  * @param {Object} [opts.headers] - Optional headers
55
- * @returns {Promise<import("axios").AxiosResponse>}
56
+ * @returns {Promise<import("axios").AxiosResponse<{ financingcost: Object }>>}
57
+ * @throws When response is 4xx/5xx (400 INVALID_FINANCINGCOST_ID, 401, 404 FINANCINGCOST_NOT_FOUND, 500)
56
58
  */
57
59
  function get({
58
60
  id,
@@ -68,13 +70,14 @@ function financingCostsFactory({client, internalAuthTokenProvider}) {
68
70
  }
69
71
 
70
72
  /**
71
- * POST /financing-costs - create financing cost. API does not accept query params.
73
+ * POST /financing-costs - create financing cost.
72
74
  * @param {Object} opts
73
75
  * @param {string} [opts.token] - API key
74
76
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
75
- * @param {Object} opts.financingCost - Financing cost payload
77
+ * @param {Object} opts.financingCost - Financing cost (name, internalId, currencyCode, dow, creditCard, maxQuota, interest, enabled)
76
78
  * @param {Object} [opts.headers] - Optional headers
77
- * @returns {Promise<import("axios").AxiosResponse>}
79
+ * @returns {Promise<import("axios").AxiosResponse<{ financingcost: Object }>>}
80
+ * @throws When response is 4xx/5xx (400 WRONG_DATA, 401, 409 duplicated internalId, 500)
78
81
  */
79
82
  function create({jwtToken, token, financingCost, headers}) {
80
83
  return client({
@@ -88,13 +91,14 @@ function financingCostsFactory({client, internalAuthTokenProvider}) {
88
91
  }
89
92
 
90
93
  /**
91
- * DELETE /financing-costs/:id - remove financing cost. API does not accept query params.
94
+ * DELETE /financing-costs/:id - remove financing cost.
92
95
  * @param {Object} opts
93
96
  * @param {string} [opts.token] - API key
94
97
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
95
- * @param {string} opts.id - Financing cost id
98
+ * @param {string} opts.id - Financing cost id (24 hex characters)
96
99
  * @param {Object} [opts.headers] - Optional headers
97
- * @returns {Promise<import("axios").AxiosResponse>}
100
+ * @returns {Promise<import("axios").AxiosResponse<{ financingcostId: string }>>}
101
+ * @throws When response is 4xx/5xx (400 INVALID_FINANCINGCOST_ID, 401, 404 FINANCINGCOST_NOT_FOUND, 500)
98
102
  */
99
103
  function remove({jwtToken, id, token, headers, query = {}}) {
100
104
  return client({
@@ -106,14 +110,15 @@ function financingCostsFactory({client, internalAuthTokenProvider}) {
106
110
  }
107
111
 
108
112
  /**
109
- * PUT /financing-costs/:id - update financing cost. API does not accept query params.
113
+ * PUT /financing-costs/:id - update financing cost.
110
114
  * @param {Object} opts
111
115
  * @param {string} [opts.token] - API key
112
116
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
113
- * @param {string} opts.id - Financing cost id
114
- * @param {Object} opts.financingCost - Financing cost payload
117
+ * @param {string} opts.id - Financing cost id (24 hex characters)
118
+ * @param {Object} opts.financingCost - Financing cost (name, internalId, currencyCode, dow, creditCard, maxQuota, interest, enabled)
115
119
  * @param {Object} [opts.headers] - Optional headers
116
- * @returns {Promise<import("axios").AxiosResponse>}
120
+ * @returns {Promise<import("axios").AxiosResponse<{ financingcost: Object }>>}
121
+ * @throws When response is 4xx/5xx (400 WRONG_DATA, 401, 404 not found, 409 duplicated internalId, 500)
117
122
  */
118
123
  function update({jwtToken, token, id, financingCost, headers}) {
119
124
  return client({
@@ -16,13 +16,14 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
16
16
  */
17
17
  function garagesFactory({client, internalAuthTokenProvider}) {
18
18
  /**
19
- * GET /garages - list garages.
19
+ * GET /garages - list garages (paginated).
20
20
  * @param {Object} opts
21
21
  * @param {string} [opts.token] - API key
22
22
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
23
23
  * @param {GaragesQuery} [opts.query] - Query params (location, stationId)
24
24
  * @param {Object} [opts.headers] - Optional headers
25
- * @returns {Promise<import("axios").AxiosResponse>}
25
+ * @returns {Promise<import("axios").AxiosResponse<{ garages: Array, next?: string, previous?: string, count: number }>>}
26
+ * @throws When response is 4xx/5xx (401, 500)
26
27
  */
27
28
  function all({token, jwtToken, query = {}, headers}) {
28
29
  return client.get("/garages", {
@@ -32,13 +33,14 @@ function garagesFactory({client, internalAuthTokenProvider}) {
32
33
  }
33
34
 
34
35
  /**
35
- * GET /garages/:garageId - get garage by id. API does not accept query params.
36
+ * GET /garages/:garageId - get garage by id.
36
37
  * @param {Object} opts
37
38
  * @param {string} [opts.token] - API key
38
39
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
39
- * @param {string} opts.garageId - Garage id
40
+ * @param {string} opts.garageId - Garage id (24 hex characters)
40
41
  * @param {Object} [opts.headers] - Optional headers
41
- * @returns {Promise<import("axios").AxiosResponse>}
42
+ * @returns {Promise<import("axios").AxiosResponse<{ garage: Object }>>}
43
+ * @throws When response is 4xx/5xx (400 INVALID_GARAGE_ID, 401, 404 GARAGE_NOT_FOUND, 500)
42
44
  */
43
45
  function get({token, jwtToken, garageId, headers}) {
44
46
  return client.get(`/garages/${garageId}`, {
@@ -47,13 +49,14 @@ function garagesFactory({client, internalAuthTokenProvider}) {
47
49
  }
48
50
 
49
51
  /**
50
- * POST /garages - create garage. API does not accept query params.
52
+ * POST /garages - create garage.
51
53
  * @param {Object} opts
52
54
  * @param {string} [opts.token] - API key
53
55
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
54
- * @param {Object} opts.data - Garage payload
56
+ * @param {Object} opts.data - Garage payload (name, location, stationId)
55
57
  * @param {Object} [opts.headers] - Optional headers
56
- * @returns {Promise<import("axios").AxiosResponse>}
58
+ * @returns {Promise<import("axios").AxiosResponse<{ garage: Object }>>}
59
+ * @throws When response is 4xx/5xx (400 WRONG_DATA, 401, 500)
57
60
  */
58
61
  function create({token, jwtToken, data, headers}) {
59
62
  return client({
@@ -71,10 +74,11 @@ function garagesFactory({client, internalAuthTokenProvider}) {
71
74
  * @param {Object} opts
72
75
  * @param {string} [opts.token] - API key
73
76
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
74
- * @param {string} opts.garageId - Garage id
75
- * @param {Object} opts.data - Garage payload
77
+ * @param {string} opts.garageId - Garage id (24 hex characters)
78
+ * @param {Object} opts.data - Garage payload (name, location, stationId)
76
79
  * @param {Object} [opts.headers] - Optional headers
77
- * @returns {Promise<import("axios").AxiosResponse>}
80
+ * @returns {Promise<import("axios").AxiosResponse<{ garage: Object }>>}
81
+ * @throws When response is 4xx/5xx (400, 401, 404 GARAGE_NOT_FOUND/STATION_NOT_FOUND, 500)
78
82
  */
79
83
  function update({token, jwtToken, garageId, data, headers}) {
80
84
  return client({
@@ -88,13 +92,14 @@ function garagesFactory({client, internalAuthTokenProvider}) {
88
92
  }
89
93
 
90
94
  /**
91
- * DELETE /garages/:garageId - remove garage. API does not accept query params.
95
+ * DELETE /garages/:garageId - remove garage.
92
96
  * @param {Object} opts
93
97
  * @param {string} [opts.token] - API key
94
98
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
95
- * @param {string} opts.garageId - Garage id
99
+ * @param {string} opts.garageId - Garage id (24 hex characters)
96
100
  * @param {Object} [opts.headers] - Optional headers
97
- * @returns {Promise<import("axios").AxiosResponse>}
101
+ * @returns {Promise<import("axios").AxiosResponse<{ success: boolean }>>}
102
+ * @throws When response is 4xx/5xx (400 INVALID_GARAGE_ID or GARAGE_WITH_VEHICLES, 401, 404, 500)
98
103
  */
99
104
  function remove({token, jwtToken, garageId, headers}) {
100
105
  return client({
@@ -19,13 +19,14 @@ const {
19
19
  */
20
20
  function getnetTerminalFactory({client, internalAuthTokenProvider}) {
21
21
  /**
22
- * GET /getnet-terminals - list getnet terminals.
22
+ * GET /getnet-terminals - list getnet terminals (paginated).
23
23
  * @param {Object} opts
24
24
  * @param {string} [opts.token] - API key
25
25
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
26
- * @param {GetnetTerminalsQuery} [opts.query] - Query params
26
+ * @param {GetnetTerminalsQuery} [opts.query] - Query params (page, stationId, serialNumber)
27
27
  * @param {Object} [opts.headers] - Optional headers
28
- * @returns {Promise<import("axios").AxiosResponse>}
28
+ * @returns {Promise<import("axios").AxiosResponse<{ getnetTerminals: Array, next?: string, previous?: string, count: number }>>}
29
+ * @throws When response is 4xx/5xx (400 INVALID_PAGE, 401, 500)
29
30
  */
30
31
  function all({
31
32
  token,
@@ -40,13 +41,14 @@ function getnetTerminalFactory({client, internalAuthTokenProvider}) {
40
41
  }
41
42
 
42
43
  /**
43
- * GET /getnet-terminals/:getnetTerminalId - get a getnet terminal. API does not accept query params.
44
+ * GET /getnet-terminals/:getnetTerminalId - get a getnet terminal by id.
44
45
  * @param {Object} opts
45
46
  * @param {string} [opts.token] - API key
46
47
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
47
- * @param {string} opts.getnetTerminalId - Getnet terminal id
48
+ * @param {string} opts.getnetTerminalId - Getnet terminal id (24 hex characters)
48
49
  * @param {Object} [opts.headers] - Optional headers
49
- * @returns {Promise<import("axios").AxiosResponse>}
50
+ * @returns {Promise<import("axios").AxiosResponse<{ getnetTerminal: Object }>>}
51
+ * @throws When response is 4xx/5xx (400 INVALID_GETNET_TERMINAL_ID, 401, 404 GETNET_TERMINAL_NOT_FOUND, 500)
50
52
  */
51
53
  function get({
52
54
  getnetTerminalId,
@@ -64,9 +66,10 @@ function getnetTerminalFactory({client, internalAuthTokenProvider}) {
64
66
  * @param {Object} opts
65
67
  * @param {string} [opts.token] - API key
66
68
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
67
- * @param {Object} opts.getnetTerminal - Getnet terminal payload
69
+ * @param {Object} opts.getnetTerminal - Getnet terminal payload (name, serialNumber, stationId optional)
68
70
  * @param {Object} [opts.headers] - Optional headers
69
- * @returns {Promise<import("axios").AxiosResponse>}
71
+ * @returns {Promise<import("axios").AxiosResponse<{ getnetTerminal: Object }>>}
72
+ * @throws When response is 4xx/5xx (400 WRONG_DATA/INVALID_STATION_ID/STATION_NOT_FOUND, 401, 409 duplicate serial, 500)
70
73
  */
71
74
  function create({
72
75
  jwtToken,
@@ -85,13 +88,14 @@ function getnetTerminalFactory({client, internalAuthTokenProvider}) {
85
88
  }
86
89
 
87
90
  /**
88
- * DELETE /getnet-terminals/:getnetTerminalId - remove getnet terminal. API does not accept query params.
91
+ * DELETE /getnet-terminals/:getnetTerminalId - remove getnet terminal.
89
92
  * @param {Object} opts
90
93
  * @param {string} [opts.token] - API key
91
94
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
92
- * @param {string} opts.getnetTerminalId - Getnet terminal id
95
+ * @param {string} opts.getnetTerminalId - Getnet terminal id (24 hex characters)
93
96
  * @param {Object} [opts.headers] - Optional headers
94
- * @returns {Promise<import("axios").AxiosResponse>}
97
+ * @returns {Promise<import("axios").AxiosResponse<{ getnetTerminalId: string }>>}
98
+ * @throws When response is 4xx/5xx (400 INVALID_GETNET_TERMINAL_ID, 401, 404 GETNET_TERMINAL_NOT_FOUND, 500)
95
99
  */
96
100
  function remove({
97
101
  jwtToken,
@@ -107,14 +111,15 @@ function getnetTerminalFactory({client, internalAuthTokenProvider}) {
107
111
  }
108
112
 
109
113
  /**
110
- * PUT /getnet-terminals/:getnetTerminalId - update getnet terminal. API does not accept query params.
114
+ * PUT /getnet-terminals/:getnetTerminalId - update getnet terminal.
111
115
  * @param {Object} opts
112
116
  * @param {string} [opts.token] - API key
113
117
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
114
- * @param {string} opts.getnetTerminalId - Getnet terminal id
115
- * @param {Object} opts.getnetTerminal - Getnet terminal payload
118
+ * @param {string} opts.getnetTerminalId - Getnet terminal id (24 hex characters)
119
+ * @param {Object} opts.getnetTerminal - Getnet terminal payload (name, serialNumber, stationId)
116
120
  * @param {Object} [opts.headers] - Optional headers
117
- * @returns {Promise<import("axios").AxiosResponse>}
121
+ * @returns {Promise<import("axios").AxiosResponse<{ getnetTerminal: Object }>>}
122
+ * @throws When response is 4xx/5xx (400, 401, 404 GETNET_TERMINAL_NOT_FOUND, 409 duplicate serial, 500)
118
123
  */
119
124
  function update({
120
125
  jwtToken,
@@ -22,7 +22,8 @@ function giftCertificateDefinitionsFactory({client, internalAuthTokenProvider})
22
22
  * @param {string} [opts.token] - API key
23
23
  * @param {GiftCertificateDefinitionsListQuery} [opts.query] - Query params (channels, currencies, providerId)
24
24
  * @param {Object} [opts.headers] - Optional headers
25
- * @returns {Promise<import("axios").AxiosResponse>}
25
+ * @returns {Promise<import("axios").AxiosResponse<{ giftCertificates: Object[], next?: string, previous?: string, count: number }>>}
26
+ * @throws 400 WRONG_DATA, PROVIDER_ID; 401 Unauthorized; 500.
26
27
  */
27
28
  function all({token, query = {}, headers}) {
28
29
  return client.get("/gift-certificate-definitions", {
@@ -38,7 +39,8 @@ function giftCertificateDefinitionsFactory({client, internalAuthTokenProvider})
38
39
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
39
40
  * @param {string} opts.giftcertificateId - Gift certificate definition id
40
41
  * @param {Object} [opts.headers] - Optional headers
41
- * @returns {Promise<import("axios").AxiosResponse>}
42
+ * @returns {Promise<import("axios").AxiosResponse<{ giftcertificate: Object }>>}
43
+ * @throws When the API returns an error. 400 INVALID_GIFTCERTIFICATE_ID; 401 Unauthorized; 404 GIFTCERTIFICATE_NOT_FOUND; 500.
42
44
  */
43
45
  function get({token, jwtToken, giftcertificateId, query = {}, headers}) {
44
46
  return client({
@@ -56,7 +58,8 @@ function giftCertificateDefinitionsFactory({client, internalAuthTokenProvider})
56
58
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
57
59
  * @param {Object} opts.giftcertificate - Gift certificate payload
58
60
  * @param {Object} [opts.headers] - Optional headers
59
- * @returns {Promise<import("axios").AxiosResponse>}
61
+ * @returns {Promise<import("axios").AxiosResponse<{ giftcertificate: Object }>>}
62
+ * @throws When the API returns an error. 400 WRONG_DATA; 401 Unauthorized; 500.
60
63
  */
61
64
  function create({token, jwtToken, giftcertificate, query = {}, headers}) {
62
65
  return client({
@@ -76,7 +79,8 @@ function giftCertificateDefinitionsFactory({client, internalAuthTokenProvider})
76
79
  * @param {string} opts.giftcertificateId - Gift certificate definition id
77
80
  * @param {Object} opts.giftcertificate - Gift certificate payload
78
81
  * @param {Object} [opts.headers] - Optional headers
79
- * @returns {Promise<import("axios").AxiosResponse>}
82
+ * @returns {Promise<import("axios").AxiosResponse<{ giftcertificate: Object }>>}
83
+ * @throws 400 WRONG_DATA, GIFTCERTIFICATE_ID; 401; 404 GIFTCERTIFICATE_NOT_FOUND; 500.
80
84
  */
81
85
  function update({token, jwtToken, giftcertificateId, giftcertificate, query = {}, headers}) {
82
86
  return client({
@@ -95,7 +99,8 @@ function giftCertificateDefinitionsFactory({client, internalAuthTokenProvider})
95
99
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
96
100
  * @param {string} opts.giftcertificateId - Gift certificate definition id
97
101
  * @param {Object} [opts.headers] - Optional headers
98
- * @returns {Promise<import("axios").AxiosResponse>}
102
+ * @returns {Promise<import("axios").AxiosResponse<{ giftcertificateId: string }>>}
103
+ * @throws 400 WRONG_DATA, GIFTCERTIFICATE_ID, GIFT_CERTIFICATE_DEFINITION_ALREADY_IMPLEMENTED; 401; 404; 500.
99
104
  */
100
105
  function remove({token, jwtToken, giftcertificateId, query = {}, headers}) {
101
106
  return client({
@@ -0,0 +1,121 @@
1
+ const {authorizationHeaders} = require("../endpoints_helpers.js");
2
+
3
+ /**
4
+ * Query params for GET /holidays (btrz-api-inventory). See get-handler getSpec().
5
+ * @typedef {Object} HolidaysListQuery
6
+ * @property {number} [page] - The page number to retrieve
7
+ * @property {string} [providerId] - Provider (account) id to list holidays for
8
+ */
9
+
10
+ /**
11
+ * Factory for holidays API (btrz-api-inventory).
12
+ * @param {Object} deps
13
+ * @param {import("axios").AxiosInstance} deps.client
14
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
15
+ * @returns {{ all: function, get: function, create: function, update: function, remove: function }}
16
+ */
17
+ function holidaysFactory({client, internalAuthTokenProvider}) {
18
+ /**
19
+ * GET /holidays - list holidays (paginated).
20
+ * @param {Object} opts
21
+ * @param {string} [opts.token] - API key
22
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
23
+ * @param {HolidaysListQuery} [opts.query] - Query params (page, providerId)
24
+ * @param {Object} [opts.headers] - Optional headers
25
+ * @returns {Promise<import("axios").AxiosResponse<{ holidays: Object[], next?: string, previous?: string, count: number }>>}
26
+ * @throws 400 INVALID_PAGE; 401; 500.
27
+ */
28
+ function all({token, jwtToken, query = {}, headers}) {
29
+ return client.get("/holidays", {
30
+ params: query,
31
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
32
+ });
33
+ }
34
+
35
+ /**
36
+ * GET /holidays/:holidayId - get holiday by id.
37
+ * @param {Object} opts
38
+ * @param {string} [opts.token] - API key
39
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
40
+ * @param {string} opts.holidayId - Holiday id (24 hex characters)
41
+ * @param {{ providerId?: string }} [opts.query] - Optional providerId
42
+ * @param {Object} [opts.headers] - Optional headers
43
+ * @returns {Promise<import("axios").AxiosResponse<{ holiday: Object }>>}
44
+ * @throws 400 INVALID_HOLIDAY_ID, INVALID_PROVIDER_ID; 401; 404 HOLIDAY_NOT_FOUND; 500.
45
+ */
46
+ function get({token, jwtToken, holidayId, query = {}, headers}) {
47
+ return client({
48
+ url: `/holidays/${holidayId}`,
49
+ method: "get",
50
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
51
+ params: query
52
+ });
53
+ }
54
+
55
+ /**
56
+ * POST /holidays - create holiday.
57
+ * @param {Object} opts
58
+ * @param {string} [opts.token] - API key
59
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
60
+ * @param {Object} opts.holiday - Holiday payload (day, month, year required; name, blackout, recurring, externalId optional)
61
+ * @param {Object} [opts.headers] - Optional headers
62
+ * @returns {Promise<import("axios").AxiosResponse<{ holiday: Object }>>}
63
+ * @throws 400 WRONG_DATA; 401; 500.
64
+ */
65
+ function create({token, jwtToken, holiday, headers}) {
66
+ return client({
67
+ url: "/holidays",
68
+ method: "post",
69
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
70
+ data: {holiday}
71
+ });
72
+ }
73
+
74
+ /**
75
+ * PUT /holidays/:holidayId - update holiday.
76
+ * @param {Object} opts
77
+ * @param {string} [opts.token] - API key
78
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
79
+ * @param {string} opts.holidayId - Holiday id
80
+ * @param {Object} opts.holiday - Holiday payload
81
+ * @param {Object} [opts.headers] - Optional headers
82
+ * @returns {Promise<import("axios").AxiosResponse<{ holiday: Object }>>}
83
+ * @throws 400 WRONG_DATA, INVALID_HOLIDAY_ID; 401; 404 HOLIDAY_NOT_FOUND; 500.
84
+ */
85
+ function update({token, jwtToken, holidayId, holiday, headers}) {
86
+ return client({
87
+ url: `/holidays/${holidayId}`,
88
+ method: "put",
89
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
90
+ data: {holiday}
91
+ });
92
+ }
93
+
94
+ /**
95
+ * DELETE /holidays/:holidayId - remove holiday.
96
+ * @param {Object} opts
97
+ * @param {string} [opts.token] - API key
98
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
99
+ * @param {string} opts.holidayId - Holiday id
100
+ * @param {Object} [opts.headers] - Optional headers
101
+ * @returns {Promise<import("axios").AxiosResponse<{ holidayId: string }>>}
102
+ * @throws 400 INVALID_HOLIDAY_ID; 401; 404 HOLIDAY_NOT_FOUND; 500.
103
+ */
104
+ function remove({token, jwtToken, holidayId, headers}) {
105
+ return client({
106
+ url: `/holidays/${holidayId}`,
107
+ method: "delete",
108
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
109
+ });
110
+ }
111
+
112
+ return {
113
+ all,
114
+ get,
115
+ create,
116
+ update,
117
+ remove
118
+ };
119
+ }
120
+
121
+ module.exports = holidaysFactory;
@@ -5,9 +5,9 @@ const {
5
5
  /**
6
6
  * Query params for GET /insurances (btrz-api-inventory). See get-insurances getSpec().
7
7
  * @typedef {Object} InsurancesListQuery
8
- * @property {string} [productId] - Filter by product id
9
- * @property {boolean} [enabled] - Filter by enabled
10
- * @property {string[]} [providerIds] - Filter by provider ids
8
+ * @property {string} [productId] - The ids of the products to get insurances for
9
+ * @property {string} [enabled] - Filter insurances if they are enabled or not [true, false]
10
+ * @property {string} [providerIds] - The ids of the providers to get products for
11
11
  */
12
12
 
13
13
  /**
@@ -21,12 +21,13 @@ function insurancesFactory({
21
21
  client, internalAuthTokenProvider
22
22
  }) {
23
23
  /**
24
- * GET /insurances - list insurances.
24
+ * GET /insurances - list insurances for the account and product provided.
25
25
  * @param {Object} opts
26
26
  * @param {string} [opts.token] - API key
27
27
  * @param {InsurancesListQuery} [opts.query] - Query params (productId, enabled, providerIds)
28
28
  * @param {Object} [opts.headers] - Optional headers
29
- * @returns {Promise<import("axios").AxiosResponse>}
29
+ * @returns {Promise<import("axios").AxiosResponse<{ insurances: Object[] }>>}
30
+ * @throws 400 INVALID_PRODUCTIDS; 401; 500.
30
31
  */
31
32
  function all({
32
33
  token, query = {}, headers
@@ -40,12 +41,13 @@ function insurancesFactory({
40
41
  }
41
42
 
42
43
  /**
43
- * GET /insurances/:insuranceId - get insurance by id. API does not accept query params.
44
+ * GET /insurances/:insuranceId - get insurance by id.
44
45
  * @param {Object} opts
45
46
  * @param {string} [opts.token] - API key
46
- * @param {string} opts.insuranceId - Insurance id
47
+ * @param {string} opts.insuranceId - Insurance id (24 hex characters)
47
48
  * @param {Object} [opts.headers] - Optional headers
48
- * @returns {Promise<import("axios").AxiosResponse>}
49
+ * @returns {Promise<import("axios").AxiosResponse<{ insurance: Object }>>}
50
+ * @throws 400 INVALID_INSURANCE_ID; 401; 404 INSURANCE_NOT_FOUND; 500.
49
51
  */
50
52
  function get({
51
53
  token, insuranceId, headers
@@ -80,14 +82,15 @@ function insurancesFactory({
80
82
  }
81
83
 
82
84
  /**
83
- * PUT /insurances/:insuranceId - update insurance. API does not accept query params.
85
+ * PUT /insurances/:insuranceId - update insurance.
84
86
  * @param {Object} opts
85
87
  * @param {string} [opts.token] - API key
86
88
  * @param {Object} opts.insurance - Insurance payload
87
89
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
88
90
  * @param {string} opts.insuranceId - Insurance id
89
91
  * @param {Object} [opts.headers] - Optional headers
90
- * @returns {Promise<import("axios").AxiosResponse>}
92
+ * @returns {Promise<import("axios").AxiosResponse<{ insurance: Object }>>}
93
+ * @throws 400 WRONG_DATA; 401; 404 INSURANCE_NOT_FOUND; 500.
91
94
  */
92
95
  function update({
93
96
  token, insurance, jwtToken, insuranceId, headers
@@ -103,13 +106,14 @@ function insurancesFactory({
103
106
  }
104
107
 
105
108
  /**
106
- * DELETE /insurances/:insuranceId - remove insurance. API does not accept query params.
109
+ * DELETE /insurances/:insuranceId - remove insurance.
107
110
  * @param {Object} opts
108
111
  * @param {string} [opts.token] - API key
109
112
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
110
- * @param {string} opts.insuranceId - Insurance id
113
+ * @param {string} opts.insuranceId - Insurance id (24 hex characters)
111
114
  * @param {Object} [opts.headers] - Optional headers
112
- * @returns {Promise<import("axios").AxiosResponse>}
115
+ * @returns {Promise<import("axios").AxiosResponse<{ insuranceId: string }>>}
116
+ * @throws 400 INVALID_INSURANCE_ID; 401; 404 INSURANCE_NOT_FOUND; 500.
113
117
  */
114
118
  function remove({
115
119
  token, jwtToken, insuranceId, headers
@@ -30,13 +30,14 @@ const {
30
30
  */
31
31
  function itemsFactory({client, internalAuthTokenProvider}) {
32
32
  /**
33
- * GET /items - list items.
33
+ * GET /items - list items (paginated).
34
34
  * @param {Object} opts
35
35
  * @param {string} [opts.token] - API key
36
36
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
37
37
  * @param {ItemsQuery} [opts.query] - Query params (productId, disabled, type, providerIds, channels, currency, etc.)
38
38
  * @param {Object} [opts.headers] - Optional headers
39
- * @returns {Promise<import("axios").AxiosResponse>}
39
+ * @returns {Promise<import("axios").AxiosResponse<{ items: Object[], next?: string, previous?: string, count: number }>>}
40
+ * @throws 401; 500.
40
41
  */
41
42
  function all({
42
43
  token,
@@ -56,10 +57,11 @@ function itemsFactory({client, internalAuthTokenProvider}) {
56
57
  * @param {Object} opts
57
58
  * @param {string} [opts.token] - API key
58
59
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
59
- * @param {string} opts.itemId - Item id (ObjectId format)
60
+ * @param {string} opts.itemId - Item id (24 hex characters)
60
61
  * @param {ItemByIdQuery} [opts.query] - Query params (currency)
61
62
  * @param {Object} [opts.headers] - Optional headers
62
- * @returns {Promise<import("axios").AxiosResponse>}
63
+ * @returns {Promise<import("axios").AxiosResponse<{ item: Object }>>}
64
+ * @throws 400 INVALID_ITEM_ID; 401; 404 ITEM_NOT_FOUND; 500.
63
65
  */
64
66
  function get({itemId, token, jwtToken, query = {}, headers}) {
65
67
  return client.get(`/items/${itemId}`, {
@@ -73,9 +75,10 @@ function itemsFactory({client, internalAuthTokenProvider}) {
73
75
  * @param {Object} opts
74
76
  * @param {string} [opts.token] - API key
75
77
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
76
- * @param {Object} opts.item - Item payload
78
+ * @param {Object} opts.item - Item payload (ItemPostData: name, productId, type, amount, valueType, order, etc.)
77
79
  * @param {Object} [opts.headers] - Optional headers
78
- * @returns {Promise<import("axios").AxiosResponse>}
80
+ * @returns {Promise<import("axios").AxiosResponse<{ item: Object }>>}
81
+ * @throws 400 WRONG_DATA, PRODUCT_ID_INVALID, etc.; 401; 404 PRODUCT_NOT_FOUND, etc.; 500.
79
82
  */
80
83
  function create({jwtToken, item, token, headers}) {
81
84
  return client({
@@ -91,10 +94,11 @@ function itemsFactory({client, internalAuthTokenProvider}) {
91
94
  * @param {Object} opts
92
95
  * @param {string} [opts.token] - API key
93
96
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
94
- * @param {string} opts.itemId - Item id
95
- * @param {Object} opts.item - Item payload
97
+ * @param {string} opts.itemId - Item id (24 hex characters)
98
+ * @param {Object} opts.item - Item payload (ItemPostData)
96
99
  * @param {Object} [opts.headers] - Optional headers
97
- * @returns {Promise<import("axios").AxiosResponse>}
100
+ * @returns {Promise<import("axios").AxiosResponse<{ item: Object }>>}
101
+ * @throws 400 WRONG_DATA, INVALID ids; 401; 404 ITEM_NOT_FOUND, PRODUCT_NOT_FOUND, etc.; 500.
98
102
  */
99
103
  function update({jwtToken, token, itemId, item, headers}) {
100
104
  return client({