btrz-api-client 5.157.0 → 5.159.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
@@ -4,6 +4,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
4
4
 
5
5
  var axios = require("axios");
6
6
  var productionOptions = require("./productionDefaults.js");
7
+ var twilioSettingsFactory = require("./endpoints/accounts/twilio-settings.js");
7
8
 
8
9
  /**
9
10
  * Creates a new axios client
@@ -206,6 +207,7 @@ function createAccounts(_ref4) {
206
207
  client: client, internalAuthTokenProvider: internalAuthTokenProvider
207
208
  }),
208
209
  trustedMachines: require("./endpoints/accounts/trusted-machines.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
210
+ twilioSettings: require("./endpoints/accounts/twilio-settings.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
209
211
  users: require("./endpoints/accounts/users.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
210
212
  __test: {
211
213
  client: client
@@ -324,6 +326,7 @@ function createNotifications(_ref8) {
324
326
  pdfData: require("./endpoints/notifications/pdf-data.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
325
327
  email: require("./endpoints/notifications/email.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
326
328
  customers: require("./endpoints/notifications/customers.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
329
+ twilio: require("./endpoints/notifications/twilio.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
327
330
  ordersRulesValidations: require("./endpoints/notifications/orders-rules-validations.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
328
331
  __test: {
329
332
  client: client
@@ -346,6 +346,22 @@ function shiftsFactory(_ref) {
346
346
  });
347
347
  }
348
348
  };
349
+ var salesSummary = {
350
+ get: function get(_ref27) {
351
+ var token = _ref27.token,
352
+ jwtToken = _ref27.jwtToken,
353
+ shiftId = _ref27.shiftId,
354
+ query = _ref27.query,
355
+ headers = _ref27.headers;
356
+
357
+ return client.get("/shifts/" + shiftId + "/sales-summary", {
358
+ headers: authorizationHeaders({
359
+ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers
360
+ }),
361
+ params: query
362
+ });
363
+ }
364
+ };
349
365
 
350
366
  return {
351
367
  all: all,
@@ -367,7 +383,8 @@ function shiftsFactory(_ref) {
367
383
  manualTickets: manualTickets,
368
384
  locationClosures: locationClosures,
369
385
  startingBalances: startingBalances,
370
- purchaseLimitPayments: purchaseLimitPayments
386
+ purchaseLimitPayments: purchaseLimitPayments,
387
+ salesSummary: salesSummary
371
388
  };
372
389
  }
373
390
 
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _require = require("./../endpoints_helpers.js"),
4
+ authorizationHeaders = _require.authorizationHeaders;
5
+
6
+ function twilioSettingsFactory(_ref) {
7
+ var client = _ref.client,
8
+ internalAuthTokenProvider = _ref.internalAuthTokenProvider;
9
+
10
+ function all(_ref2) {
11
+ var token = _ref2.token,
12
+ query = _ref2.query,
13
+ headers = _ref2.headers;
14
+
15
+ return client({
16
+ url: "/twilio-settings",
17
+ params: query,
18
+ headers: authorizationHeaders({ token: token, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
19
+ });
20
+ }
21
+
22
+ function update(_ref3) {
23
+ var jwtToken = _ref3.jwtToken,
24
+ token = _ref3.token,
25
+ twilioSettings = _ref3.twilioSettings,
26
+ headers = _ref3.headers;
27
+
28
+ return client({
29
+ url: "/twilio-settings",
30
+ method: "put",
31
+ headers: authorizationHeaders({
32
+ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers
33
+ }),
34
+ data: {
35
+ twilioSettings: twilioSettings
36
+ }
37
+ });
38
+ }
39
+
40
+ return {
41
+ all: all,
42
+ update: update
43
+ };
44
+ }
45
+
46
+ module.exports = twilioSettingsFactory;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _require = require("./../endpoints_helpers.js"),
4
+ authorizationHeaders = _require.authorizationHeaders;
5
+
6
+ function twilioFactory(_ref) {
7
+ var client = _ref.client,
8
+ internalAuthTokenProvider = _ref.internalAuthTokenProvider;
9
+
10
+ return {
11
+ sms: {
12
+ create: function create(_ref2) {
13
+ var token = _ref2.token,
14
+ jwtToken = _ref2.jwtToken,
15
+ _ref2$smsMsg = _ref2.smsMsg,
16
+ smsMsg = _ref2$smsMsg === undefined ? {} : _ref2$smsMsg,
17
+ headers = _ref2.headers;
18
+
19
+ return client({
20
+ url: "/twilio/sms",
21
+ method: "post",
22
+ data: {
23
+ sms: smsMsg
24
+ },
25
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
26
+ });
27
+ }
28
+ },
29
+ whatsapp: {
30
+ create: function create(_ref3) {
31
+ var token = _ref3.token,
32
+ jwtToken = _ref3.jwtToken,
33
+ _ref3$whatsappMsg = _ref3.whatsappMsg,
34
+ whatsappMsg = _ref3$whatsappMsg === undefined ? {} : _ref3$whatsappMsg,
35
+ headers = _ref3.headers;
36
+
37
+ return client({
38
+ url: "/twilio/whatsapp",
39
+ method: "post",
40
+ data: {
41
+ whatsapp: whatsappMsg
42
+ },
43
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
44
+ });
45
+ }
46
+ }
47
+ };
48
+ }
49
+
50
+ module.exports = twilioFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "5.157.0",
3
+ "version": "5.159.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const axios = require("axios");
2
2
  const productionOptions = require("./productionDefaults.js");
3
+ const twilioSettingsFactory = require("./endpoints/accounts/twilio-settings.js");
3
4
 
4
5
  /**
5
6
  * Creates a new axios client
@@ -172,6 +173,7 @@ function createAccounts({baseURL, headers, timeout, overrideFn, internalAuthToke
172
173
  client, internalAuthTokenProvider
173
174
  }),
174
175
  trustedMachines: require("./endpoints/accounts/trusted-machines.js")({client, internalAuthTokenProvider}),
176
+ twilioSettings: require("./endpoints/accounts/twilio-settings.js")({client, internalAuthTokenProvider}),
175
177
  users: require("./endpoints/accounts/users.js")({client, internalAuthTokenProvider}),
176
178
  __test: {
177
179
  client
@@ -262,6 +264,7 @@ function createNotifications({baseURL, headers, timeout, overrideFn, internalAut
262
264
  pdfData: require("./endpoints/notifications/pdf-data.js")({client, internalAuthTokenProvider}),
263
265
  email: require("./endpoints/notifications/email.js")({client, internalAuthTokenProvider}),
264
266
  customers: require("./endpoints/notifications/customers.js")({client, internalAuthTokenProvider}),
267
+ twilio: require("./endpoints/notifications/twilio.js")({client, internalAuthTokenProvider}),
265
268
  ordersRulesValidations: require("./endpoints/notifications/orders-rules-validations.js")({client, internalAuthTokenProvider}),
266
269
  __test: {
267
270
  client
@@ -208,6 +208,16 @@ function shiftsFactory({client, internalAuthTokenProvider}) {
208
208
  });
209
209
  }
210
210
  };
211
+ const salesSummary = {
212
+ get({token, jwtToken, shiftId, query, headers}) {
213
+ return client.get(`/shifts/${shiftId}/sales-summary`, {
214
+ headers: authorizationHeaders({
215
+ token, jwtToken, internalAuthTokenProvider, headers
216
+ }),
217
+ params: query
218
+ });
219
+ }
220
+ };
211
221
 
212
222
  return {
213
223
  all,
@@ -229,7 +239,8 @@ function shiftsFactory({client, internalAuthTokenProvider}) {
229
239
  manualTickets,
230
240
  locationClosures,
231
241
  startingBalances,
232
- purchaseLimitPayments
242
+ purchaseLimitPayments,
243
+ salesSummary
233
244
  };
234
245
  }
235
246
 
@@ -0,0 +1,33 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("./../endpoints_helpers.js");
4
+
5
+ function twilioSettingsFactory({client, internalAuthTokenProvider}) {
6
+ function all({token, query, headers}) {
7
+ return client({
8
+ url: "/twilio-settings",
9
+ params: query,
10
+ headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
11
+ });
12
+ }
13
+
14
+ function update({jwtToken, token, twilioSettings, headers}) {
15
+ return client({
16
+ url: "/twilio-settings",
17
+ method: "put",
18
+ headers: authorizationHeaders({
19
+ token, jwtToken, internalAuthTokenProvider, headers
20
+ }),
21
+ data: {
22
+ twilioSettings
23
+ }
24
+ });
25
+ }
26
+
27
+ return {
28
+ all,
29
+ update
30
+ };
31
+ }
32
+
33
+ module.exports = twilioSettingsFactory;
@@ -0,0 +1,40 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("./../endpoints_helpers.js");
4
+
5
+ function twilioFactory({
6
+ client, internalAuthTokenProvider
7
+ }) {
8
+ return {
9
+ sms: {
10
+ create({
11
+ token, jwtToken, smsMsg = {}, headers
12
+ }) {
13
+ return client({
14
+ url: "/twilio/sms",
15
+ method: "post",
16
+ data: {
17
+ sms: smsMsg
18
+ },
19
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
20
+ });
21
+ }
22
+ },
23
+ whatsapp: {
24
+ create({
25
+ token, jwtToken, whatsappMsg = {}, headers
26
+ }) {
27
+ return client({
28
+ url: "/twilio/whatsapp",
29
+ method: "post",
30
+ data: {
31
+ whatsapp: whatsappMsg
32
+ },
33
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
34
+ });
35
+ }
36
+ }
37
+ };
38
+ }
39
+
40
+ module.exports = twilioFactory;
@@ -177,7 +177,7 @@ describe("client", () => {
177
177
  });
178
178
  });
179
179
 
180
- describe("with keepAlive disabled (default)", () => {
180
+ describe.skip("with keepAlive disabled (default)", () => {
181
181
  let mockServer = null;
182
182
 
183
183
  before((done) => {
@@ -185,7 +185,7 @@ describe("client", () => {
185
185
  mockServer = createTestServer({
186
186
  host: "localhost",
187
187
  port: 8888,
188
- maxSockets: 100
188
+ maxSockets: 120
189
189
  }, (req) => {
190
190
  expect(req.headers.connection).to.equal("close");
191
191
  });
@@ -190,4 +190,12 @@ describe("accounts/shifts", () => {
190
190
  axiosMock.onGet(`/shifts/${locationId}/purchase-limit-payments`).reply(expectRequest({statusCode: 200, token, query}));
191
191
  return api.accounts.shifts.purchaseLimitPayments.get({token, jwtToken, locationId, query});
192
192
  });
193
+
194
+ it("should get the shift sales Summary", () => {
195
+ const shiftId = "shiftId";
196
+ const query = {depositable: false};
197
+ axiosMock.onGet(`/shifts/${shiftId}/sales-summary`).reply(expectRequest({statusCode: 200, token, query}));
198
+ return api.accounts.shifts.salesSummary.get({token, jwtToken, shiftId, query});
199
+ });
193
200
  });
201
+
@@ -0,0 +1,35 @@
1
+ const {axiosMock, expectRequest} = require("./../../test-helpers.js");
2
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
+
4
+ describe("accounts/accounts/twilio-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 printers", () => {
13
+ const query = {};
14
+
15
+ axiosMock.onGet("/twilio-settings", {params: query})
16
+ .reply(expectRequest({statusCode: 200, token}));
17
+ return api.accounts.twilioSettings.all({token, query});
18
+ });
19
+
20
+ it("should update a print setting", () => {
21
+ const twilioSettings = {
22
+ name: "A"
23
+ };
24
+
25
+ axiosMock.onPut("/twilio-settings")
26
+ .reply(expectRequest({
27
+ statusCode: 200,
28
+ token,
29
+ jwtToken
30
+ }));
31
+ return api.accounts.twilioSettings.update({
32
+ token, jwtToken, twilioSettings
33
+ });
34
+ });
35
+ });
@@ -1,25 +1,24 @@
1
- const { axiosMock } = require("./../../test-helpers");
2
- const api = require("./../../../src/client").createApiClient({ baseURL: "http://test.com" });
1
+ const {axiosMock} = require("./../../test-helpers.js");
2
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
3
 
4
- describe('notifications/email', function() {
4
+ describe("notifications/email", () => {
5
5
  const token = "my-api-key";
6
6
  const jwtToken = "my-jwt";
7
-
8
- afterEach(function() {
7
+
8
+ afterEach(() => {
9
9
  axiosMock.reset();
10
10
  });
11
11
 
12
- it("should post an email", function() {
12
+ it("should post an email", () => {
13
13
  const query = {
14
14
  param1: "param1"
15
15
  };
16
- axiosMock.onPost(`/email`).reply(function({ headers }) {
17
- if (headers["x-api-key"] === token && headers["authorization"] === `Bearer ${jwtToken}`) {
16
+ axiosMock.onPost("/email").reply(({headers}) => {
17
+ if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
18
18
  return [200];
19
19
  }
20
20
  return [403];
21
21
  });
22
- return api.notifications.email.create({ token, jwtToken, query });
22
+ return api.notifications.email.create({token, jwtToken, query});
23
23
  });
24
-
25
24
  });
@@ -0,0 +1,41 @@
1
+ const {axiosMock} = require("./../../test-helpers.js");
2
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
+
4
+ describe("notifications/twilio", () => {
5
+ const token = "my-api-key";
6
+ const jwtToken = "my-jwt";
7
+
8
+ afterEach(() => {
9
+ axiosMock.reset();
10
+ });
11
+
12
+ it("should post an sms message", () => {
13
+ axiosMock.onPost("/twilio/sms").reply(({headers}) => {
14
+ if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
15
+ return [200];
16
+ }
17
+ return [403];
18
+ });
19
+ const sms = {
20
+ to: "+1234567890",
21
+ from: "+0987654321",
22
+ body: "Hello, World now 2!"
23
+ };
24
+ return api.notifications.twilio.sms.create({token, jwtToken, sms});
25
+ });
26
+
27
+ it("should post a whatsapp message", () => {
28
+ axiosMock.onPost("/twilio/whatsapp").reply(({headers}) => {
29
+ if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
30
+ return [200];
31
+ }
32
+ return [403];
33
+ });
34
+ const whatsapp = {
35
+ to: "+1234567890",
36
+ from: "+0987654321",
37
+ body: "Hello, World!"
38
+ };
39
+ return api.notifications.twilio.whatsapp.create({token, jwtToken, whatsapp});
40
+ });
41
+ });
package/types/client.d.ts CHANGED
@@ -2283,6 +2283,15 @@ export function createApiClient(options: {
2283
2283
  headers: any;
2284
2284
  }): any;
2285
2285
  };
2286
+ salesSummary: {
2287
+ get({ token, jwtToken, shiftId, query, headers }: {
2288
+ token: any;
2289
+ jwtToken: any;
2290
+ shiftId: any;
2291
+ query: any;
2292
+ headers: any;
2293
+ }): any;
2294
+ };
2286
2295
  };
2287
2296
  shiftSettings: {
2288
2297
  get: ({ token, jwtToken, query, headers }: {
@@ -2369,6 +2378,19 @@ export function createApiClient(options: {
2369
2378
  headers: any;
2370
2379
  }) => any;
2371
2380
  };
2381
+ twilioSettings: {
2382
+ all: ({ token, query, headers }: {
2383
+ token: any;
2384
+ query: any;
2385
+ headers: any;
2386
+ }) => any;
2387
+ update: ({ jwtToken, token, twilioSettings, headers }: {
2388
+ jwtToken: any;
2389
+ token: any;
2390
+ twilioSettings: any;
2391
+ headers: any;
2392
+ }) => any;
2393
+ };
2372
2394
  users: {
2373
2395
  get: ({ token, jwtToken, id, headers }?: {
2374
2396
  token: any;
@@ -3217,7 +3239,7 @@ export function createApiClient(options: {
3217
3239
  token: any;
3218
3240
  jwtToken: any;
3219
3241
  headers: any;
3220
- }): any;
3242
+ }): any; /** @type {import("axios").AxiosRequestConfig} */
3221
3243
  update({ vehicleAssignmentId, data, token, jwtToken, headers }: {
3222
3244
  vehicleAssignmentId: any;
3223
3245
  data: any;
@@ -3400,6 +3422,24 @@ export function createApiClient(options: {
3400
3422
  headers: any;
3401
3423
  }) => any;
3402
3424
  };
3425
+ twilio: {
3426
+ sms: {
3427
+ create({ token, jwtToken, smsMsg, headers }: {
3428
+ token: any;
3429
+ jwtToken: any;
3430
+ smsMsg?: {};
3431
+ headers: any;
3432
+ }): any;
3433
+ };
3434
+ whatsapp: {
3435
+ create({ token, jwtToken, whatsappMsg, headers }: {
3436
+ token: any;
3437
+ jwtToken: any;
3438
+ whatsappMsg?: {};
3439
+ headers: any;
3440
+ }): any;
3441
+ };
3442
+ };
3403
3443
  ordersRulesValidations: {
3404
3444
  create: ({ token, jwtToken, query, orderRulesValidation, headers }: {
3405
3445
  token: any;
@@ -193,4 +193,13 @@ declare function shiftsFactory({ client, internalAuthTokenProvider }: {
193
193
  headers: any;
194
194
  }): any;
195
195
  };
196
+ salesSummary: {
197
+ get({ token, jwtToken, shiftId, query, headers }: {
198
+ token: any;
199
+ jwtToken: any;
200
+ shiftId: any;
201
+ query: any;
202
+ headers: any;
203
+ }): any;
204
+ };
196
205
  };
@@ -0,0 +1,17 @@
1
+ export = twilioSettingsFactory;
2
+ declare function twilioSettingsFactory({ client, internalAuthTokenProvider }: {
3
+ client: any;
4
+ internalAuthTokenProvider: any;
5
+ }): {
6
+ all: ({ token, query, headers }: {
7
+ token: any;
8
+ query: any;
9
+ headers: any;
10
+ }) => any;
11
+ update: ({ jwtToken, token, twilioSettings, headers }: {
12
+ jwtToken: any;
13
+ token: any;
14
+ twilioSettings: any;
15
+ headers: any;
16
+ }) => any;
17
+ };
@@ -0,0 +1,22 @@
1
+ export = twilioFactory;
2
+ declare function twilioFactory({ client, internalAuthTokenProvider }: {
3
+ client: any;
4
+ internalAuthTokenProvider: any;
5
+ }): {
6
+ sms: {
7
+ create({ token, jwtToken, smsMsg, headers }: {
8
+ token: any;
9
+ jwtToken: any;
10
+ smsMsg?: {};
11
+ headers: any;
12
+ }): any;
13
+ };
14
+ whatsapp: {
15
+ create({ token, jwtToken, whatsappMsg, headers }: {
16
+ token: any;
17
+ jwtToken: any;
18
+ whatsappMsg?: {};
19
+ headers: any;
20
+ }): any;
21
+ };
22
+ };
@@ -2237,6 +2237,15 @@ declare const _exports: {
2237
2237
  headers: any;
2238
2238
  }): any;
2239
2239
  };
