btrz-api-client 5.193.0 → 5.195.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
@@ -502,6 +502,26 @@ function createGPS(_ref15) {
502
502
  };
503
503
  }
504
504
 
505
+ function createRatality(_ref16) {
506
+ var baseURL = _ref16.baseURL,
507
+ headers = _ref16.headers,
508
+ timeout = _ref16.timeout,
509
+ overrideFn = _ref16.overrideFn,
510
+ agents = _ref16.agents;
511
+
512
+ var client = clientFactory({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: overrideFn, agents: agents });
513
+ var version = "v2";
514
+
515
+ return {
516
+ auth: require("./endpoints/ratality/auth.js")({ client: client }),
517
+ clients: require("./endpoints/ratality/clients.js")({ client: client, version: version }),
518
+ integrations: require("./endpoints/ratality/integrations.js")({ client: client, version: version }),
519
+ __test: {
520
+ client: client
521
+ }
522
+ };
523
+ }
524
+
505
525
  /**
506
526
  * Returns the apiClient object with defaults set
507
527
  *
@@ -516,15 +536,15 @@ function createGPS(_ref15) {
516
536
  * @param {{httpAgent: import("http").Agent, httpsAgent: import("https").Agent}} options.agents - An object containg one or both http agents
517
537
  */
518
538
  function createApiClient(options) {
519
- var _ref16 = options || productionOptions,
520
- baseURL = _ref16.baseURL,
521
- _ref16$baseURLOverrid = _ref16.baseURLOverride,
522
- baseURLOverride = _ref16$baseURLOverrid === undefined ? {} : _ref16$baseURLOverrid,
523
- headers = _ref16.headers,
524
- _ref16$timeout = _ref16.timeout,
525
- timeout = _ref16$timeout === undefined ? 0 : _ref16$timeout,
526
- internalAuthTokenProvider = _ref16.internalAuthTokenProvider,
527
- agents = _ref16.agents;
539
+ var _ref17 = options || productionOptions,
540
+ baseURL = _ref17.baseURL,
541
+ _ref17$baseURLOverrid = _ref17.baseURLOverride,
542
+ baseURLOverride = _ref17$baseURLOverrid === undefined ? {} : _ref17$baseURLOverrid,
543
+ headers = _ref17.headers,
544
+ _ref17$timeout = _ref17.timeout,
545
+ timeout = _ref17$timeout === undefined ? 0 : _ref17$timeout,
546
+ internalAuthTokenProvider = _ref17.internalAuthTokenProvider,
547
+ agents = _ref17.agents;
528
548
 
529
549
  return {
530
550
  constants: require("./constants.js"),
@@ -543,7 +563,8 @@ function createApiClient(options) {
543
563
  seatmaps: createSeatmaps({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.seatmaps, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
544
564
  btrzpay: createBtrzPay({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.btrzpay, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
545
565
  invoices: createInvoices({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
546
- gps: createGPS({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents })
566
+ gps: createGPS({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
567
+ ratality: createRatality({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.ratality, agents: agents })
547
568
  };
548
569
  }
549
570
 
@@ -362,6 +362,18 @@ function shiftsFactory(_ref) {
362
362
  });
363
363
  }
364
364
  };
365
+ var commissions = {
366
+ get: function get(_ref28) {
367
+ var token = _ref28.token,
368
+ jwtToken = _ref28.jwtToken,
369
+ shiftId = _ref28.shiftId,
370
+ headers = _ref28.headers;
371
+
372
+ return client.get("/shifts/" + shiftId + "/commissions", {
373
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
374
+ });
375
+ }
376
+ };
365
377
 
366
378
  return {
367
379
  all: all,
@@ -384,7 +396,8 @@ function shiftsFactory(_ref) {
384
396
  locationClosures: locationClosures,
385
397
  startingBalances: startingBalances,
386
398
  purchaseLimitPayments: purchaseLimitPayments,
387
- salesSummary: salesSummary
399
+ salesSummary: salesSummary,
400
+ commissions: commissions
388
401
  };
389
402
  }
390
403
 
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ function authFactory(_ref) {
4
+ var client = _ref.client;
5
+
6
+ function create(_ref2) {
7
+ var data = _ref2.data,
8
+ headers = _ref2.headers;
9
+
10
+ return client({
11
+ url: "/authenticate",
12
+ method: "post",
13
+ headers: headers,
14
+ data: data
15
+ });
16
+ }
17
+
18
+ return {
19
+ create: create
20
+ };
21
+ }
22
+
23
+ module.exports = authFactory;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _require = require("./../endpoints_helpers.js"),
4
+ authorizationHeaders = _require.authorizationHeaders;
5
+
6
+ function clientsFactory(_ref) {
7
+ var client = _ref.client,
8
+ version = _ref.version;
9
+
10
+ function create(_ref2) {
11
+ var jwtToken = _ref2.jwtToken,
12
+ data = _ref2.data,
13
+ headers = _ref2.headers;
14
+
15
+ return client({
16
+ url: "/" + version + "/client",
17
+ method: "post",
18
+ headers: authorizationHeaders({ jwtToken: jwtToken, headers: headers }),
19
+ data: data
20
+ });
21
+ }
22
+
23
+ function get(_ref3) {
24
+ var jwtToken = _ref3.jwtToken,
25
+ clientId = _ref3.clientId;
26
+
27
+ return client({
28
+ url: "/" + version + "/client",
29
+ method: "get",
30
+ headers: Object.assign({ clientId: clientId }, authorizationHeaders({ jwtToken: jwtToken }))
31
+ });
32
+ }
33
+
34
+ return {
35
+ create: create,
36
+ get: get
37
+ };
38
+ }
39
+
40
+ module.exports = clientsFactory;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _require = require("./../endpoints_helpers.js"),
4
+ authorizationHeaders = _require.authorizationHeaders;
5
+
6
+ function integrationsFactory(_ref) {
7
+ var client = _ref.client,
8
+ version = _ref.version;
9
+
10
+ function get(_ref2) {
11
+ var jwtToken = _ref2.jwtToken,
12
+ clientId = _ref2.clientId;
13
+
14
+ return client({
15
+ url: "/" + version + "/client/integrations",
16
+ method: "get",
17
+ headers: Object.assign({ clientId: clientId }, authorizationHeaders({ jwtToken: jwtToken }))
18
+ });
19
+ }
20
+
21
+ function create(_ref3) {
22
+ var jwtToken = _ref3.jwtToken,
23
+ clientId = _ref3.clientId,
24
+ data = _ref3.data;
25
+
26
+ return client({
27
+ url: "/" + version + "/client/integrations",
28
+ method: "post",
29
+ headers: Object.assign({ clientId: clientId }, authorizationHeaders({ jwtToken: jwtToken })),
30
+ data: data
31
+ });
32
+ }
33
+
34
+ function remove(_ref4) {
35
+ var jwtToken = _ref4.jwtToken,
36
+ clientId = _ref4.clientId,
37
+ integrationType = _ref4.integrationType;
38
+
39
+ return client({
40
+ url: "/" + version + "/client/integrations/" + integrationType,
41
+ method: "delete",
42
+ headers: Object.assign({ clientId: clientId }, authorizationHeaders({ jwtToken: jwtToken }))
43
+ });
44
+ }
45
+
46
+ return {
47
+ get: get,
48
+ create: create,
49
+ remove: remove
50
+ };
51
+ }
52
+
53
+ module.exports = integrationsFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "5.193.0",
3
+ "version": "5.195.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -391,6 +391,20 @@ function createGPS({baseURL, headers, timeout, overrideFn, internalAuthTokenProv
391
391
  };
392
392
  }
393
393
 
394
+ function createRatality({baseURL, headers, timeout, overrideFn, agents}) {
395
+ const client = clientFactory({baseURL, headers, timeout, overrideFn, agents});
396
+ const version = "v2";
397
+
398
+ return {
399
+ auth: require("./endpoints/ratality/auth.js")({client}),
400
+ clients: require("./endpoints/ratality/clients.js")({client, version}),
401
+ integrations: require("./endpoints/ratality/integrations.js")({client, version}),
402
+ __test: {
403
+ client
404
+ }
405
+ };
406
+ }
407
+
394
408
  /**
395
409
  * Returns the apiClient object with defaults set
396
410
  *
@@ -427,7 +441,8 @@ function createApiClient(options) {
427
441
  seatmaps: createSeatmaps({baseURL, headers, timeout, overrideFn: baseURLOverride.seatmaps, internalAuthTokenProvider, agents}),
428
442
  btrzpay: createBtrzPay({baseURL, headers, timeout, overrideFn: baseURLOverride.btrzpay, internalAuthTokenProvider, agents}),
429
443
  invoices: createInvoices({baseURL, headers, timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider, agents}),
430
- gps: createGPS({baseURL, headers, timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider, agents})
444
+ gps: createGPS({baseURL, headers, timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider, agents}),
445
+ ratality: createRatality({baseURL, headers, timeout, overrideFn: baseURLOverride.ratality, agents})
431
446
  };
432
447
  }
433
448
 
@@ -218,6 +218,13 @@ function shiftsFactory({client, internalAuthTokenProvider}) {
218
218
  });
219
219
  }
220
220
  };
221
+ const commissions = {
222
+ get({token, jwtToken, shiftId, headers}) {
223
+ return client.get(`/shifts/${shiftId}/commissions`, {
224
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
225
+ });
226
+ }
227
+ };
221
228
 
222
229
  return {
223
230
  all,
@@ -240,7 +247,8 @@ function shiftsFactory({client, internalAuthTokenProvider}) {
240
247
  locationClosures,
241
248
  startingBalances,
242
249
  purchaseLimitPayments,
243
- salesSummary
250
+ salesSummary,
251
+ commissions
244
252
  };
245
253
  }
246
254
 
@@ -0,0 +1,19 @@
1
+ function authFactory({client}) {
2
+ function create({
3
+ data,
4
+ headers
5
+ }) {
6
+ return client({
7
+ url: "/authenticate",
8
+ method: "post",
9
+ headers,
10
+ data
11
+ });
12
+ }
13
+
14
+ return {
15
+ create
16
+ };
17
+ }
18
+
19
+ module.exports = authFactory;
@@ -0,0 +1,35 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("./../endpoints_helpers.js");
4
+
5
+ function clientsFactory({client, version}) {
6
+ function create({
7
+ jwtToken,
8
+ data,
9
+ headers
10
+ }) {
11
+ return client({
12
+ url: `/${version}/client`,
13
+ method: "post",
14
+ headers: authorizationHeaders({jwtToken, headers}),
15
+ data
16
+ });
17
+ }
18
+
19
+ function get({
20
+ jwtToken, clientId
21
+ }) {
22
+ return client({
23
+ url: `/${version}/client`,
24
+ method: "get",
25
+ headers: Object.assign({clientId}, authorizationHeaders({jwtToken}))
26
+ });
27
+ }
28
+
29
+ return {
30
+ create,
31
+ get
32
+ };
33
+ }
34
+
35
+ module.exports = clientsFactory;
@@ -0,0 +1,44 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("./../endpoints_helpers.js");
4
+
5
+ function integrationsFactory({client, version}) {
6
+ function get({
7
+ jwtToken, clientId
8
+ }) {
9
+ return client({
10
+ url: `/${version}/client/integrations`,
11
+ method: "get",
12
+ headers: Object.assign({clientId}, authorizationHeaders({jwtToken}))
13
+ });
14
+ }
15
+
16
+ function create({
17
+ jwtToken, clientId, data
18
+ }) {
19
+ return client({
20
+ url: `/${version}/client/integrations`,
21
+ method: "post",
22
+ headers: Object.assign({clientId}, authorizationHeaders({jwtToken})),
23
+ data
24
+ });
25
+ }
26
+
27
+ function remove({
28
+ jwtToken, clientId, integrationType
29
+ }) {
30
+ return client({
31
+ url: `/${version}/client/integrations/${integrationType}`,
32
+ method: "delete",
33
+ headers: Object.assign({clientId}, authorizationHeaders({jwtToken}))
34
+ });
35
+ }
36
+
37
+ return {
38
+ get,
39
+ create,
40
+ remove
41
+ };
42
+ }
43
+
44
+ module.exports = integrationsFactory;
@@ -197,5 +197,12 @@ describe("accounts/shifts", () => {
197
197
  axiosMock.onGet(`/shifts/${shiftId}/sales-summary`).reply(expectRequest({statusCode: 200, token, query}));
198
198
  return api.accounts.shifts.salesSummary.get({token, jwtToken, shiftId, query});
199
199
  });
200
+
201
+ it("should get the shift commissions", () => {
202
+ const shiftId = "shiftId1";
203
+ axiosMock.onGet(`/shifts/${shiftId}/commissions`).reply(expectRequest({statusCode: 200, token}));
204
+ return api.accounts.shifts.commissions.get({token, jwtToken, shiftId});
205
+ });
206
+
200
207
  });
201
208
 
@@ -0,0 +1,23 @@
1
+ const {expect} = require("chai");
2
+ const {axiosMock} = require("./../../test-helpers");
3
+ const api = require("./../../../src/client").createApiClient({ baseURL: "http://ratality.com" });
4
+
5
+ describe("auth", () => {
6
+ afterEach(function() {
7
+ axiosMock.restore();
8
+ });
9
+
10
+ it("should perform a token create", () => {
11
+ const data = {
12
+ "username": "user_123",
13
+ "password": "pass_123",
14
+ "rememberMe": true
15
+ };
16
+ const response = {id_token: "someToken"};
17
+ axiosMock.onPost("/authenticate").reply((config) => {
18
+ expect(config.data).to.eql(JSON.stringify(data));
19
+ return [200, response];
20
+ });
21
+ return api.ratality.auth.create({data});
22
+ });
23
+ });
@@ -0,0 +1,32 @@
1
+ const { axiosMock, expectRequest } = require("./../../test-helpers");
2
+ const api = require("./../../../src/client").createApiClient({ baseURL: "http://ratality.com/v2" });
3
+
4
+ describe("client", () => {
5
+ const jwtToken = 'I owe you a JWT token';
6
+ const version = "v2";
7
+
8
+ afterEach(function() {
9
+ axiosMock.restore();
10
+ });
11
+
12
+ it("should perform a client create", () => {
13
+ const data = {
14
+ "name": "test_account",
15
+ "externalId": "testAccountId123"
16
+ };
17
+ axiosMock.onPost(`/${version}/client`).reply(expectRequest({statusCode: 200, jwtToken, body: data, withoutApiKey: true}));
18
+ return api.ratality.clients.create({
19
+ jwtToken,
20
+ data
21
+ });
22
+ });
23
+
24
+ it("should perform a client get", () => {
25
+ const clientId = "clientId123";
26
+ axiosMock.onGet(`/${version}/client`).reply(expectRequest({statusCode: 200, jwtToken, withoutApiKey: true}));
27
+ return api.ratality.clients.get({
28
+ jwtToken,
29
+ clientId
30
+ });
31
+ });
32
+ });
@@ -0,0 +1,90 @@
1
+ const { expect } = require("chai");
2
+ const { axiosMock, expectRequest } = require("./../../test-helpers");
3
+ const api = require("./../../../src/client").createApiClient({ baseURL: "http://ratality.com/v2" });
4
+
5
+ describe("integrations", () => {
6
+ const jwtToken = 'I owe you a JWT token';
7
+ const version = "v2";
8
+
9
+ afterEach(function() {
10
+ axiosMock.restore();
11
+ });
12
+
13
+ it("should perform an integration create", () => {
14
+ const clientId = "clientId123";
15
+ const data = {
16
+ "integrationType": "Betterez",
17
+ "outboundConnection": {
18
+ "url": "https://sandbox-api.betterez.com",
19
+ "username": "user@place.com",
20
+ "password": "123456"
21
+ }
22
+ };
23
+ axiosMock.onPost(`/${version}/client/integrations`).reply((config) => {
24
+ expectRequest({statusCode: 200, jwtToken, body: data, withoutApiKey: true});
25
+ expect(config.headers).to.include({clientId});
26
+ return [200, {
27
+ "integrationType": "Betterez",
28
+ "clientId": clientId,
29
+ "channelId": 1000,
30
+ "outboundConnection": {
31
+ "url": "https://sandbox-api.betterez.com",
32
+ "username": "user@place.com",
33
+ "password": "123456"
34
+ },
35
+ "inboundConnection": {
36
+ "url": "https://integrate.us.ratality.com/betterez/99999",
37
+ "tags": [
38
+ "brand.created",
39
+ "brand.updated",
40
+ "station.created",
41
+ "station.updated",
42
+ "route.created",
43
+ "route.updated",
44
+ "route.deleted",
45
+ "schedule.created",
46
+ "schedule.updated",
47
+ "schedule.deleted",
48
+ "ticket.created",
49
+ "ticket.updated",
50
+ "ticket.moved"
51
+ ]
52
+ }
53
+ }];
54
+ });
55
+ return api.ratality.integrations.create({
56
+ jwtToken,
57
+ clientId,
58
+ data
59
+ });
60
+ });
61
+
62
+ it("should perform an integration get", () => {
63
+ const clientId = "clientId123";
64
+ axiosMock.onGet(`/${version}/client/integrations`).reply((config) => {
65
+ expectRequest({statusCode: 200, jwtToken, withoutApiKey: true});
66
+ expect(config.headers).to.include({clientId});
67
+ return [200, {integrations: []}];
68
+ });
69
+ return api.ratality.integrations.get({
70
+ jwtToken,
71
+ clientId
72
+ });
73
+ });
74
+
75
+ it("should perform an integration delete", () => {
76
+ const clientId = "clientId123";
77
+ const integrationType = "Betterez";
78
+ axiosMock.onDelete(`/${version}/client/integrations/${integrationType}`).reply((config) => {
79
+ expectRequest({statusCode: 200, jwtToken, withoutApiKey: true});
80
+ expect(config.headers).to.include({clientId});
81
+ expect(config.url).to.contain("Betterez");
82
+ return [200, {integrations: []}];
83
+ });
84
+ return api.ratality.integrations.remove({
85
+ jwtToken,
86
+ clientId,
87
+ integrationType
88
+ });
89
+ });
90
+ });
package/types/client.d.ts CHANGED
@@ -2474,6 +2474,14 @@ export function createApiClient(options: {
2474
2474
  headers: any;
2475
2475
  }): any;
2476
2476
  };
2477
+ commissions: {
2478
+ get({ token, jwtToken, shiftId, headers }: {
2479
+ token: any;
2480
+ jwtToken: any;
2481
+ shiftId: any;
2482
+ headers: any;
2483
+ }): any;
2484
+ };
2477
2485
  };
2478
2486
  shiftSettings: {
2479
2487
  get: ({ token, jwtToken, query, headers }: {
@@ -4460,5 +4468,43 @@ export function createApiClient(options: {
4460
4468
  client: axios.AxiosInstance;
4461
4469
  };
4462
4470
  };
4471
+ ratality: {
4472
+ auth: {
4473
+ create: ({ data, headers }: {
4474
+ data: any;
4475
+ headers: any;
4476
+ }) => any;
4477
+ };
4478
+ clients: {
4479
+ create: ({ jwtToken, data, headers }: {
4480
+ jwtToken: any;
4481
+ data: any;
4482
+ headers: any;
4483
+ }) => any;
4484
+ get: ({ jwtToken, clientId }: {
4485
+ jwtToken: any;
4486
+ clientId: any;
4487
+ }) => any;
4488
+ };
4489
+ integrations: {
4490
+ get: ({ jwtToken, clientId }: {
4491
+ jwtToken: any;
4492
+ clientId: any;
4493
+ }) => any;
4494
+ create: ({ jwtToken, clientId, data }: {
4495
+ jwtToken: any;
4496
+ clientId: any;
4497
+ data: any;
4498
+ }) => any;
4499
+ remove: ({ jwtToken, clientId, integrationType }: {
4500
+ jwtToken: any;
4501
+ clientId: any;
4502
+ integrationType: any;
4503
+ }) => any;
4504
+ };
4505
+ __test: {
4506
+ client: axios.AxiosInstance;
4507
+ };
4508
+ };
4463
4509
  };
4464
4510
  import axios = require("axios");
@@ -202,4 +202,12 @@ declare function shiftsFactory({ client, internalAuthTokenProvider }: {
202
202
  headers: any;
203
203
  }): any;
204
204
  };
205
+ commissions: {
206
+ get({ token, jwtToken, shiftId, headers }: {
207
+ token: any;
208
+ jwtToken: any;
209
+ shiftId: any;
210
+ headers: any;
211
+ }): any;
212
+ };
205
213
  };
@@ -0,0 +1,9 @@
1
+ export = authFactory;
2
+ declare function authFactory({ client }: {
3
+ client: any;
4
+ }): {
5
+ create: ({ data, headers }: {
6
+ data: any;
7
+ headers: any;
8
+ }) => any;
9
+ };
@@ -0,0 +1,15 @@
1
+ export = clientsFactory;
2
+ declare function clientsFactory({ client, version }: {
3
+ client: any;
4
+ version: any;
5
+ }): {
6
+ create: ({ jwtToken, data, headers }: {
7
+ jwtToken: any;
8
+ data: any;
9
+ headers: any;
10
+ }) => any;
11
+ get: ({ jwtToken, clientId }: {
12
+ jwtToken: any;
13
+ clientId: any;
14
+ }) => any;
15
+ };
@@ -0,0 +1,20 @@
1
+ export = integrationsFactory;
2
+ declare function integrationsFactory({ client, version }: {
3
+ client: any;
4
+ version: any;
5
+ }): {
6
+ get: ({ jwtToken, clientId }: {
7
+ jwtToken: any;
8
+ clientId: any;
9
+ }) => any;
10
+ create: ({ jwtToken, clientId, data }: {
11
+ jwtToken: any;
12
+ clientId: any;
13
+ data: any;
14
+ }) => any;
15
+ remove: ({ jwtToken, clientId, integrationType }: {
16
+ jwtToken: any;
17
+ clientId: any;
18
+ integrationType: any;
19
+ }) => any;
20
+ };