btrz-api-client 8.59.0 → 8.61.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.
@@ -21,7 +21,8 @@ var _require = require("../endpoints_helpers.js"),
21
21
  * @returns {{
22
22
  * saldoMax: {
23
23
  * all: function, get: function, create: function, update: function,
24
- * nip: object, authorization: { create: function }, movements: { create: function }
24
+ * nip: object, authorization: { create: function }, movements: { create: function },
25
+ * statements: { create: function }
25
26
  * }
26
27
  * }}
27
28
  */
@@ -34,7 +35,7 @@ function externalWalletsFactory(_ref) {
34
35
  /**
35
36
  * @type {{
36
37
  * all: function, create: function, get: function, update: function,
37
- * nip: object, authorization: { create: function }, movements: object
38
+ * nip: object, authorization: { create: function }, movements: object, statements: { create: function }
38
39
  * }}
39
40
  */
40
41
  var saldoMax = {
@@ -225,6 +226,39 @@ function externalWalletsFactory(_ref) {
225
226
  data: { movement: movement }
226
227
  });
227
228
  }
229
+ },
230
+ /** @type {{ create: function }} */
231
+ statements: {
232
+ /**
233
+ * POST /external-wallets/saldo-max/:walletId/statements — Saldo Max wallet statements (Inventory → ADO ConsultaSaldoHistorial).
234
+ * Optional `statementRequest`: `sendMail` (ADO may email history), `page` / `limit` (pagination strings per ADO).
235
+ * Response: `statement` plus `count`, `next`, `previous` (Inventory paginated shape).
236
+ * @param {Object} opts
237
+ * @param {string} [opts.token] - API key
238
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
239
+ * @param {string} opts.walletId - Saldo Max wallet id (idWallet)
240
+ * @param {{ sendMail?: boolean, page?: string, limit?: string }} [opts.statementRequest] -
241
+ * optional body (sent as `{ statementRequest }` in JSON)
242
+ * @param {Object} [opts.headers] - Optional headers
243
+ * @returns {Promise<import("axios").AxiosResponse<{
244
+ * statement: Object, count: number, next?: string, previous?: string
245
+ * }>>}
246
+ * @throws When response is 4xx/5xx (400 INVALID_WALLET_ID; 401; 404; 502; 503; 500)
247
+ */
248
+ create: function create(_ref9) {
249
+ var token = _ref9.token,
250
+ jwtToken = _ref9.jwtToken,
251
+ walletId = _ref9.walletId,
252
+ statementRequest = _ref9.statementRequest,
253
+ headers = _ref9.headers;
254
+
255
+ return client({
256
+ url: "/external-wallets/saldo-max/" + walletId + "/statements",
257
+ method: "post",
258
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
259
+ data: statementRequest != null ? { statementRequest: statementRequest } : {}
260
+ });
261
+ }
228
262
  }
229
263
  };
230
264
 
@@ -7,7 +7,7 @@ var _require = require("./../endpoints_helpers.js"),
7
7
  /**
8
8
  * Query params for GET pdf-templates-processing binary routes (btrz-api-notifications). Client uses type/family to resolve path.
9
9
  * @typedef {Object} PdfGetQuery
10
- * @property {string} type - Document type (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, shift, remainderSlip, exchange, invoice, locationClosure, parcelManifest, startingBalance, partialShiftDeposits, shiftLocationClosure, bankDepositSlip, terminalVoucher, manualTickets)
10
+ * @property {string} type - Document type (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, shift, remainderSlip, exchange, invoice, locationClosure, parcelManifest, startingBalance, partialShiftDeposits, shiftLocationClosure, bankDepositSlip, terminalVoucher, manualTickets, externalWalletVoucher)
11
11
  * @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
12
12
  */
13
13
 
