washday-sdk 1.3.0 → 1.4.2

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,7 +327,14 @@ 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
+ });
331
+ this.integrations.mercadoPago = bindMethods(this, {
332
+ getDiscoverMPTerminals: integrationsEndpoints.getModule.getDiscoverMPTerminals,
333
+ importMPTerminal: integrationsEndpoints.postModule.importMPTerminal,
334
+ getStoredMPTerminals: integrationsEndpoints.getModule.getStoredMPTerminals,
330
335
  disconnectMP: integrationsEndpoints.postModule.disconnectMP,
336
+ getMPUsersStores: integrationsEndpoints.getModule.getMPUsersStores,
337
+ importAllMPTerminals: integrationsEndpoints.postModule.importAllMPTerminals
331
338
  });
332
339
  };
333
340
  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 {
@@ -21,3 +22,42 @@ export const getMPConnectionStatus = function () {
21
22
  }
22
23
  });
23
24
  };
25
+ export const getDiscoverMPTerminals = function (_a) {
26
+ return __awaiter(this, arguments, void 0, function* ({ mp_store_id }) {
27
+ try {
28
+ const config = {
29
+ headers: { Authorization: `Bearer ${this.apiToken}` }
30
+ };
31
+ return yield this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals/discover?mp_store_id=${mp_store_id}`, config);
32
+ }
33
+ catch (error) {
34
+ throw error;
35
+ }
36
+ });
37
+ };
38
+ export const getStoredMPTerminals = function (_a) {
39
+ return __awaiter(this, arguments, void 0, function* ({ storeId }) {
40
+ try {
41
+ const config = {
42
+ headers: { Authorization: `Bearer ${this.apiToken}` }
43
+ };
44
+ return yield this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals?storeId=${storeId}`, config);
45
+ }
46
+ catch (error) {
47
+ throw error;
48
+ }
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
+ };
@@ -34,3 +34,36 @@ export const disconnectMP = function () {
34
34
  }
35
35
  });
36
36
  };
37
+ export const importMPTerminal = function (data) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ try {
40
+ if (!data.storeId) {
41
+ throw new Error('storeId is required');
42
+ }
43
+ if (!data.mp_pos_id) {
44
+ throw new Error('mp_pos_id is required');
45
+ }
46
+ const config = {
47
+ headers: { Authorization: `Bearer ${this.apiToken}` }
48
+ };
49
+ return yield this.axiosInstance.post(`${BASE_ROUTER}/mp/terminals/import`, data, config);
50
+ }
51
+ catch (error) {
52
+ throw error;
53
+ }
54
+ });
55
+ };
56
+ export const importAllMPTerminals = function (data) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ try {
59
+ const config = {
60
+ headers: { Authorization: `Bearer ${this.apiToken}` }
61
+ };
62
+ console.log('from washday-sdk importAllMPTerminals body', data);
63
+ return yield this.axiosInstance.post(`${BASE_ROUTER}/mp/terminals/importAll`, data, config);
64
+ }
65
+ catch (error) {
66
+ throw error;
67
+ }
68
+ });
69
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.2",
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,7 +334,14 @@ 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
+ });
338
+ this.integrations.mercadoPago = bindMethods(this, {
339
+ getDiscoverMPTerminals: integrationsEndpoints.getModule.getDiscoverMPTerminals,
340
+ importMPTerminal: integrationsEndpoints.postModule.importMPTerminal,
341
+ getStoredMPTerminals: integrationsEndpoints.getModule.getStoredMPTerminals,
337
342
  disconnectMP: integrationsEndpoints.postModule.disconnectMP,
343
+ getMPUsersStores: integrationsEndpoints.getModule.getMPUsersStores,
344
+ importAllMPTerminals: integrationsEndpoints.postModule.importAllMPTerminals
338
345
  });
339
346
  } as any;
340
347
 
@@ -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 {
@@ -13,3 +14,52 @@ export const getMPConnectionStatus = async function (this: WashdayClientInstance
13
14
  throw error;
14
15
  }
15
16
  };
17
+
18
+ export const getDiscoverMPTerminals = async function (this: WashdayClientInstance, {
19
+ mp_store_id
20
+ }: {
21
+ mp_store_id: string;
22
+ }): Promise<any> {
23
+ try {
24
+ const config = {
25
+ headers: { Authorization: `Bearer ${this.apiToken}` }
26
+ };
27
+ return await this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals/discover?mp_store_id=${mp_store_id}`, config);
28
+ }
29
+ catch (error) {
30
+ throw error;
31
+ }
32
+ };
33
+
34
+ export const getStoredMPTerminals = async function (this: WashdayClientInstance, {
35
+ storeId
36
+ }: {
37
+ storeId: string;
38
+ }): Promise<any> {
39
+ try {
40
+ const config = {
41
+ headers: { Authorization: `Bearer ${this.apiToken}` }
42
+ };
43
+ return await this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals?storeId=${storeId}`, config);
44
+ }
45
+ catch (error) {
46
+ throw error;
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
+ };
@@ -27,4 +27,42 @@ export const disconnectMP = async function (this: WashdayClientInstance): Promis
27
27
  catch (error) {
28
28
  throw error;
29
29
  }
30
+ };
31
+
32
+ export const importMPTerminal = async function (this: WashdayClientInstance, data: {
33
+ storeId: string;
34
+ mp_pos_id: string;
35
+ label?: string;
36
+ mp_store_id?: string;
37
+ }): Promise<any> {
38
+ try {
39
+ if (!data.storeId) {
40
+ throw new Error('storeId is required');
41
+ }
42
+ if (!data.mp_pos_id) {
43
+ throw new Error('mp_pos_id is required');
44
+ }
45
+ const config = {
46
+ headers: { Authorization: `Bearer ${this.apiToken}` }
47
+ };
48
+ return await this.axiosInstance.post(`${BASE_ROUTER}/mp/terminals/import`, data, config);
49
+ }
50
+ catch (error) {
51
+ throw error;
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
+ }
30
68
  };
@@ -317,6 +317,13 @@ export interface WashdayClientInstance {
317
317
  integrations: {
318
318
  getMPConnectionStatus: typeof integrationsEndpoints.getModule.getMPConnectionStatus;
319
319
  startMPOAuthFlow: typeof integrationsEndpoints.postModule.startMPOAuthFlow;
320
- disconnectMP: typeof integrationsEndpoints.postModule.disconnectMP;
320
+ mercadoPago: {
321
+ getDiscoverMPTerminals: typeof integrationsEndpoints.getModule.getDiscoverMPTerminals;
322
+ importMPTerminal: typeof integrationsEndpoints.postModule.importMPTerminal;
323
+ getStoredMPTerminals: typeof integrationsEndpoints.getModule.getStoredMPTerminals;
324
+ disconnectMP: typeof integrationsEndpoints.postModule.disconnectMP;
325
+ getMPUsersStores: typeof integrationsEndpoints.getModule.getMPUsersStores;
326
+ importAllMPTerminals: typeof integrationsEndpoints.postModule.importAllMPTerminals;
327
+ }
321
328
  };
322
329
  }