btrz-api-client 8.62.0 → 8.64.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.
@@ -10,11 +10,11 @@ var _require = require("../endpoints_helpers.js"),
10
10
  */
11
11
 
12
12
  /**
13
- * Factory for external-customers API (btrz-api-notifications). Saldo Max (ADO) verification-code registration.
13
+ * Factory for external-customers API (btrz-api-notifications). Saldo Max (ADO) verification-code registration and statement email.
14
14
  * @param {Object} deps
15
15
  * @param {import("axios").AxiosInstance} deps.client
16
16
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
17
- * @returns {{ requestSaldoMaxVerificationCode: function }}
17
+ * @returns {{ requestSaldoMaxVerificationCode: function, sendSaldoMaxStatementEmail: function }}
18
18
  */
19
19
 
20
20
 
@@ -46,8 +46,33 @@ function externalCustomersFactory(_ref) {
46
46
  });
47
47
  }
48
48
 
49
+ /**
50
+ * POST /external-customers/ado/external-wallets/:walletId/statements — Request Saldo Max wallet statement email.
51
+ * Notifications proxies to Inventory with sendMail. No query; body is empty JSON.
52
+ * @param {Object} opts
53
+ * @param {string} [opts.token] - API key
54
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
55
+ * @param {string} opts.walletId - Saldo Max wallet id (path segment; encoded in the URL)
56
+ * @param {Object} [opts.headers] - Optional headers
57
+ * @returns {Promise<import("axios").AxiosResponse<{ success: boolean }>>}
58
+ */
59
+ function sendSaldoMaxStatementEmail(_ref3) {
60
+ var token = _ref3.token,
61
+ jwtToken = _ref3.jwtToken,
62
+ walletId = _ref3.walletId,
63
+ headers = _ref3.headers;
64
+
65
+ return client({
66
+ url: "/external-customers/ado/external-wallets/" + encodeURIComponent(walletId) + "/statements",
67
+ method: "post",
68
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
69
+ data: {}
70
+ });
71
+ }
72
+
49
73
  return {
50
- requestSaldoMaxVerificationCode: requestSaldoMaxVerificationCode
74
+ requestSaldoMaxVerificationCode: requestSaldoMaxVerificationCode,
75
+ sendSaldoMaxStatementEmail: sendSaldoMaxStatementEmail
51
76
  };
52
77
  }
53
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "8.62.0",
3
+ "version": "8.64.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "homepage": "https://github.com/Betterez/btrz-api-client#readme",
28
28
  "devDependencies": {
29
- "axios-mock-adapter": "2.1.0",
29
+ "axios-mock-adapter": "1.21.5",
30
30
  "babel-cli": "^6.26.0",
31
31
  "babel-plugin-transform-object-rest-spread": "^6.26.0",
32
32
  "babel-preset-es2015": "^6.24.1",
@@ -44,7 +44,7 @@
44
44
  "uuid": "14.0.0"
45
45
  },
46
46
  "dependencies": {
47
- "axios": "1.15.2",
47
+ "axios": "^0.27.2",
48
48
  "base-64": "^1.0.0",
49
49
  "undici": "^8.1.0"
50
50
  }
@@ -7,11 +7,11 @@ const {authorizationHeaders} = require("../endpoints_helpers.js");
7
7
  */
8
8
 
9
9
  /**
10
- * Factory for external-customers API (btrz-api-notifications). Saldo Max (ADO) verification-code registration.
10
+ * Factory for external-customers API (btrz-api-notifications). Saldo Max (ADO) verification-code registration and statement email.
11
11
  * @param {Object} deps
12
12
  * @param {import("axios").AxiosInstance} deps.client
13
13
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
14
- * @returns {{ requestSaldoMaxVerificationCode: function }}
14
+ * @returns {{ requestSaldoMaxVerificationCode: function, sendSaldoMaxStatementEmail: function }}
15
15
  */
16
16
  function externalCustomersFactory({client, internalAuthTokenProvider}) {
17
17
  /**
@@ -33,8 +33,28 @@ function externalCustomersFactory({client, internalAuthTokenProvider}) {
33
33
  });
34
34
  }
35
35
 
36
+ /**
37
+ * POST /external-customers/ado/external-wallets/:walletId/statements — Request Saldo Max wallet statement email.
38
+ * Notifications proxies to Inventory with sendMail. No query; body is empty JSON.
39
+ * @param {Object} opts
40
+ * @param {string} [opts.token] - API key
41
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
42
+ * @param {string} opts.walletId - Saldo Max wallet id (path segment; encoded in the URL)
43
+ * @param {Object} [opts.headers] - Optional headers
44
+ * @returns {Promise<import("axios").AxiosResponse<{ success: boolean }>>}
45
+ */
46
+ function sendSaldoMaxStatementEmail({token, jwtToken, walletId, headers}) {
47
+ return client({
48
+ url: `/external-customers/ado/external-wallets/${encodeURIComponent(walletId)}/statements`,
49
+ method: "post",
50
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
51
+ data: {}
52
+ });
53
+ }
54
+
36
55
  return {
37
- requestSaldoMaxVerificationCode
56
+ requestSaldoMaxVerificationCode,
57
+ sendSaldoMaxStatementEmail
38
58
  };
39
59
  }
40
60
 
@@ -27,4 +27,35 @@ describe("notifications/external-customers", () => {
27
27
  expect(res.data).to.eql({code: "success", message: "Registration successful"});
28
28
  });
29
29
  });
30
+
31
+ it("should POST Saldo Max statement email (ado/external-wallets/:walletId/statements)", () => {
32
+ const walletId = "15154";
33
+ axiosMock.onPost(`/external-customers/ado/external-wallets/${walletId}/statements`).reply((config) => {
34
+ expect(config.data).to.equal(JSON.stringify({}));
35
+ expect(config.headers["x-api-key"]).to.eql(token);
36
+ expect(config.headers.authorization).to.eql(`Bearer ${jwtToken}`);
37
+ return [200, {success: true}];
38
+ });
39
+
40
+ return api.notifications.externalCustomers.sendSaldoMaxStatementEmail({
41
+ token,
42
+ jwtToken,
43
+ walletId
44
+ }).then((res) => {
45
+ expect(res.data).to.eql({success: true});
46
+ });
47
+ });
48
+
49
+ it("should encode walletId in statement email path", () => {
50
+ const walletId = "id/with chars";
51
+ axiosMock.onPost("/external-customers/ado/external-wallets/id%2Fwith%20chars/statements").reply(200, {success: true});
52
+
53
+ return api.notifications.externalCustomers.sendSaldoMaxStatementEmail({
54
+ token,
55
+ jwtToken,
56
+ walletId
57
+ }).then((res) => {
58
+ expect(res.data.success).to.equal(true);
59
+ });
60
+ });
30
61
  });