@@ -130,6 +130,9 @@ function pdfFactory(_ref) {
130
130
  if (query.type === "manualTickets") {
131
131
  url = "/pdf-manual-tickets/" + itemId;
132
132
  }
133
+ if (query.type === "externalWalletVoucher") {
134
+ url = "/pdf-external-wallet-voucher/" + itemId;
135
+ }
133
136
 
134
137
  return client.get(url, {
135
138
  params: query,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "8.59.0",
3
+ "version": "8.61.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,7 +20,8 @@ const {
20
20
  * @returns {{
21
21
  * saldoMax: {
22
22
  * all: function, get: function, create: function, update: function,
23
- * nip: object, authorization: { create: function }, movements: { create: function }
23
+ * nip: object, authorization: { create: function }, movements: { create: function },
24
+ * statements: { create: function }
24
25
  * }
25
26
  * }}
26
27
  */
@@ -28,7 +29,7 @@ function externalWalletsFactory({client, internalAuthTokenProvider}) {
28
29
  /**
29
30
  * @type {{
30
31
  * all: function, create: function, get: function, update: function,
31
- * nip: object, authorization: { create: function }, movements: object
32
+ * nip: object, authorization: { create: function }, movements: object, statements: { create: function }
32
33
  * }}
33
34
  */
34
35
  const saldoMax = {
@@ -179,6 +180,33 @@ function externalWalletsFactory({client, internalAuthTokenProvider}) {
179
180
  data: {movement}
180
181
  });
181
182
  }
183
+ },
184
+ /** @type {{ create: function }} */
185
+ statements: {
186
+ /**
187
+ * POST /external-wallets/saldo-max/:walletId/statements — Saldo Max wallet statements (Inventory → ADO ConsultaSaldoHistorial).
188
+ * Optional `statementRequest`: `sendMail` (ADO may email history), `page` / `limit` (pagination strings per ADO).
189
+ * Response: `statement` plus `count`, `next`, `previous` (Inventory paginated shape).
190
+ * @param {Object} opts
191
+ * @param {string} [opts.token] - API key
192
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
193
+ * @param {string} opts.walletId - Saldo Max wallet id (idWallet)
194
+ * @param {{ sendMail?: boolean, page?: string, limit?: string }} [opts.statementRequest] -
195
+ * optional body (sent as `{ statementRequest }` in JSON)
196
+ * @param {Object} [opts.headers] - Optional headers
197
+ * @returns {Promise<import("axios").AxiosResponse<{
198
+ * statement: Object, count: number, next?: string, previous?: string
199
+ * }>>}
200
+ * @throws When response is 4xx/5xx (400 INVALID_WALLET_ID; 401; 404; 502; 503; 500)
201
+ */
202
+ create: ({token, jwtToken, walletId, statementRequest, headers}) => {
203
+ return client({
204
+ url: `/external-wallets/saldo-max/${walletId}/statements`,
205
+ method: "post",
206
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
207
+ data: statementRequest != null ? {statementRequest} : {}
208
+ });
209
+ }
182
210
  }
183
211
  };
184
212
 
@@ -6,7 +6,7 @@ const {
6
6
  /**
7
7
  * Query params for GET pdf-templates-processing binary routes (btrz-api-notifications). Client uses type/family to resolve path.
8
8
  * @typedef {Object} PdfGetQuery
9
- * @property {string} type - Document type (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, shift, remainderSlip, exchange, invoice, locationClosure, parcelManifest, startingBalance, partialShiftDeposits, shiftLocationClosure, bankDepositSlip, terminalVoucher, manualTickets)
9
+ * @property {string} type - Document type (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, shift, remainderSlip, exchange, invoice, locationClosure, parcelManifest, startingBalance, partialShiftDeposits, shiftLocationClosure, bankDepositSlip, terminalVoucher, manualTickets, externalWalletVoucher)
10
10
  * @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
11
11
  */
12
12
 
@@ -126,6 +126,9 @@ function pdfFactory({
126
126
  if (query.type === "manualTickets") {
127
127
  url = `/pdf-manual-tickets/${itemId}`;
128
128
  }
129
+ if (query.type === "externalWalletVoucher") {
130
+ url = `/pdf-external-wallet-voucher/${itemId}`;
131
+ }
129
132
 
130
133
  return client.get(url, {
131
134
  params: query,
@@ -188,5 +188,35 @@ describe("inventory/external-wallets", () => {
188
188
  movement
189
189
  });
190
190
  });
191
+
192
+ it("should post wallet statement with statementRequest (e.g. sendMail)", async () => {
193
+ const walletId = "wallet-stmt-1";
194
+ const statementRequest = {sendMail: true};
195
+
196
+ axiosMock.onPost(`/external-wallets/saldo-max/${walletId}/statements`).reply(expectRequest({
197
+ statusCode: 200, token, jwtToken, body: {statementRequest}
198
+ }));
199
+
200
+ return api.inventory.externalWallets.saldoMax.statements.create({
201
+ jwtToken,
202
+ token,
203
+ walletId,
204
+ statementRequest
205
+ });
206
+ });
207
+
208
+ it("should post wallet statement with empty body when statementRequest omitted", async () => {
209
+ const walletId = "wallet-stmt-2";
210
+
211
+ axiosMock.onPost(`/external-wallets/saldo-max/${walletId}/statements`).reply(expectRequest({
212
+ statusCode: 200, token, jwtToken, body: {}
213
+ }));
214
+
215
+ return api.inventory.externalWallets.saldoMax.statements.create({
216
+ jwtToken,
217
+ token,
218
+ walletId
219
+ });
220
+ });
191
221
  });
192
222
  });