btrz-api-client 7.34.0 → 8.1.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.
@@ -8,36 +8,55 @@ function notifyTicketFactory(_ref) {
8
8
  internalAuthTokenProvider = _ref.internalAuthTokenProvider;
9
9
 
10
10
  return {
11
- tickets: {
11
+ childUsers: {
12
12
  create: function create(_ref2) {
13
13
  var token = _ref2.token,
14
14
  jwtToken = _ref2.jwtToken,
15
- query = _ref2.query,
16
- operation = _ref2.operation,
17
- to = _ref2.to,
18
- ticketId = _ref2.ticketId,
15
+ email = _ref2.email,
16
+ lang = _ref2.lang,
19
17
  headers = _ref2.headers;
20
18
 
21
19
  return client({
22
- url: "/notify-tickets/" + ticketId,
20
+ url: "/notify-child-user",
23
21
  method: "post",
24
- params: query,
25
22
  data: {
26
- to: to,
27
- operation: operation
23
+ email: email,
24
+ lang: lang
28
25
  },
29
26
  headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
30
27
  });
31
28
  }
32
29
  },
33
- vouchers: {
30
+ tickets: {
34
31
  create: function create(_ref3) {
35
32
  var token = _ref3.token,
36
33
  jwtToken = _ref3.jwtToken,
37
34
  query = _ref3.query,
38
- data = _ref3.data,
35
+ operation = _ref3.operation,
36
+ to = _ref3.to,
37
+ ticketId = _ref3.ticketId,
39
38
  headers = _ref3.headers;
40
39
 
40
+ return client({
41
+ url: "/notify-tickets/" + ticketId,
42
+ method: "post",
43
+ params: query,
44
+ data: {
45
+ to: to,
46
+ operation: operation
47
+ },
48
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
49
+ });
50
+ }
51
+ },
52
+ vouchers: {
53
+ create: function create(_ref4) {
54
+ var token = _ref4.token,
55
+ jwtToken = _ref4.jwtToken,
56
+ query = _ref4.query,
57
+ data = _ref4.data,
58
+ headers = _ref4.headers;
59
+
41
60
  return client({
42
61
  url: "/notify-vouchers",
43
62
  method: "post",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _require = require("./../endpoints_helpers"),
3
+ var _require = require("./../endpoints_helpers.js"),
4
4
  authorizationHeaders = _require.authorizationHeaders;
5
5
 
6
6
  function transactionsFactory(_ref) {
@@ -75,8 +75,7 @@ function transactionsFactory(_ref) {
75
75
  }
76
76
 
77
77
  function expireAll(_ref7) {
78
- var internalAuthTokenProvider = _ref7.internalAuthTokenProvider,
79
- jwtToken = _ref7.jwtToken,
78
+ var jwtToken = _ref7.jwtToken,
80
79
  transactionId = _ref7.transactionId,
81
80
  avoidEmail = _ref7.avoidEmail,
82
81
  token = _ref7.token,
@@ -108,7 +107,7 @@ function transactionsFactory(_ref) {
108
107
  return client({
109
108
  url: "/transactions/" + transactionId + "/cancellable-items",
110
109
  params: {
111
- displayAll: displayAll ? true : false,
110
+ displayAll: !!displayAll,
112
111
  channel: channel || ""
113
112
  },
114
113
  headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "7.34.0",
3
+ "version": "8.1.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,6 +6,19 @@ function notifyTicketFactory({
6
6
  client, internalAuthTokenProvider
7
7
  }) {
8
8
  return {
9
+ childUsers: {
10
+ create({token, jwtToken, email, lang, headers}) {
11
+ return client({
12
+ url: "/notify-child-user",
13
+ method: "post",
14
+ data: {
15
+ email,
16
+ lang
17
+ },
18
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
19
+ });
20
+ }
21
+ },
9
22
  tickets: {
10
23
  create({token, jwtToken, query, operation, to, ticketId, headers}) {
11
24
  return client({
@@ -1,4 +1,4 @@
1
- const {authorizationHeaders} = require("./../endpoints_helpers");
1
+ const {authorizationHeaders} = require("./../endpoints_helpers.js");
2
2
 
3
3
  function transactionsFactory({client, internalAuthTokenProvider}) {
4
4
  function get({token, jwtToken, trxId, query, headers}) {
@@ -41,7 +41,7 @@ function transactionsFactory({client, internalAuthTokenProvider}) {
41
41
  });
42
42
  }
43
43
 
44
- function expireAll({internalAuthTokenProvider, jwtToken, transactionId, avoidEmail, token, headers}) {
44
+ function expireAll({jwtToken, transactionId, avoidEmail, token, headers}) {
45
45
  return client({
46
46
  url: "/transactions/status",
47
47
  method: "patch",
@@ -61,7 +61,7 @@ function transactionsFactory({client, internalAuthTokenProvider}) {
61
61
  return client({
62
62
  url: `/transactions/${transactionId}/cancellable-items`,
63
63
  params: {
64
- displayAll: displayAll ? true : false,
64
+ displayAll: !!displayAll,
65
65
  channel: channel || ""
66
66
  },
67
67
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
@@ -50,3 +50,28 @@ describe("notifications/notify-tickets", () => {
50
50
  });
51
51
  });
52
52
  });
53
+
54
+ describe("notifications/notify-child-user", () => {
55
+ const token = "my-api-key";
56
+ const jwtToken = "my-jwt";
57
+
58
+ afterEach(() => {
59
+ axiosMock.reset();
60
+ });
61
+
62
+ it("should post send an email with child user created", () => {
63
+ axiosMock.onPost("/notify-child-user").reply(({headers}) => {
64
+ if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
65
+ return [200];
66
+ }
67
+ return [403];
68
+ });
69
+
70
+ return api.notifications.notify.childUsers.create({
71
+ token,
72
+ jwtToken,
73
+ email: "test@betterez.com",
74
+ lang: "en"
75
+ });
76
+ });
77
+ });
@@ -1,19 +1,17 @@
1
1
  /* eslint-disable prefer-arrow-callback */
2
2
  /* eslint-disable func-names */
3
3
 
4
- const {axiosMock, expectRequest} = require("./../../test-helpers");
5
- const api = require("./../../../src/client").createApiClient({baseURL: "http://test.com"});
6
-
7
- const expect = require("chai").expect;
8
-
9
4
  describe("operations/transactions", function () {
10
- const token = "validToken";
11
- const jwtToken = "validJWTtoken";
5
+ const {axiosMock, expectRequest} = require("./../../test-helpers.js");
12
6
  const internalAuthTokenProvider = {
13
7
  getToken: () => {
14
8
  return "internalToken";
15
9
  }
16
10
  };
11
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com", internalAuthTokenProvider});
12
+ const expect = require("chai").expect;
13
+ const token = "validToken";
14
+ const jwtToken = "validJWTtoken";
17
15
 
18
16
  afterEach(function () {
19
17
  axiosMock.reset();
@@ -118,7 +116,6 @@ describe("operations/transactions", function () {
118
116
  jwtToken: "internal_auth_token"
119
117
  }));
120
118
  return api.operations.transactions.expireAll({
121
- internalAuthTokenProvider,
122
119
  transactionId,
123
120
  jwtToken: "internal_auth_token"
124
121
  });
@@ -6,7 +6,7 @@ const port = process.env.OPERATIONS_API_PORT;
6
6
  const token = process.env.API_TOKEN;
7
7
  const jwtToken = process.env.JWT_TOKEN;
8
8
 
9
- const api = require("./../../../src/client").createApiClient({
9
+ const api = require("./../../../src/client.js").createApiClient({
10
10
  baseURL: `http://localhost:${port}`,
11
11
  baseURLOverride: {
12
12
  operations: (baseUrl) => {
@@ -32,12 +32,7 @@ describe("operations/transactions", function () {
32
32
  describe("expireAll", () => {
33
33
  it("should expire all", () => {
34
34
  const transactionId = "5ce2d7d4c16f0e5827069f13";
35
- const internalAuthTokenProvider = {
36
- getToken: () => {
37
- return process.env.INTERNAL_TOKEN;
38
- }
39
- };
40
- return api.operations.transactions.expireAll({jwtToken, internalAuthTokenProvider, transactionId})
35
+ return api.operations.transactions.expireAll({jwtToken, transactionId})
41
36
  .then((res) => {
42
37
  expect(res.data.transactionIds).to.have.length(1);
43
38
  });
package/types/client.d.ts CHANGED
@@ -4119,8 +4119,7 @@ export function createApiClient(options: {
4119
4119
  ticketIds: any;
4120
4120
  headers: any;
4121
4121
  }) => any;
4122
- expireAll: ({ internalAuthTokenProvider, jwtToken, transactionId, avoidEmail, token, headers }: {
4123
- internalAuthTokenProvider: any;
4122
+ expireAll: ({ jwtToken, transactionId, avoidEmail, token, headers }: {
4124
4123
  jwtToken: any;
4125
4124
  transactionId: any;
4126
4125
  avoidEmail: any;
@@ -4424,6 +4423,15 @@ export function createApiClient(options: {
4424
4423
  };
4425
4424
  };
4426
4425
  notify: {
4426
+ childUsers: {
4427
+ create({ token, jwtToken, email, lang, headers }: {
4428
+ token: any;
4429
+ jwtToken: any;
4430
+ email: any;
4431
+ lang: any;
4432
+ headers: any;
4433
+ }): any;
4434
+ };
4427
4435
  tickets: {
4428
4436
  create({ token, jwtToken, query, operation, to, ticketId, headers }: {
4429
4437
  token: any;
@@ -3,6 +3,15 @@ declare function notifyTicketFactory({ client, internalAuthTokenProvider }: {
3
3
  client: any;
4
4
  internalAuthTokenProvider: any;
5
5
  }): {
6
+ childUsers: {
7
+ create({ token, jwtToken, email, lang, headers }: {
8
+ token: any;
9
+ jwtToken: any;
10
+ email: any;
11
+ lang: any;
12
+ headers: any;
13
+ }): any;
14
+ };
6
15
  tickets: {
7
16
  create({ token, jwtToken, query, operation, to, ticketId, headers }: {
8
17
  token: any;
@@ -35,8 +35,7 @@ declare function transactionsFactory({ client, internalAuthTokenProvider }: {
35
35
  ticketIds: any;
36
36
  headers: any;
37
37
  }) => any;
38
- expireAll: ({ internalAuthTokenProvider, jwtToken, transactionId, avoidEmail, token, headers }: {
39
- internalAuthTokenProvider: any;
38
+ expireAll: ({ jwtToken, transactionId, avoidEmail, token, headers }: {
40
39
  jwtToken: any;
41
40
  transactionId: any;
42
41
  avoidEmail: any;
@@ -4073,8 +4073,7 @@ declare const _exports: {
4073
4073
  ticketIds: any;
4074
4074
  headers: any;
4075
4075
  }) => any;
4076
- expireAll: ({ internalAuthTokenProvider, jwtToken, transactionId, avoidEmail, token, headers }: {
4077
- internalAuthTokenProvider: any;
4076
+ expireAll: ({ jwtToken, transactionId, avoidEmail, token, headers }: {
4078
4077
  jwtToken: any;
4079
4078
  transactionId: any;
4080
4079
  avoidEmail: any;
@@ -4378,6 +4377,15 @@ declare const _exports: {
4378
4377
  };
4379
4378
  };
4380
4379
  notify: {
4380
+ childUsers: {
4381
+ create({ token, jwtToken, email, lang, headers }: {
4382
+ token: any;
4383
+ jwtToken: any;
4384
+ email: any;
4385
+ lang: any;
4386
+ headers: any;
4387
+ }): any;
4388
+ };
4381
4389
  tickets: {
4382
4390
  create({ token, jwtToken, query, operation, to, ticketId, headers }: {
4383
4391
  token: any;