btrz-api-client 8.70.0 → 8.71.1

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/lib/client.js CHANGED
@@ -223,6 +223,7 @@ function createAccounts(_ref4) {
223
223
  applications: require("./endpoints/accounts/applications.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
224
224
  applicationSettings: require("./endpoints/accounts/application-settings.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
225
225
  customers: require("./endpoints/accounts/customers.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
226
+ controlClassesSettings: require("./endpoints/accounts/control-classes-settings.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
226
227
  currentShifts: require("./endpoints/accounts/current-shifts.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
227
228
  docs: require("./endpoints/accounts/docs.js")({
228
229
  client: client
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable max-len */
4
+ var _require = require("../endpoints_helpers.js"),
5
+ authorizationHeaders = _require.authorizationHeaders;
6
+
7
+ /**
8
+ * Factory for control-classes-settings API (btrz-api-accounts).
9
+ * @param {Object} deps
10
+ * @param {import("axios").AxiosInstance} deps.client
11
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
12
+ * @returns {{ get: function, put: function }}
13
+ */
14
+
15
+
16
+ function controlClassesSettingsFactory(_ref) {
17
+ var client = _ref.client,
18
+ internalAuthTokenProvider = _ref.internalAuthTokenProvider;
19
+
20
+ /**
21
+ * GET /control-classes-settings — get control classes settings for the account. No query parameters.
22
+ * @param {Object} opts
23
+ * @param {string} [opts.token] - API key (X-API-KEY)
24
+ * @param {string} [opts.jwtToken] - JWT or internal auth token
25
+ * @param {Object} [opts.headers] - Optional request headers
26
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClassesSettings: { namingPolicy: string, childSelectionCriteriaDefault: string } }>>}
27
+ * @throws {import("axios").AxiosError} 401 Unauthorized (missing or invalid API key/Authorization)
28
+ * @throws {import("axios").AxiosError} 500 Internal server error
29
+ */
30
+ function get(_ref2) {
31
+ var token = _ref2.token,
32
+ jwtToken = _ref2.jwtToken,
33
+ headers = _ref2.headers;
34
+
35
+ return client({
36
+ url: "/control-classes-settings",
37
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
38
+ });
39
+ }
40
+
41
+ /**
42
+ * PUT /control-classes-settings — update control classes settings. At least one of namingPolicy or childSelectionCriteriaDefault must be provided.
43
+ * @param {Object} opts
44
+ * @param {string} [opts.token] - API key (X-API-KEY)
45
+ * @param {string} [opts.jwtToken] - JWT or internal auth token
46
+ * @param {{ namingPolicy?: string, childSelectionCriteriaDefault?: string }} opts.controlClassesSettings - Settings payload
47
+ * @param {Object} [opts.headers] - Optional request headers
48
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClassesSettings: { namingPolicy: string, childSelectionCriteriaDefault: string } }>>}
49
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA, ALLOW_DUPLICATES_NOT_ALLOWED_WITH_SALES_AUTHORIZATIONS_AVAILABILITY
50
+ * @throws {import("axios").AxiosError} 401 Unauthorized
51
+ * @throws {import("axios").AxiosError} 404 ACCOUNT_NOT_FOUND
52
+ * @throws {import("axios").AxiosError} 500 Internal server error
53
+ */
54
+ function put(_ref3) {
55
+ var token = _ref3.token,
56
+ jwtToken = _ref3.jwtToken,
57
+ controlClassesSettings = _ref3.controlClassesSettings,
58
+ headers = _ref3.headers;
59
+
60
+ return client({
61
+ url: "/control-classes-settings",
62
+ method: "put",
63
+ headers: authorizationHeaders({
64
+ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers
65
+ }),
66
+ data: controlClassesSettings
67
+ });
68
+ }
69
+
70
+ return {
71
+ get: get,
72
+ put: put
73
+ };
74
+ }
75
+
76
+ module.exports = controlClassesSettingsFactory;
@@ -42,6 +42,30 @@ function externalCustomersFactory(_ref) {
42
42
  });
43
43
  }
44
44
 
45
+ /**
46
+ * POST /external-customers/ado/confirmation – Confirm a Saldo Max Profile V2 quick registration OTP.
47
+ * Requires BETTEREZ_APP JWT.
48
+ * @param {Object} opts
49
+ * @param {string} [opts.token] - API key
50
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
51
+ * @param {{confirmationToken: string, confirmationCode: string}} opts.data - Confirmation token and OTP code
52
+ * @param {Object} [opts.headers] - Optional headers
53
+ * @returns {Promise<import("axios").AxiosResponse<{ code: string, userId?: string, isConfirmed?: boolean, message?: string }>>}
54
+ */
55
+ function confirmSaldoMaxRegistration(_ref3) {
56
+ var data = _ref3.data,
57
+ token = _ref3.token,
58
+ jwtToken = _ref3.jwtToken,
59
+ headers = _ref3.headers;
60
+
61
+ return client({
62
+ url: "/external-customers/ado/confirmation",
63
+ method: "post",
64
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
65
+ data: data
66
+ });
67
+ }
68
+
45
69
  var saldoMax = {
46
70
  /**
47
71
  * GET /external-customers/ado - get SaldoMax user by email, phone or walletId.
@@ -60,18 +84,21 @@ function externalCustomersFactory(_ref) {
60
84
  * @returns {Promise<import("axios").AxiosResponse<{ adoUsers: Array<Object> }>>}
61
85
  * @throws When response is 4xx/5xx (400, 401, 404 EXTERNAL_WALLET_NOT_FOUND, 500)
62
86
  */
63
- get: function get(_ref3) {
64
- var token = _ref3.token,
65
- jwtToken = _ref3.jwtToken,
66
- query = _ref3.query,
67
- headers = _ref3.headers;
87
+ get: function get(_ref4) {
88
+ var token = _ref4.token,
89
+ jwtToken = _ref4.jwtToken,
90
+ query = _ref4.query,
91
+ headers = _ref4.headers;
68
92
 
69
93
  return client.get("/external-customers/ado", {
70
94
  params: query,
71
95
  headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
72
96
  });
73
97
  },
74
- create: registerSaldoMax
98
+ create: registerSaldoMax,
99
+ confirmation: {
100
+ create: confirmSaldoMaxRegistration
101
+ }
75
102
  };
76
103
 
77
104
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "8.70.0",
3
+ "version": "8.71.1",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -189,6 +189,7 @@ function createAccounts({baseURL, headers, timeout, overrideFn, internalAuthToke
189
189
  applications: require("./endpoints/accounts/applications.js")({client, internalAuthTokenProvider}),
190
190
  applicationSettings: require("./endpoints/accounts/application-settings.js")({client, internalAuthTokenProvider}),
191
191
  customers: require("./endpoints/accounts/customers.js")({client, internalAuthTokenProvider}),
192
+ controlClassesSettings: require("./endpoints/accounts/control-classes-settings.js")({client, internalAuthTokenProvider}),
192
193
  currentShifts: require("./endpoints/accounts/current-shifts.js")({client, internalAuthTokenProvider}),
193
194
  docs: require("./endpoints/accounts/docs.js")({
194
195
  client
@@ -0,0 +1,61 @@
1
+ /* eslint-disable max-len */
2
+ const {
3
+ authorizationHeaders
4
+ } = require("../endpoints_helpers.js");
5
+
6
+ /**
7
+ * Factory for control-classes-settings API (btrz-api-accounts).
8
+ * @param {Object} deps
9
+ * @param {import("axios").AxiosInstance} deps.client
10
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
11
+ * @returns {{ get: function, put: function }}
12
+ */
13
+ function controlClassesSettingsFactory({client, internalAuthTokenProvider}) {
14
+ /**
15
+ * GET /control-classes-settings — get control classes settings for the account. No query parameters.
16
+ * @param {Object} opts
17
+ * @param {string} [opts.token] - API key (X-API-KEY)
18
+ * @param {string} [opts.jwtToken] - JWT or internal auth token
19
+ * @param {Object} [opts.headers] - Optional request headers
20
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClassesSettings: { namingPolicy: string, childSelectionCriteriaDefault: string } }>>}
21
+ * @throws {import("axios").AxiosError} 401 Unauthorized (missing or invalid API key/Authorization)
22
+ * @throws {import("axios").AxiosError} 500 Internal server error
23
+ */
24
+ function get({token, jwtToken, headers}) {
25
+ return client({
26
+ url: "/control-classes-settings",
27
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
28
+ });
29
+ }
30
+
31
+ /**
32
+ * PUT /control-classes-settings — update control classes settings. At least one of namingPolicy or childSelectionCriteriaDefault must be provided.
33
+ * @param {Object} opts
34
+ * @param {string} [opts.token] - API key (X-API-KEY)
35
+ * @param {string} [opts.jwtToken] - JWT or internal auth token
36
+ * @param {{ namingPolicy?: string, childSelectionCriteriaDefault?: string }} opts.controlClassesSettings - Settings payload
37
+ * @param {Object} [opts.headers] - Optional request headers
38
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClassesSettings: { namingPolicy: string, childSelectionCriteriaDefault: string } }>>}
39
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA, ALLOW_DUPLICATES_NOT_ALLOWED_WITH_SALES_AUTHORIZATIONS_AVAILABILITY
40
+ * @throws {import("axios").AxiosError} 401 Unauthorized
41
+ * @throws {import("axios").AxiosError} 404 ACCOUNT_NOT_FOUND
42
+ * @throws {import("axios").AxiosError} 500 Internal server error
43
+ */
44
+ function put({token, jwtToken, controlClassesSettings, headers}) {
45
+ return client({
46
+ url: "/control-classes-settings",
47
+ method: "put",
48
+ headers: authorizationHeaders({
49
+ token, jwtToken, internalAuthTokenProvider, headers
50
+ }),
51
+ data: controlClassesSettings
52
+ });
53
+ }
54
+
55
+ return {
56
+ get,
57
+ put
58
+ };
59
+ }
60
+
61
+ module.exports = controlClassesSettingsFactory;
@@ -29,6 +29,25 @@ function externalCustomersFactory({client, internalAuthTokenProvider}) {
29
29
  });
30
30
  }
31
31
 
32
+ /**
33
+ * POST /external-customers/ado/confirmation – Confirm a Saldo Max Profile V2 quick registration OTP.
34
+ * Requires BETTEREZ_APP JWT.
35
+ * @param {Object} opts
36
+ * @param {string} [opts.token] - API key
37
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
38
+ * @param {{confirmationToken: string, confirmationCode: string}} opts.data - Confirmation token and OTP code
39
+ * @param {Object} [opts.headers] - Optional headers
40
+ * @returns {Promise<import("axios").AxiosResponse<{ code: string, userId?: string, isConfirmed?: boolean, message?: string }>>}
41
+ */
42
+ function confirmSaldoMaxRegistration({data, token, jwtToken, headers}) {
43
+ return client({
44
+ url: "/external-customers/ado/confirmation",
45
+ method: "post",
46
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
47
+ data
48
+ });
49
+ }
50
+
32
51
  const saldoMax = {
33
52
  /**
34
53
  * GET /external-customers/ado - get SaldoMax user by email, phone or walletId.
@@ -53,7 +72,10 @@ function externalCustomersFactory({client, internalAuthTokenProvider}) {
53
72
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
54
73
  });
55
74
  },
56
- create: registerSaldoMax
75
+ create: registerSaldoMax,
76
+ confirmation: {
77
+ create: confirmSaldoMaxRegistration
78
+ }
57
79
  };
58
80
 
59
81
  return {
@@ -0,0 +1,36 @@
1
+ const {axiosMock, expectRequest} = require("../../test-helpers.js");
2
+ const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
+
4
+ describe("accounts/control-classes-settings", () => {
5
+ const token = "I owe you a token";
6
+ const jwtToken = "secret";
7
+
8
+ afterEach(() => {
9
+ axiosMock.reset();
10
+ });
11
+
12
+ it("should get the control classes settings", () => {
13
+ axiosMock.onGet("/control-classes-settings")
14
+ .reply(expectRequest({statusCode: 200, token}));
15
+
16
+ return api.accounts.controlClassesSettings.get({token, jwtToken});
17
+ });
18
+
19
+ it("should update control classes settings", () => {
20
+ const controlClassesSettings = {
21
+ namingPolicy: "UNIQUE_BY_ACCOUNT",
22
+ childSelectionCriteriaDefault: "MOST_SPECIFIC"
23
+ };
24
+
25
+ axiosMock.onPut("/control-classes-settings")
26
+ .reply(expectRequest({
27
+ statusCode: 200,
28
+ token,
29
+ jwtToken
30
+ }));
31
+
32
+ return api.accounts.controlClassesSettings.put({
33
+ token, jwtToken, controlClassesSettings
34
+ });
35
+ });
36
+ });
@@ -59,4 +59,22 @@ describe("accounts/external-customers", () => {
59
59
  data
60
60
  });
61
61
  });
62
+
63
+ it("should POST Saldo Max Profile V2 registration confirmation", () => {
64
+ const data = {
65
+ confirmationToken: "confirmation-token",
66
+ confirmationCode: "123456"
67
+ };
68
+ axiosMock.onPost("/external-customers/ado/confirmation").reply(expectRequest({
69
+ statusCode: 200,
70
+ token,
71
+ jwtToken,
72
+ body: data
73
+ }));
74
+ return api.accounts.externalCustomers.saldoMax.confirmation.create({
75
+ token,
76
+ jwtToken,
77
+ data
78
+ });
79
+ });
62
80
  });
@@ -0,0 +1,17 @@
1
+ export = controlClassesSettingsFactory;
2
+ /**
3
+ * Factory for control-classes-settings API (btrz-api-accounts).
4
+ * @param {Object} deps
5
+ * @param {import("axios").AxiosInstance} deps.client
6
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
7
+ * @returns {{ get: function, put: function }}
8
+ */
9
+ declare function controlClassesSettingsFactory({ client, internalAuthTokenProvider }: {
10
+ client: import("axios").AxiosInstance;
11
+ internalAuthTokenProvider?: {
12
+ getToken: () => string;
13
+ };
14
+ }): {
15
+ get: Function;
16
+ put: Function;
17
+ };