btrz-api-client 9.11.0 → 9.13.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/lib/client.js CHANGED
@@ -536,6 +536,10 @@ function createAccounts({
536
536
  client,
537
537
  internalAuthTokenProvider
538
538
  }),
539
+ qrMappings: require("./endpoints/accounts/qr-mappings.js")({
540
+ client,
541
+ internalAuthTokenProvider
542
+ }),
539
543
  emailSettings: require("./endpoints/accounts/email-settings.js")({
540
544
  client,
541
545
  internalAuthTokenProvider
@@ -101,6 +101,37 @@ function externalCustomersFactory({
101
101
  data
102
102
  });
103
103
  }
104
+
105
+ /**
106
+ * PUT /external-customers/ado/{externalId} – Update Saldo Max (ADO) client data (e.g. birthDate).
107
+ * Requires BETTEREZ_APP JWT. Maps to ADO ModificarDatosClienteMonedero.
108
+ * @param {Object} opts
109
+ * @param {string} opts.id - ADO idCustomerUnique (path externalId)
110
+ * @param {string} [opts.token] - API key
111
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
112
+ * @param {{birthDate: string}} opts.data - Body; birthDate in DD/MM/YYYY
113
+ * @param {Object} [opts.headers] - Optional headers
114
+ * @returns {Promise<import("axios").AxiosResponse<{ code: string, externalId: string, birthDate: string }>>}
115
+ */
116
+ function updateSaldoMaxClientData({
117
+ id,
118
+ data,
119
+ token,
120
+ jwtToken,
121
+ headers
122
+ }) {
123
+ return client({
124
+ url: `/external-customers/ado/${encodeURIComponent(id)}`,
125
+ method: "put",
126
+ headers: authorizationHeaders({
127
+ token,
128
+ jwtToken,
129
+ internalAuthTokenProvider,
130
+ headers
131
+ }),
132
+ data
133
+ });
134
+ }
104
135
  const saldoMax = {
105
136
  /**
106
137
  * GET /external-customers/ado - get SaldoMax user by email, phone or walletId.
@@ -136,6 +167,7 @@ function externalCustomersFactory({
136
167
  });
137
168
  },
138
169
  create: registerSaldoMax,
170
+ update: updateSaldoMaxClientData,
139
171
  confirmation: {
140
172
  create: confirmSaldoMaxRegistration,
141
173
  resend: {
@@ -0,0 +1,167 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("../endpoints_helpers.js");
4
+
5
+ /**
6
+ * Query params for GET /qr-mappings (btrz-api-accounts). See get-handler getSpec().
7
+ * @typedef {Object} QrMappingsListQuery
8
+ * @property {number} [page] - 1-based page for pagination
9
+ */
10
+
11
+ /**
12
+ * Factory for qr-mappings API (btrz-api-accounts).
13
+ * @param {Object} deps
14
+ * @param {import("axios").AxiosInstance} deps.client
15
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
16
+ * @returns {{ get: function, all: function, create: function, update: function, remove: function }}
17
+ */
18
+ function qrMappingsFactory({
19
+ client,
20
+ internalAuthTokenProvider
21
+ }) {
22
+ /**
23
+ * GET /qr-mappings/:qrMappingId - get a QR mapping.
24
+ * @param {Object} opts
25
+ * @param {string} [opts.token] - API key
26
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
27
+ * @param {string} opts.qrMappingId - QR mapping id (ObjectId)
28
+ * @param {Object} [opts.headers] - Optional headers
29
+ * @returns {Promise<import("axios").AxiosResponse>}
30
+ */
31
+ function get({
32
+ token,
33
+ jwtToken,
34
+ qrMappingId,
35
+ headers
36
+ }) {
37
+ return client({
38
+ url: `/qr-mappings/${qrMappingId}`,
39
+ headers: authorizationHeaders({
40
+ token,
41
+ jwtToken,
42
+ internalAuthTokenProvider,
43
+ headers
44
+ })
45
+ });
46
+ }
47
+
48
+ /**
49
+ * GET /qr-mappings - list QR mappings (paginated when page is provided).
50
+ * @param {Object} opts
51
+ * @param {string} [opts.token] - API key
52
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
53
+ * @param {QrMappingsListQuery} [opts.query] - Query params (page)
54
+ * @param {Object} [opts.headers] - Optional headers
55
+ * @returns {Promise<import("axios").AxiosResponse>}
56
+ */
57
+ function all({
58
+ token,
59
+ jwtToken,
60
+ query = {},
61
+ headers
62
+ }) {
63
+ return client({
64
+ url: "/qr-mappings",
65
+ params: query,
66
+ headers: authorizationHeaders({
67
+ token,
68
+ jwtToken,
69
+ internalAuthTokenProvider,
70
+ headers
71
+ })
72
+ });
73
+ }
74
+
75
+ /**
76
+ * POST /qr-mappings - create a QR mapping.
77
+ * @param {Object} opts
78
+ * @param {string} [opts.token] - API key
79
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
80
+ * @param {Object} opts.data - QR mapping payload
81
+ * @param {Object} [opts.headers] - Optional headers
82
+ * @returns {Promise<import("axios").AxiosResponse>}
83
+ */
84
+ function create({
85
+ token,
86
+ jwtToken,
87
+ data,
88
+ headers
89
+ }) {
90
+ return client({
91
+ url: "/qr-mappings",
92
+ method: "post",
93
+ headers: authorizationHeaders({
94
+ token,
95
+ jwtToken,
96
+ internalAuthTokenProvider,
97
+ headers
98
+ }),
99
+ data
100
+ });
101
+ }
102
+
103
+ /**
104
+ * PUT /qr-mappings/:qrMappingId - update a QR mapping.
105
+ * @param {Object} opts
106
+ * @param {string} [opts.token] - API key
107
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
108
+ * @param {string} opts.qrMappingId - QR mapping id (ObjectId)
109
+ * @param {Object} opts.data - QR mapping payload
110
+ * @param {Object} [opts.headers] - Optional headers
111
+ * @returns {Promise<import("axios").AxiosResponse>}
112
+ */
113
+ function update({
114
+ token,
115
+ jwtToken,
116
+ qrMappingId,
117
+ data,
118
+ headers
119
+ }) {
120
+ return client({
121
+ url: `/qr-mappings/${qrMappingId}`,
122
+ method: "put",
123
+ headers: authorizationHeaders({
124
+ token,
125
+ jwtToken,
126
+ internalAuthTokenProvider,
127
+ headers
128
+ }),
129
+ data
130
+ });
131
+ }
132
+
133
+ /**
134
+ * DELETE /qr-mappings/:qrMappingId - delete a QR mapping.
135
+ * @param {Object} opts
136
+ * @param {string} [opts.token] - API key
137
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
138
+ * @param {string} opts.qrMappingId - QR mapping id (ObjectId)
139
+ * @param {Object} [opts.headers] - Optional headers
140
+ * @returns {Promise<import("axios").AxiosResponse>}
141
+ */
142
+ function remove({
143
+ qrMappingId,
144
+ token,
145
+ jwtToken,
146
+ headers
147
+ }) {
148
+ return client({
149
+ url: `/qr-mappings/${qrMappingId}`,
150
+ method: "delete",
151
+ headers: authorizationHeaders({
152
+ token,
153
+ jwtToken,
154
+ internalAuthTokenProvider,
155
+ headers
156
+ })
157
+ });
158
+ }
159
+ return {
160
+ get,
161
+ all,
162
+ create,
163
+ update,
164
+ remove
165
+ };
166
+ }
167
+ module.exports = qrMappingsFactory;
@@ -18,8 +18,6 @@ const {
18
18
  * @property {string} [seatClassId] - Filter by seat class ID(s), comma-separated
19
19
  * @property {string} [operatingCompanyId] - Filter by operating company ID(s), comma-separated
20
20
  * @property {string} [channel] - Filter by channel(s), comma-separated
21
- * @property {number} [advancePurchaseFrom] - Filter by advance purchase from (hours)
22
- * @property {number} [advancePurchaseTo] - Filter by advance purchase to (hours)
23
21
  */
24
22
 
25
23
  /**
@@ -3,6 +3,33 @@ const {
3
3
  authorizationHeaders
4
4
  } = require("./../endpoints_helpers.js");
5
5
 
6
+ /**
7
+ * @typedef {Object} MoveSegmentDemandEntry
8
+ * @property {string} fromId - Station ObjectId for the moved ticket origin
9
+ * @property {string} toId - Station ObjectId for the moved ticket destination
10
+ * @property {string} [fareId] - Optional fare ObjectId
11
+ * @property {number} [sitting] - Sitting passengers for this segment (default 0)
12
+ * @property {number} [standing] - Standing passengers for this segment (default 0)
13
+ */
14
+
15
+ /**
16
+ * @typedef {Object} TripsSearchQuery
17
+ * @property {string} productId
18
+ * @property {string} originId
19
+ * @property {string} destinationId
20
+ * @property {string} fareIds - Format fareId:qty,fareId:qty
21
+ * @property {string} departureDate - YYYY-MM-DD
22
+ * @property {string} [returnDate] - YYYY-MM-DD
23
+ * @property {string} [channel]
24
+ * @property {string} [currency]
25
+ * @property {boolean|string} [isMove] - When true, includes dispatched trips and allows moveSegmentDemand
26
+ * @property {string} [moveSegmentDemand] - JSON stringified MoveSegmentDemandEntry[] used for IROPS/bulk-move segment-aware capacity (requires isMove=true)
27
+ * @property {boolean|string} [ignoreCutoffs]
28
+ * @property {boolean|string} [ignorePerFareCapacityLimits]
29
+ * @property {string} [allowedManifestStatuses]
30
+ * @property {boolean|string} [includeMoveToTrips]
31
+ */
32
+
6
33
  /**
7
34
  * Factory for trips API (btrz-api-inventory-trips).
8
35
  * @param {Object} deps
@@ -19,10 +46,10 @@ function tripsFactory({
19
46
  * @param {Object} opts
20
47
  * @param {string} [opts.token] - API key (X-API-KEY)
21
48
  * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
22
- * @param {Object} [opts.query] - Query params (productId, originId, destinationId, fareIds, departureDate, returnDate, etc.)
49
+ * @param {TripsSearchQuery} [opts.query] - Query params for trip search
23
50
  * @param {Object} [opts.headers] - Optional headers
24
51
  * @returns {Promise<import("axios").AxiosResponse<{ trips: { departures: Object[], returns: Object[] } }>>}
25
- * @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, WRONG_DATA
52
+ * @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, INVALID_MOVE_SEGMENT_DEMAND, WRONG_DATA
26
53
  * @throws 401 Unauthorized
27
54
  * @throws 409 NO_HIGHER_OR_EQL_PRICE
28
55
  * @throws 500 Internal server error
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "9.11.0",
3
+ "version": "9.13.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -200,6 +200,7 @@ function createAccounts({baseURL, headers, timeout, overrideFn, internalAuthToke
200
200
  }),
201
201
  domains: require("./endpoints/accounts/domains.js")({client, internalAuthTokenProvider}),
202
202
  dynamicForms: require("./endpoints/accounts/dynamic-forms.js")({client, internalAuthTokenProvider}),
203
+ qrMappings: require("./endpoints/accounts/qr-mappings.js")({client, internalAuthTokenProvider}),
203
204
  emailSettings: require("./endpoints/accounts/email-settings.js")({client, internalAuthTokenProvider}),
204
205
  emailTemplates: require("./endpoints/accounts/email-templates.js")({client, internalAuthTokenProvider}),
205
206
  smsTemplates: require("./endpoints/accounts/sms-templates.js")({client, internalAuthTokenProvider}),
@@ -67,6 +67,26 @@ function externalCustomersFactory({client, internalAuthTokenProvider}) {
67
67
  });
68
68
  }
69
69
 
70
+ /**
71
+ * PUT /external-customers/ado/{externalId} – Update Saldo Max (ADO) client data (e.g. birthDate).
72
+ * Requires BETTEREZ_APP JWT. Maps to ADO ModificarDatosClienteMonedero.
73
+ * @param {Object} opts
74
+ * @param {string} opts.id - ADO idCustomerUnique (path externalId)
75
+ * @param {string} [opts.token] - API key
76
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
77
+ * @param {{birthDate: string}} opts.data - Body; birthDate in DD/MM/YYYY
78
+ * @param {Object} [opts.headers] - Optional headers
79
+ * @returns {Promise<import("axios").AxiosResponse<{ code: string, externalId: string, birthDate: string }>>}
80
+ */
81
+ function updateSaldoMaxClientData({id, data, token, jwtToken, headers}) {
82
+ return client({
83
+ url: `/external-customers/ado/${encodeURIComponent(id)}`,
84
+ method: "put",
85
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
86
+ data
87
+ });
88
+ }
89
+
70
90
  const saldoMax = {
71
91
  /**
72
92
  * GET /external-customers/ado - get SaldoMax user by email, phone or walletId.
@@ -92,6 +112,7 @@ function externalCustomersFactory({client, internalAuthTokenProvider}) {
92
112
  });
93
113
  },
94
114
  create: registerSaldoMax,
115
+ update: updateSaldoMaxClientData,
95
116
  confirmation: {
96
117
  create: confirmSaldoMaxRegistration,
97
118
  resend: {
@@ -0,0 +1,107 @@
1
+ const {authorizationHeaders} = require("../endpoints_helpers.js");
2
+
3
+ /**
4
+ * Query params for GET /qr-mappings (btrz-api-accounts). See get-handler getSpec().
5
+ * @typedef {Object} QrMappingsListQuery
6
+ * @property {number} [page] - 1-based page for pagination
7
+ */
8
+
9
+ /**
10
+ * Factory for qr-mappings API (btrz-api-accounts).
11
+ * @param {Object} deps
12
+ * @param {import("axios").AxiosInstance} deps.client
13
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
14
+ * @returns {{ get: function, all: function, create: function, update: function, remove: function }}
15
+ */
16
+ function qrMappingsFactory({client, internalAuthTokenProvider}) {
17
+ /**
18
+ * GET /qr-mappings/:qrMappingId - get a QR mapping.
19
+ * @param {Object} opts
20
+ * @param {string} [opts.token] - API key
21
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
22
+ * @param {string} opts.qrMappingId - QR mapping id (ObjectId)
23
+ * @param {Object} [opts.headers] - Optional headers
24
+ * @returns {Promise<import("axios").AxiosResponse>}
25
+ */
26
+ function get({token, jwtToken, qrMappingId, headers}) {
27
+ return client({
28
+ url: `/qr-mappings/${qrMappingId}`,
29
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
30
+ });
31
+ }
32
+
33
+ /**
34
+ * GET /qr-mappings - list QR mappings (paginated when page is provided).
35
+ * @param {Object} opts
36
+ * @param {string} [opts.token] - API key
37
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
38
+ * @param {QrMappingsListQuery} [opts.query] - Query params (page)
39
+ * @param {Object} [opts.headers] - Optional headers
40
+ * @returns {Promise<import("axios").AxiosResponse>}
41
+ */
42
+ function all({token, jwtToken, query = {}, headers}) {
43
+ return client({
44
+ url: "/qr-mappings",
45
+ params: query,
46
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
47
+ });
48
+ }
49
+
50
+ /**
51
+ * POST /qr-mappings - create a QR mapping.
52
+ * @param {Object} opts
53
+ * @param {string} [opts.token] - API key
54
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
55
+ * @param {Object} opts.data - QR mapping payload
56
+ * @param {Object} [opts.headers] - Optional headers
57
+ * @returns {Promise<import("axios").AxiosResponse>}
58
+ */
59
+ function create({token, jwtToken, data, headers}) {
60
+ return client({
61
+ url: "/qr-mappings",
62
+ method: "post",
63
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
64
+ data
65
+ });
66
+ }
67
+
68
+ /**
69
+ * PUT /qr-mappings/:qrMappingId - update a QR mapping.
70
+ * @param {Object} opts
71
+ * @param {string} [opts.token] - API key
72
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
73
+ * @param {string} opts.qrMappingId - QR mapping id (ObjectId)
74
+ * @param {Object} opts.data - QR mapping payload
75
+ * @param {Object} [opts.headers] - Optional headers
76
+ * @returns {Promise<import("axios").AxiosResponse>}
77
+ */
78
+ function update({token, jwtToken, qrMappingId, data, headers}) {
79
+ return client({
80
+ url: `/qr-mappings/${qrMappingId}`,
81
+ method: "put",
82
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
83
+ data
84
+ });
85
+ }
86
+
87
+ /**
88
+ * DELETE /qr-mappings/:qrMappingId - delete a QR mapping.
89
+ * @param {Object} opts
90
+ * @param {string} [opts.token] - API key
91
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
92
+ * @param {string} opts.qrMappingId - QR mapping id (ObjectId)
93
+ * @param {Object} [opts.headers] - Optional headers
94
+ * @returns {Promise<import("axios").AxiosResponse>}
95
+ */
96
+ function remove({qrMappingId, token, jwtToken, headers}) {
97
+ return client({
98
+ url: `/qr-mappings/${qrMappingId}`,
99
+ method: "delete",
100
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
101
+ });
102
+ }
103
+
104
+ return {get, all, create, update, remove};
105
+ }
106
+
107
+ module.exports = qrMappingsFactory;
@@ -18,8 +18,6 @@ const {
18
18
  * @property {string} [seatClassId] - Filter by seat class ID(s), comma-separated
19
19
  * @property {string} [operatingCompanyId] - Filter by operating company ID(s), comma-separated
20
20
  * @property {string} [channel] - Filter by channel(s), comma-separated
21
- * @property {number} [advancePurchaseFrom] - Filter by advance purchase from (hours)
22
- * @property {number} [advancePurchaseTo] - Filter by advance purchase to (hours)
23
21
  */
24
22
 
25
23
  /**
@@ -1,6 +1,33 @@
1
1
  /* eslint-disable max-len */
2
2
  const {authorizationHeaders} = require("./../endpoints_helpers.js");
3
3
 
4
+ /**
5
+ * @typedef {Object} MoveSegmentDemandEntry
6
+ * @property {string} fromId - Station ObjectId for the moved ticket origin
7
+ * @property {string} toId - Station ObjectId for the moved ticket destination
8
+ * @property {string} [fareId] - Optional fare ObjectId
9
+ * @property {number} [sitting] - Sitting passengers for this segment (default 0)
10
+ * @property {number} [standing] - Standing passengers for this segment (default 0)
11
+ */
12
+
13
+ /**
14
+ * @typedef {Object} TripsSearchQuery
15
+ * @property {string} productId
16
+ * @property {string} originId
17
+ * @property {string} destinationId
18
+ * @property {string} fareIds - Format fareId:qty,fareId:qty
19
+ * @property {string} departureDate - YYYY-MM-DD
20
+ * @property {string} [returnDate] - YYYY-MM-DD
21
+ * @property {string} [channel]
22
+ * @property {string} [currency]
23
+ * @property {boolean|string} [isMove] - When true, includes dispatched trips and allows moveSegmentDemand
24
+ * @property {string} [moveSegmentDemand] - JSON stringified MoveSegmentDemandEntry[] used for IROPS/bulk-move segment-aware capacity (requires isMove=true)
25
+ * @property {boolean|string} [ignoreCutoffs]
26
+ * @property {boolean|string} [ignorePerFareCapacityLimits]
27
+ * @property {string} [allowedManifestStatuses]
28
+ * @property {boolean|string} [includeMoveToTrips]
29
+ */
30
+
4
31
  /**
5
32
  * Factory for trips API (btrz-api-inventory-trips).
6
33
  * @param {Object} deps
@@ -14,10 +41,10 @@ function tripsFactory({client, internalAuthTokenProvider}) {
14
41
  * @param {Object} opts
15
42
  * @param {string} [opts.token] - API key (X-API-KEY)
16
43
  * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
17
- * @param {Object} [opts.query] - Query params (productId, originId, destinationId, fareIds, departureDate, returnDate, etc.)
44
+ * @param {TripsSearchQuery} [opts.query] - Query params for trip search
18
45
  * @param {Object} [opts.headers] - Optional headers
19
46
  * @returns {Promise<import("axios").AxiosResponse<{ trips: { departures: Object[], returns: Object[] } }>>}
20
- * @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, WRONG_DATA
47
+ * @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, INVALID_MOVE_SEGMENT_DEMAND, WRONG_DATA
21
48
  * @throws 401 Unauthorized
22
49
  * @throws 409 NO_HIGHER_OR_EQL_PRICE
23
50
  * @throws 500 Internal server error
package/test/all.test.js CHANGED
@@ -10,6 +10,7 @@ require("./endpoints/accounts/current-shifts.test.js");
10
10
  require("./endpoints/accounts/customers.js");
11
11
  require("./endpoints/accounts/domains.test.js");
12
12
  require("./endpoints/accounts/dynamic-forms.test.js");
13
+ require("./endpoints/accounts/qr-mappings.test.js");
13
14
  require("./endpoints/accounts/email-templates.test.js");
14
15
  require("./endpoints/accounts/exchange-rates.test.js");
15
16
  require("./endpoints/accounts/exchange-receipts.test.js");
@@ -94,4 +94,23 @@ describe("accounts/external-customers", () => {
94
94
  data
95
95
  });
96
96
  });
97
+
98
+ it("should PUT Saldo Max client data (birthDate) on external-customers/ado/{externalId}", () => {
99
+ const externalId = "01-1224-000001988";
100
+ const data = {
101
+ birthDate: "15/06/1990"
102
+ };
103
+ axiosMock.onPut(`/external-customers/ado/${encodeURIComponent(externalId)}`).reply(expectRequest({
104
+ statusCode: 200,
105
+ token,
106
+ jwtToken,
107
+ body: data
108
+ }));
109
+ return api.accounts.externalCustomers.saldoMax.update({
110
+ token,
111
+ jwtToken,
112
+ id: externalId,
113
+ data
114
+ });
115
+ });
97
116
  });
@@ -0,0 +1,73 @@
1
+ const {axiosMock, expectRequest} = require("../../test-helpers.js");
2
+ const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
+
4
+ describe("accounts/qr-mappings/", () => {
5
+ const token = "someToken";
6
+ const jwtToken = "I owe you a JWT token";
7
+
8
+ afterEach(() => {
9
+ axiosMock.restore();
10
+ });
11
+
12
+ it("should GET a list of qr mappings", () => {
13
+ axiosMock.onGet("/qr-mappings").reply(expectRequest({
14
+ statusCode: 200,
15
+ token
16
+ }));
17
+ return api.accounts.qrMappings.all({
18
+ token
19
+ });
20
+ });
21
+
22
+ it("should GET a list of qr mappings with page query", () => {
23
+ const query = {page: 2};
24
+ axiosMock.onGet("/qr-mappings").reply(expectRequest({
25
+ statusCode: 200,
26
+ token,
27
+ query
28
+ }));
29
+ return api.accounts.qrMappings.all({
30
+ token,
31
+ query
32
+ });
33
+ });
34
+
35
+ it("should GET the qr mapping", () => {
36
+ const qrMappingId = "123";
37
+ axiosMock.onGet(`/qr-mappings/${qrMappingId}`)
38
+ .reply(expectRequest({statusCode: 200, token}));
39
+ return api.accounts.qrMappings.get({token, jwtToken, qrMappingId});
40
+ });
41
+
42
+ it("should create qr mapping", () => {
43
+ const data = {name: "mapping", separator: "|", segments: []};
44
+ axiosMock.onPost("/qr-mappings").reply(expectRequest({statusCode: 200, token, jwtToken, body: data}));
45
+ return api.accounts.qrMappings.create({
46
+ jwtToken,
47
+ token,
48
+ data
49
+ });
50
+ });
51
+
52
+ it("should update qr mapping", () => {
53
+ const qrMappingId = "123";
54
+ const data = {name: "updated", separator: "-", segments: []};
55
+ axiosMock.onPut(`/qr-mappings/${qrMappingId}`).reply(expectRequest({statusCode: 200, token, jwtToken, body: data}));
56
+ return api.accounts.qrMappings.update({
57
+ jwtToken,
58
+ qrMappingId,
59
+ token,
60
+ data
61
+ });
62
+ });
63
+
64
+ it("should delete qr mapping", () => {
65
+ const qrMappingId = "123";
66
+ axiosMock.onDelete(`/qr-mappings/${qrMappingId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
67
+ return api.accounts.qrMappings.remove({
68
+ jwtToken,
69
+ qrMappingId,
70
+ token
71
+ });
72
+ });
73
+ });