washday-sdk 1.4.0 → 1.5.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/dist/api/index.js CHANGED
@@ -327,12 +327,16 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD') {
327
327
  this.integrations = bindMethods(this, {
328
328
  getMPConnectionStatus: integrationsEndpoints.getModule.getMPConnectionStatus,
329
329
  startMPOAuthFlow: integrationsEndpoints.postModule.startMPOAuthFlow,
330
- mercadoPago: {
331
- getDiscoverMPTerminals: integrationsEndpoints.getModule.getDiscoverMPTerminals,
332
- importMPTerminal: integrationsEndpoints.postModule.importMPTerminal,
333
- getMPTerminals: integrationsEndpoints.getModule.getMPTerminals,
334
- disconnectMP: integrationsEndpoints.postModule.disconnectMP
335
- }
330
+ });
331
+ this.integrations.mercadoPago = bindMethods(this, {
332
+ getDiscoverMPTerminals: integrationsEndpoints.getModule.getDiscoverMPTerminals,
333
+ importMPTerminal: integrationsEndpoints.postModule.importMPTerminal,
334
+ getStoredMPTerminals: integrationsEndpoints.getModule.getStoredMPTerminals,
335
+ disconnectMP: integrationsEndpoints.postModule.disconnectMP,
336
+ getMPUsersStores: integrationsEndpoints.getModule.getMPUsersStores,
337
+ importAllMPTerminals: integrationsEndpoints.postModule.importAllMPTerminals,
338
+ createMPAttempt: integrationsEndpoints.postModule.createMPAttempt,
339
+ cancelMPAttempt: integrationsEndpoints.postModule.cancelMPAttempt
336
340
  });
337
341
  };
338
342
  export default WashdayClient;
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  const BASE_ROUTER = 'api/integrations';
11
+ const BASE_ROUTER_MP = 'api/mercadopago';
11
12
  export const getMPConnectionStatus = function () {
12
13
  return __awaiter(this, void 0, void 0, function* () {
13
14
  try {
@@ -34,7 +35,7 @@ export const getDiscoverMPTerminals = function (_a) {
34
35
  }
35
36
  });
36
37
  };
37
- export const getMPTerminals = function (_a) {
38
+ export const getStoredMPTerminals = function (_a) {
38
39
  return __awaiter(this, arguments, void 0, function* ({ storeId }) {
39
40
  try {
40
41
  const config = {
@@ -47,3 +48,16 @@ export const getMPTerminals = function (_a) {
47
48
  }
48
49
  });
49
50
  };
51
+ export const getMPUsersStores = function (_a) {
52
+ return __awaiter(this, arguments, void 0, function* ({ user_id }) {
53
+ try {
54
+ const config = {
55
+ headers: { Authorization: `Bearer ${this.apiToken}` }
56
+ };
57
+ return yield this.axiosInstance.get(`${BASE_ROUTER_MP}/users/stores?user_id=${user_id}`, config);
58
+ }
59
+ catch (error) {
60
+ throw error;
61
+ }
62
+ });
63
+ };
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  const BASE_ROUTER = 'api/integrations';
11
+ const BASE_ROUTER_MP_ATTEMPTS = 'api/mercadopago/attempts';
11
12
  export const startMPOAuthFlow = function (data) {
12
13
  return __awaiter(this, void 0, void 0, function* () {
13
14
  try {
@@ -53,3 +54,43 @@ export const importMPTerminal = function (data) {
53
54
  }
54
55
  });
55
56
  };
57
+ export const importAllMPTerminals = function (data) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ try {
60
+ const config = {
61
+ headers: { Authorization: `Bearer ${this.apiToken}` }
62
+ };
63
+ console.log('from washday-sdk importAllMPTerminals body', data);
64
+ return yield this.axiosInstance.post(`${BASE_ROUTER}/mp/terminals/importAll`, data, config);
65
+ }
66
+ catch (error) {
67
+ throw error;
68
+ }
69
+ });
70
+ };
71
+ export const createMPAttempt = function (data) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ try {
74
+ const config = {
75
+ headers: { Authorization: `Bearer ${this.apiToken}` }
76
+ };
77
+ return yield this.axiosInstance.post(`${BASE_ROUTER_MP_ATTEMPTS}`, data, config);
78
+ }
79
+ catch (error) {
80
+ throw error;
81
+ }
82
+ });
83
+ };
84
+ export const cancelMPAttempt = function (data) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ try {
87
+ const config = {
88
+ headers: { Authorization: `Bearer ${this.apiToken}` }
89
+ };
90
+ return yield this.axiosInstance.post(`${BASE_ROUTER_MP_ATTEMPTS}/${data.attemptId}/cancel`, data, config);
91
+ }
92
+ catch (error) {
93
+ throw error;
94
+ }
95
+ });
96
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/api/index.ts CHANGED
@@ -334,12 +334,16 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
334
334
  this.integrations = bindMethods(this, {
335
335
  getMPConnectionStatus: integrationsEndpoints.getModule.getMPConnectionStatus,
336
336
  startMPOAuthFlow: integrationsEndpoints.postModule.startMPOAuthFlow,
337
- mercadoPago: {
338
- getDiscoverMPTerminals: integrationsEndpoints.getModule.getDiscoverMPTerminals,
339
- importMPTerminal: integrationsEndpoints.postModule.importMPTerminal,
340
- getMPTerminals: integrationsEndpoints.getModule.getMPTerminals,
341
- disconnectMP: integrationsEndpoints.postModule.disconnectMP
342
- }
337
+ });
338
+ this.integrations.mercadoPago = bindMethods(this, {
339
+ getDiscoverMPTerminals: integrationsEndpoints.getModule.getDiscoverMPTerminals,
340
+ importMPTerminal: integrationsEndpoints.postModule.importMPTerminal,
341
+ getStoredMPTerminals: integrationsEndpoints.getModule.getStoredMPTerminals,
342
+ disconnectMP: integrationsEndpoints.postModule.disconnectMP,
343
+ getMPUsersStores: integrationsEndpoints.getModule.getMPUsersStores,
344
+ importAllMPTerminals: integrationsEndpoints.postModule.importAllMPTerminals,
345
+ createMPAttempt: integrationsEndpoints.postModule.createMPAttempt,
346
+ cancelMPAttempt: integrationsEndpoints.postModule.cancelMPAttempt
343
347
  });
