btrz-api-client 5.228.0 → 5.229.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
@@ -350,6 +350,7 @@ function createNotifications(_ref8) {
350
350
  email: require("./endpoints/notifications/email.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
351
351
  customers: require("./endpoints/notifications/customers.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
352
352
  twilio: require("./endpoints/notifications/twilio.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
353
+ notify: require("./endpoints/notifications/notify-tickets.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
353
354
  ordersRulesValidations: require("./endpoints/notifications/orders-rules-validations.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
354
355
  __test: {
355
356
  client: client
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _require = require("./../endpoints_helpers.js"),
4
+ authorizationHeaders = _require.authorizationHeaders;
5
+
6
+ function notifyTicketFactory(_ref) {
7
+ var client = _ref.client,
8
+ internalAuthTokenProvider = _ref.internalAuthTokenProvider;
9
+
10
+ return {
11
+ tickets: {
12
+ create: function create(_ref2) {
13
+ var token = _ref2.token,
14
+ jwtToken = _ref2.jwtToken,
15
+ query = _ref2.query,
16
+ operation = _ref2.operation,
17
+ to = _ref2.to,
18
+ ticketId = _ref2.ticketId,
19
+ headers = _ref2.headers;
20
+
21
+ return client({
22
+ url: "/notify-tickets/" + ticketId,
23
+ method: "post",
24
+ params: query,
25
+ data: {
26
+ to: to,
27
+ operation: operation
28
+ },
29
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
30
+ });
31
+ }
32
+ }
33
+ };
34
+ }
35
+
36
+ module.exports = notifyTicketFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "5.228.0",
3
+ "version": "5.229.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -288,6 +288,7 @@ function createNotifications({baseURL, headers, timeout, overrideFn, internalAut
288
288
  email: require("./endpoints/notifications/email.js")({client, internalAuthTokenProvider}),
289
289
  customers: require("./endpoints/notifications/customers.js")({client, internalAuthTokenProvider}),
290
290
  twilio: require("./endpoints/notifications/twilio.js")({client, internalAuthTokenProvider}),
291
+ notify: require("./endpoints/notifications/notify-tickets.js")({client, internalAuthTokenProvider}),
291
292
  ordersRulesValidations: require("./endpoints/notifications/orders-rules-validations.js")({client, internalAuthTokenProvider}),
292
293
  __test: {
293
294
  client
@@ -0,0 +1,26 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("./../endpoints_helpers.js");
4
+
5
+ function notifyTicketFactory({
6
+ client, internalAuthTokenProvider
7
+ }) {
8
+ return {
9
+ tickets: {
10
+ create({token, jwtToken, query, operation, to, ticketId, headers}) {
11
+ return client({
12
+ url: `/notify-tickets/${ticketId}`,
13
+ method: "post",
14
+ params: query,
15
+ data: {
16
+ to,
17
+ operation
18
+ },
19
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
20
+ });
21
+ }
22
+ }
23
+ };
24
+ }
25
+
26
+ module.exports = notifyTicketFactory;
@@ -0,0 +1,32 @@
1
+ const {axiosMock} = require("./../../test-helpers.js");
2
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
+
4
+ describe("notifications/notify-tickets", () => {
5
+ const token = "my-api-key";
6
+ const jwtToken = "my-jwt";
7
+
8
+ afterEach(() => {
9
+ axiosMock.reset();
10
+ });
11
+
12
+ it("should post send an email", () => {
13
+ const query = {
14
+ lang: "en"
15
+ };
16
+ const ticketId = "XHC";
17
+ axiosMock.onPost(`/notify-tickets/${ticketId}`).reply(({headers}) => {
18
+ if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
19
+ return [200];
20
+ }
21
+ return [403];
22
+ });
23
+ return api.notifications.notify.tickets.create({
24
+ token,
25
+ jwtToken,
26
+ query,
27
+ operation: "movement",
28
+ to: "info@betterez.com",
29
+ ticketId
30
+ });
31
+ });
32
+ });
package/types/client.d.ts CHANGED
@@ -4025,6 +4025,19 @@ export function createApiClient(options: {
4025
4025
  }): any;
4026
4026
  };
4027
4027
  };
4028
+ notify: {
4029
+ tickets: {
4030
+ create({ token, jwtToken, query, operation, to, ticketId, headers }: {
4031
+ token: any;
4032
+ jwtToken: any;
4033
+ query: any;
4034
+ operation: any;
4035
+ to: any;
4036
+ ticketId: any;
4037
+ headers: any;
4038
+ }): any;
4039
+ };
4040
+ };
4028
4041
  ordersRulesValidations: {
4029
4042
  create: ({ token, jwtToken, query, orderRulesValidation, headers }: {
4030
4043
  token: any;
@@ -0,0 +1,17 @@
1
+ export = notifyTicketFactory;
2
+ declare function notifyTicketFactory({ client, internalAuthTokenProvider }: {
3
+ client: any;
4
+ internalAuthTokenProvider: any;
5
+ }): {
6
+ tickets: {
7
+ create({ token, jwtToken, query, operation, to, ticketId, headers }: {
8
+ token: any;
9
+ jwtToken: any;
10
+ query: any;
11
+ operation: any;
12
+ to: any;
13
+ ticketId: any;
14
+ headers: any;
15
+ }): any;
16
+ };
17
+ };
@@ -3979,6 +3979,19 @@ declare const _exports: {
3979
3979
  }): any;
3980
3980
  };
3981
3981
  };
3982
+ notify: {
3983
+ tickets: {
3984
+ create({ token, jwtToken, query, operation, to, ticketId, headers }: {
3985
+ token: any;
3986
+ jwtToken: any;
3987
+ query: any;
3988
+ operation: any;
3989
+ to: any;
3990
+ ticketId: any;
3991
+ headers: any;
3992
+ }): any;
3993
+ };
3994
+ };
3982
3995
  ordersRulesValidations: {
3983
3996
  create: ({ token, jwtToken, query, orderRulesValidation, headers }: {
3984
3997
  token: any;