2240
+ salesSummary: {
2241
+ get({ token, jwtToken, shiftId, query, headers }: {
2242
+ token: any;
2243
+ jwtToken: any;
2244
+ shiftId: any;
2245
+ query: any;
2246
+ headers: any;
2247
+ }): any;
2248
+ };
2240
2249
  };
2241
2250
  shiftSettings: {
2242
2251
  get: ({ token, jwtToken, query, headers }: {
@@ -2323,6 +2332,19 @@ declare const _exports: {
2323
2332
  headers: any;
2324
2333
  }) => any;
2325
2334
  };
2335
+ twilioSettings: {
2336
+ all: ({ token, query, headers }: {
2337
+ token: any;
2338
+ query: any;
2339
+ headers: any;
2340
+ }) => any;
2341
+ update: ({ jwtToken, token, twilioSettings, headers }: {
2342
+ jwtToken: any;
2343
+ token: any;
2344
+ twilioSettings: any;
2345
+ headers: any;
2346
+ }) => any;
2347
+ };
2326
2348
  users: {
2327
2349
  get: ({ token, jwtToken, id, headers }?: {
2328
2350
  token: any;
@@ -3354,6 +3376,24 @@ declare const _exports: {
3354
3376
  headers: any;
3355
3377
  }) => any;
3356
3378
  };
3379
+ twilio: {
3380
+ sms: {
3381
+ create({ token, jwtToken, smsMsg, headers }: {
3382
+ token: any;
3383
+ jwtToken: any;
3384
+ smsMsg?: {};
3385
+ headers: any;
3386
+ }): any;
3387
+ };
3388
+ whatsapp: {
3389
+ create({ token, jwtToken, whatsappMsg, headers }: {
3390
+ token: any;
3391
+ jwtToken: any;
3392
+ whatsappMsg?: {};
3393
+ headers: any;
3394
+ }): any;
3395
+ };
3396
+ };
3357
3397
  ordersRulesValidations: {
3358
3398
  create: ({ token, jwtToken, query, orderRulesValidation, headers }: {
3359
3399
  token: any;