btrz-api-client 8.73.0 → 8.74.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
@@ -610,11 +610,11 @@ function createInvoices(_ref14) {
610
610
  }
611
611
 
612
612
  /**
613
- * Creates the GPS API client (scannerAppLocation).
613
+ * Creates the BPE API client (configuration).
614
614
  * @param {CreateModuleOptions} opts - Client options
615
- * @returns {Object} Object with gps endpoint namespaces and __test.client
615
+ * @returns {Object} Object with bpes endpoint namespaces and __test.client
616
616
  */
617
- function createGPS(_ref15) {
617
+ function createBpes(_ref15) {
618
618
  var baseURL = _ref15.baseURL,
619
619
  headers = _ref15.headers,
620
620
  timeout = _ref15.timeout,
@@ -625,7 +625,7 @@ function createGPS(_ref15) {
625
625
  var client = clientFactory({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: overrideFn, agents: agents });
626
626
 
627
627
  return {
628
- scannerAppLocation: require("./endpoints/gps/scanner-app-location.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
628
+ configuration: require("./endpoints/bpes/configuration.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
629
629
  __test: {
630
630
  client: client
631
631
  }
@@ -633,17 +633,40 @@ function createGPS(_ref15) {
633
633
  }
634
634
 
635
635
  /**
636
- * Creates the Ratality API client (auth, clients, integrations). Does not use internalAuthTokenProvider.
637
- * @param {Omit<CreateModuleOptions, "internalAuthTokenProvider">} opts - Client options (no internalAuthTokenProvider)
638
- * @returns {Object} Object with ratality endpoint namespaces and __test.client
636
+ * Creates the GPS API client (scannerAppLocation).
637
+ * @param {CreateModuleOptions} opts - Client options
638
+ * @returns {Object} Object with gps endpoint namespaces and __test.client
639
639
  */
640
- function createRatality(_ref16) {
640
+ function createGPS(_ref16) {
641
641
  var baseURL = _ref16.baseURL,
642
642
  headers = _ref16.headers,
643
643
  timeout = _ref16.timeout,
644
644
  overrideFn = _ref16.overrideFn,
645
+ internalAuthTokenProvider = _ref16.internalAuthTokenProvider,
645
646
  agents = _ref16.agents;
646
647
 
648
+ var client = clientFactory({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: overrideFn, agents: agents });
649
+
650
+ return {
651
+ scannerAppLocation: require("./endpoints/gps/scanner-app-location.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
652
+ __test: {
653
+ client: client
654
+ }
655
+ };
656
+ }
657
+
658
+ /**
659
+ * Creates the Ratality API client (auth, clients, integrations). Does not use internalAuthTokenProvider.
660
+ * @param {Omit<CreateModuleOptions, "internalAuthTokenProvider">} opts - Client options (no internalAuthTokenProvider)
661
+ * @returns {Object} Object with ratality endpoint namespaces and __test.client
662
+ */
663
+ function createRatality(_ref17) {
664
+ var baseURL = _ref17.baseURL,
665
+ headers = _ref17.headers,
666
+ timeout = _ref17.timeout,
667
+ overrideFn = _ref17.overrideFn,
668
+ agents = _ref17.agents;
669
+
647
670
  var client = clientFactory({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: overrideFn, agents: agents });
648
671
  var version = "v2";
649
672
 
@@ -671,15 +694,15 @@ function createRatality(_ref16) {
671
694
  * @param {{httpAgent: import("http").Agent, httpsAgent: import("https").Agent}} options.agents - An object containg one or both http agents
672
695
  */
673
696
  function createApiClient(options) {
674
- var _ref17 = options || productionOptions,
675
- baseURL = _ref17.baseURL,
676
- _ref17$baseURLOverrid = _ref17.baseURLOverride,
677
- baseURLOverride = _ref17$baseURLOverrid === undefined ? {} : _ref17$baseURLOverrid,
678
- headers = _ref17.headers,
679
- _ref17$timeout = _ref17.timeout,
680
- timeout = _ref17$timeout === undefined ? 0 : _ref17$timeout,
681
- internalAuthTokenProvider = _ref17.internalAuthTokenProvider,
682
- agents = _ref17.agents;
697
+ var _ref18 = options || productionOptions,
698
+ baseURL = _ref18.baseURL,
699
+ _ref18$baseURLOverrid = _ref18.baseURLOverride,
700
+ baseURLOverride = _ref18$baseURLOverrid === undefined ? {} : _ref18$baseURLOverrid,
701
+ headers = _ref18.headers,
702
+ _ref18$timeout = _ref18.timeout,
703
+ timeout = _ref18$timeout === undefined ? 0 : _ref18$timeout,
704
+ internalAuthTokenProvider = _ref18.internalAuthTokenProvider,
705
+ agents = _ref18.agents;
683
706
 
684
707
  return {
685
708
  constants: require("./constants.js"),
@@ -698,6 +721,7 @@ function createApiClient(options) {
698
721
  seatmaps: createSeatmaps({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.seatmaps, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
699
722
  btrzpay: createBtrzPay({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.btrzpay, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
700
723
  invoices: createInvoices({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
724
+ bpes: createBpes({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.bpes, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
701
725
  gps: createGPS({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider: internalAuthTokenProvider, agents: agents }),
702
726
  ratality: createRatality({ baseURL: baseURL, headers: headers, timeout: timeout, overrideFn: baseURLOverride.ratality, agents: agents })
703
727
  };
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ var _require = require("../endpoints_helpers.js"),
4
+ authorizationHeaders = _require.authorizationHeaders;
5
+
6
+ /**
7
+ * Factory for BPE configuration API (btrz-api-bpes).
8
+ * @param {Object} deps
9
+ * @param {import("axios").AxiosInstance} deps.client
10
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
11
+ * @returns {{ get: function, create: function, update: function }}
12
+ */
13
+
14
+
15
+ function configurationFactory(_ref) {
16
+ var client = _ref.client,
17
+ internalAuthTokenProvider = _ref.internalAuthTokenProvider;
18
+
19
+ /**
20
+ * GET /bpe-configurations - returns the BPE configuration for the authenticated account.
21
+ * @param {Object} opts
22
+ * @param {string} [opts.token] - API key
23
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
24
+ * @param {Object} [opts.headers] - Optional headers
25
+ * @returns {Promise<import("axios").AxiosResponse<{ bpeConfiguration: Object }>>}
26
+ */
27
+ function get(_ref2) {
28
+ var token = _ref2.token,
29
+ jwtToken = _ref2.jwtToken,
30
+ headers = _ref2.headers;
31
+
32
+ return client({
33
+ url: "/bpe-configurations",
34
+ method: "get",
35
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
36
+ });
37
+ }
38
+
39
+ /**
40
+ * POST /bpe-configurations - creates the BPE configuration for the authenticated account.
41
+ * @param {Object} opts
42
+ * @param {string} [opts.token] - API key
43
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
44
+ * @param {Object} opts.bpeConfiguration - Configuration payload
45
+ * @param {Object} [opts.headers] - Optional headers
46
+ * @returns {Promise<import("axios").AxiosResponse<{ bpeConfiguration: Object }>>}
47
+ */
48
+ function create(_ref3) {
49
+ var token = _ref3.token,
50
+ jwtToken = _ref3.jwtToken,
51
+ bpeConfiguration = _ref3.bpeConfiguration,
52
+ headers = _ref3.headers;
53
+
54
+ return client({
55
+ url: "/bpe-configurations",
56
+ method: "post",
57
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
58
+ data: { bpeConfiguration: bpeConfiguration }
59
+ });
60
+ }
61
+
62
+ /**
63
+ * PUT /bpe-configurations - updates the BPE configuration for the authenticated account.
64
+ * @param {Object} opts
65
+ * @param {string} [opts.token] - API key
66
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
67
+ * @param {Object} opts.bpeConfiguration - Configuration payload
68
+ * @param {Object} [opts.headers] - Optional headers
69
+ * @returns {Promise<import("axios").AxiosResponse<{ bpeConfiguration: Object }>>}
70
+ */
71
+ function update(_ref4) {
72
+ var token = _ref4.token,
73
+ jwtToken = _ref4.jwtToken,
74
+ bpeConfiguration = _ref4.bpeConfiguration,
75
+ headers = _ref4.headers;
76
+
77
+ return client({
78
+ url: "/bpe-configurations",
79
+ method: "put",
80
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
81
+ data: { bpeConfiguration: bpeConfiguration }
82
+ });
83
+ }
84
+
85
+ return {
86
+ get: get,
87
+ create: create,
88
+ update: update
89
+ };
90
+ }
91
+
92
+ module.exports = configurationFactory;
@@ -15,6 +15,8 @@ var _require = require("../endpoints_helpers.js"),
15
15
  * @property {string} [latestPurchaseDate] - ISO 8601 datetime (purchase on or before)
16
16
  * @property {string} [earliestTravelDate] - ISO 8601 datetime (trip depart on or after)
17
17
  * @property {string} [latestTravelDate] - ISO 8601 datetime (trip depart on or before)
18
+ * @property {string} [currency] - Currency ISO code (e.g. "USD"). Modifiers without a currency apply to all currencies and are always returned
19
+ * @property {string} [excludeExpired] - When "true", modifiers whose sellEndDate and/or tripEndDate is in the past are not returned
18
20
  */
19
21
 
20
22
  /**
@@ -13,6 +13,9 @@ module.exports = {
13
13
  },
14
14
  trips: function trips(url) {
15
15
  return url + "/inventory";
16
+ },
17
+ bpes: function bpes(url) {
18
+ return url + "/bpes";
16
19
  }
17
20
  }
18
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "8.73.0",
3
+ "version": "8.74.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -505,6 +505,22 @@ function createInvoices({baseURL, headers, timeout, overrideFn, internalAuthToke
505
505
  };
506
506
  }
507
507
 
508
+ /**
509
+ * Creates the BPE API client (configuration).
510
+ * @param {CreateModuleOptions} opts - Client options
511
+ * @returns {Object} Object with bpes endpoint namespaces and __test.client
512
+ */
513
+ function createBpes({baseURL, headers, timeout, overrideFn, internalAuthTokenProvider, agents}) {
514
+ const client = clientFactory({baseURL, headers, timeout, overrideFn, agents});
515
+
516
+ return {
517
+ configuration: require("./endpoints/bpes/configuration.js")({client, internalAuthTokenProvider}),
518
+ __test: {
519
+ client
520
+ }
521
+ };
522
+ }
523
+
508
524
  /**
509
525
  * Creates the GPS API client (scannerAppLocation).
510
526
  * @param {CreateModuleOptions} opts - Client options
@@ -576,6 +592,7 @@ function createApiClient(options) {
576
592
  seatmaps: createSeatmaps({baseURL, headers, timeout, overrideFn: baseURLOverride.seatmaps, internalAuthTokenProvider, agents}),
577
593
  btrzpay: createBtrzPay({baseURL, headers, timeout, overrideFn: baseURLOverride.btrzpay, internalAuthTokenProvider, agents}),
578
594
  invoices: createInvoices({baseURL, headers, timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider, agents}),
595
+ bpes: createBpes({baseURL, headers, timeout, overrideFn: baseURLOverride.bpes, internalAuthTokenProvider, agents}),
579
596
  gps: createGPS({baseURL, headers, timeout, overrideFn: baseURLOverride.invoices, internalAuthTokenProvider, agents}),
580
597
  ratality: createRatality({baseURL, headers, timeout, overrideFn: baseURLOverride.ratality, agents})
581
598
  };
@@ -0,0 +1,70 @@
1
+ const {authorizationHeaders} = require("../endpoints_helpers.js");
2
+
3
+ /**
4
+ * Factory for BPE configuration API (btrz-api-bpes).
5
+ * @param {Object} deps
6
+ * @param {import("axios").AxiosInstance} deps.client
7
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
8
+ * @returns {{ get: function, create: function, update: function }}
9
+ */
10
+ function configurationFactory({client, internalAuthTokenProvider}) {
11
+ /**
12
+ * GET /bpe-configurations - returns the BPE configuration for the authenticated account.
13
+ * @param {Object} opts
14
+ * @param {string} [opts.token] - API key
15
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
16
+ * @param {Object} [opts.headers] - Optional headers
17
+ * @returns {Promise<import("axios").AxiosResponse<{ bpeConfiguration: Object }>>}
18
+ */
19
+ function get({token, jwtToken, headers}) {
20
+ return client({
21
+ url: "/bpe-configurations",
22
+ method: "get",
23
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
24
+ });
25
+ }
26
+
27
+ /**
28
+ * POST /bpe-configurations - creates the BPE configuration for the authenticated account.
29
+ * @param {Object} opts
30
+ * @param {string} [opts.token] - API key
31
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
32
+ * @param {Object} opts.bpeConfiguration - Configuration payload
33
+ * @param {Object} [opts.headers] - Optional headers
34
+ * @returns {Promise<import("axios").AxiosResponse<{ bpeConfiguration: Object }>>}
35
+ */
36
+ function create({token, jwtToken, bpeConfiguration, headers}) {
37
+ return client({
38
+ url: "/bpe-configurations",
39
+ method: "post",
40
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
41
+ data: {bpeConfiguration}
42
+ });
43
+ }
44
+
45
+ /**
46
+ * PUT /bpe-configurations - updates the BPE configuration for the authenticated account.
47
+ * @param {Object} opts
48
+ * @param {string} [opts.token] - API key
49
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
50
+ * @param {Object} opts.bpeConfiguration - Configuration payload
51
+ * @param {Object} [opts.headers] - Optional headers
52
+ * @returns {Promise<import("axios").AxiosResponse<{ bpeConfiguration: Object }>>}
53
+ */
54
+ function update({token, jwtToken, bpeConfiguration, headers}) {
55
+ return client({
56
+ url: "/bpe-configurations",
57
+ method: "put",
58
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
59
+ data: {bpeConfiguration}
60
+ });
61
+ }
62
+
63
+ return {
64
+ get,
65
+ create,
66
+ update
67
+ };
68
+ }
69
+
70
+ module.exports = configurationFactory;
@@ -14,6 +14,8 @@ const {
14
14
  * @property {string} [latestPurchaseDate] - ISO 8601 datetime (purchase on or before)
15
15
  * @property {string} [earliestTravelDate] - ISO 8601 datetime (trip depart on or after)
16
16
  * @property {string} [latestTravelDate] - ISO 8601 datetime (trip depart on or before)
17
+ * @property {string} [currency] - Currency ISO code (e.g. "USD"). Modifiers without a currency apply to all currencies and are always returned
18
+ * @property {string} [excludeExpired] - When "true", modifiers whose sellEndDate and/or tripEndDate is in the past are not returned
17
19
  */
18
20
 
19
21
  /**
@@ -11,6 +11,9 @@ module.exports = {
11
11
  },
12
12
  trips: (url) => {
13
13
  return `${url}/inventory`;
14
+ },
15
+ bpes: (url) => {
16
+ return `${url}/bpes`;
14
17
  }
15
18
  }
16
19
  };
package/test/all.test.js CHANGED
@@ -149,6 +149,7 @@ require("./endpoints/invoices/invoices.test.js");
149
149
  require("./endpoints/invoices/providers.test.js");
150
150
  require("./endpoints/invoices/providersSequences.test.js");
151
151
  require("./endpoints/invoices/system.test.js");
152
+ require("./endpoints/bpes/configuration.test.js");
152
153
  require("./endpoints/loyalty/movements.test.js");
153
154
  require("./endpoints/loyalty/programs.test.js");
154
155
  require("./endpoints/notifications/customers.test.js");
@@ -0,0 +1,38 @@
1
+ const {axiosMock, expectRequest} = require("../../test-helpers.js");
2
+ const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
+
4
+ describe("bpes/configuration", () => {
5
+ const token = "I owe you a token";
6
+ const jwtToken = "I owe you a JWT token";
7
+
8
+ afterEach(() => {
9
+ axiosMock.restore();
10
+ });
11
+
12
+ it("should get the BPE configuration", () => {
13
+ axiosMock.onGet("/bpe-configurations").reply(expectRequest({statusCode: 200, token, jwtToken}));
14
+ return api.bpes.configuration.get({token, jwtToken});
15
+ });
16
+
17
+ it("should create the BPE configuration", () => {
18
+ axiosMock.onPost("/bpe-configurations").reply(expectRequest({statusCode: 200, token, jwtToken}));
19
+ return api.bpes.configuration.create({
20
+ token,
21
+ jwtToken,
22
+ bpeConfiguration: {
23
+ companyIdentificator: "00000000-0000-0000-0000-000000000000"
24
+ }
25
+ });
26
+ });
27
+
28
+ it("should update the BPE configuration", () => {
29
+ axiosMock.onPut("/bpe-configurations").reply(expectRequest({statusCode: 200, token, jwtToken}));
30
+ return api.bpes.configuration.update({
31
+ token,
32
+ jwtToken,
33
+ bpeConfiguration: {
34
+ companyIdentificator: "00000000-0000-0000-0000-000000000001"
35
+ }
36
+ });
37
+ });
38
+ });
package/types/client.d.ts CHANGED
@@ -93,6 +93,7 @@ export function createApiClient(options: {
93
93
  seatmaps: any;
94
94
  btrzpay: any;
95
95
  invoices: any;
96
+ bpes: any;
96
97
  gps: any;
97
98
  ratality: any;
98
99
  };
@@ -0,0 +1,18 @@
1
+ export = configurationFactory;
2
+ /**
3
+ * Factory for BPE configuration API (btrz-api-bpes).
4
+ * @param {Object} deps
5
+ * @param {import("axios").AxiosInstance} deps.client
6
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
7
+ * @returns {{ get: function, create: function, update: function }}
8
+ */
9
+ declare function configurationFactory({ client }: {
10
+ client: import("axios").AxiosInstance;
11
+ internalAuthTokenProvider?: {
12
+ getToken: () => string;
13
+ };
14
+ }): {
15
+ get: Function;
16
+ create: Function;
17
+ update: Function;
18
+ };
@@ -16,6 +16,7 @@ declare const _exports: {
16
16
  seatmaps: any;
17
17
  btrzpay: any;
18
18
  invoices: any;
19
+ bpes: any;
19
20
  gps: any;
20
21
  ratality: any;
21
22
  };
@@ -4,6 +4,7 @@ declare const _exports: {
4
4
  baseURLOverride: {
5
5
  inventory: (arg0: string) => string;
6
6
  trips: (arg0: string) => string;
7
+ bpes: (arg0: string) => string;
7
8
  };
8
9
  };
9
10
  export = _exports;