344
348
  } as any;
345
349
 
@@ -1,6 +1,7 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
 
3
3
  const BASE_ROUTER = 'api/integrations';
4
+ const BASE_ROUTER_MP = 'api/mercadopago';
4
5
 
5
6
  export const getMPConnectionStatus = async function (this: WashdayClientInstance): Promise<any> {
6
7
  try {
@@ -30,7 +31,7 @@ export const getDiscoverMPTerminals = async function (this: WashdayClientInstanc
30
31
  }
31
32
  };
32
33
 
33
- export const getMPTerminals = async function (this: WashdayClientInstance, {
34
+ export const getStoredMPTerminals = async function (this: WashdayClientInstance, {
34
35
  storeId
35
36
  }: {
36
37
  storeId: string;
@@ -45,3 +46,20 @@ export const getMPTerminals = async function (this: WashdayClientInstance, {
45
46
  throw error;
46
47
  }
47
48
  };
49
+
50
+
51
+ export const getMPUsersStores = async function (this: WashdayClientInstance, {
52
+ user_id
53
+ }: {
54
+ user_id: string;
55
+ }): Promise<any> {
56
+ try {
57
+ const config = {
58
+ headers: { Authorization: `Bearer ${this.apiToken}` }
59
+ };
60
+ return await this.axiosInstance.get(`${BASE_ROUTER_MP}/users/stores?user_id=${user_id}`, config);
61
+ }
62
+ catch (error) {
63
+ throw error;
64
+ }
65
+ };
@@ -1,7 +1,7 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
 
3
3
  const BASE_ROUTER = 'api/integrations';
4
-
4
+ const BASE_ROUTER_MP_ATTEMPTS = 'api/mercadopago/attempts';
5
5
 
6
6
  export const startMPOAuthFlow = async function (this: WashdayClientInstance, data: {
7
7
  redirectUri: string;
@@ -50,4 +50,52 @@ export const importMPTerminal = async function (this: WashdayClientInstance, dat
50
50
  catch (error) {
51
51
  throw error;
52
52
  }
53
+ };
54
+
55
+ export const importAllMPTerminals = async function (this: WashdayClientInstance, data: {
56
+ storeId: string;
57
+ }): Promise<any> {
58
+ try {
59
+ const config = {
60
+ headers: { Authorization: `Bearer ${this.apiToken}` }
61
+ };
62
+ console.log('from washday-sdk importAllMPTerminals body', data);
63
+ return await this.axiosInstance.post(`${BASE_ROUTER}/mp/terminals/importAll`, data, config);
64
+ }
65
+ catch (error) {
66
+ throw error;
67
+ }
68
+ };
69
+
70
+ export const createMPAttempt = async function (this: WashdayClientInstance, data: {
71
+ orderId: string;
72
+ amount: number;
73
+ currency: string;
74
+ storeId: string;
75
+ terminalId: string;
76
+ cashierBoxId: string;
77
+ }): Promise<any> {
78
+ try {
79
+ const config = {
80
+ headers: { Authorization: `Bearer ${this.apiToken}` }
81
+ };
82
+ return await this.axiosInstance.post(`${BASE_ROUTER_MP_ATTEMPTS}`, data, config);
83
+ }
84
+ catch (error) {
85
+ throw error;
86
+ }
87
+ };
88
+
89
+ export const cancelMPAttempt = async function (this: WashdayClientInstance, data: {
90
+ attemptId: string;
91
+ }): Promise<any> {
92
+ try {
93
+ const config = {
94
+ headers: { Authorization: `Bearer ${this.apiToken}` }
95
+ };
96
+ return await this.axiosInstance.post(`${BASE_ROUTER_MP_ATTEMPTS}/${data.attemptId}/cancel`, data, config);
97
+ }
98
+ catch (error) {
99
+ throw error;
100
+ }
53
101
  };
@@ -320,8 +320,12 @@ export interface WashdayClientInstance {
320
320
  mercadoPago: {
321
321
  getDiscoverMPTerminals: typeof integrationsEndpoints.getModule.getDiscoverMPTerminals;
322
322
  importMPTerminal: typeof integrationsEndpoints.postModule.importMPTerminal;
323
- getMPTerminals: typeof integrationsEndpoints.getModule.getMPTerminals;
323
+ getStoredMPTerminals: typeof integrationsEndpoints.getModule.getStoredMPTerminals;
324
324
  disconnectMP: typeof integrationsEndpoints.postModule.disconnectMP;
325
+ getMPUsersStores: typeof integrationsEndpoints.getModule.getMPUsersStores;
326
+ importAllMPTerminals: typeof integrationsEndpoints.postModule.importAllMPTerminals;
327
+ createMPAttempt: typeof integrationsEndpoints.postModule.createMPAttempt;
328
+ cancelMPAttempt: typeof integrationsEndpoints.postModule.cancelMPAttempt;
325
329
  }
326
330
  };
327
331
  }