washday-sdk 1.2.1 → 1.4.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 +11 -0
- package/dist/api/integrations/delete.js +1 -0
- package/dist/api/integrations/get.js +49 -0
- package/dist/api/integrations/index.js +3 -0
- package/dist/api/integrations/post.js +55 -0
- package/dist/api/integrations/put.js +1 -0
- package/package.json +1 -1
- package/src/api/index.ts +13 -1
- package/src/api/integrations/delete.ts +0 -0
- package/src/api/integrations/get.ts +47 -0
- package/src/api/integrations/index.ts +3 -0
- package/src/api/integrations/post.ts +53 -0
- package/src/api/integrations/put.ts +0 -0
- package/src/interfaces/Api.ts +11 -0
package/dist/api/index.js
CHANGED
|
@@ -42,6 +42,7 @@ import * as outsourcedOrdersEndpoints from './outsourcedOrders';
|
|
|
42
42
|
import * as publicsEndpoints from './publics';
|
|
43
43
|
import { validateUserPin } from "./users/post";
|
|
44
44
|
import { getAxiosInstance } from "./axiosInstance";
|
|
45
|
+
import * as integrationsEndpoints from './integrations';
|
|
45
46
|
function bindMethods(instance, methods) {
|
|
46
47
|
const boundMethods = {};
|
|
47
48
|
for (const key in methods) {
|
|
@@ -323,5 +324,15 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD') {
|
|
|
323
324
|
clockOut: attendanceEndpoints.postModule.clockOut,
|
|
324
325
|
updateById: attendanceEndpoints.putModule.updateById,
|
|
325
326
|
});
|
|
327
|
+
this.integrations = bindMethods(this, {
|
|
328
|
+
getMPConnectionStatus: integrationsEndpoints.getModule.getMPConnectionStatus,
|
|
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
|
+
}
|
|
336
|
+
});
|
|
326
337
|
};
|
|
327
338
|
export default WashdayClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const BASE_ROUTER = 'api/integrations';
|
|
11
|
+
export const getMPConnectionStatus = function () {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
return yield this.axiosInstance.get(`${BASE_ROUTER}/mp/connection`, config);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export const getDiscoverMPTerminals = function (_a) {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* ({ mp_store_id }) {
|
|
26
|
+
try {
|
|
27
|
+
const config = {
|
|
28
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
29
|
+
};
|
|
30
|
+
return yield this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals/discover?mp_store_id=${mp_store_id}`, config);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export const getMPTerminals = function (_a) {
|
|
38
|
+
return __awaiter(this, arguments, void 0, function* ({ storeId }) {
|
|
39
|
+
try {
|
|
40
|
+
const config = {
|
|
41
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
42
|
+
};
|
|
43
|
+
return yield this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals?storeId=${storeId}`, config);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const BASE_ROUTER = 'api/integrations';
|
|
11
|
+
export const startMPOAuthFlow = function (data) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
return yield this.axiosInstance.post(`${BASE_ROUTER}/mp/oauth/start`, data, config);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export const disconnectMP = function () {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const config = {
|
|
28
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
29
|
+
};
|
|
30
|
+
return yield this.axiosInstance.post(`${BASE_ROUTER}/mp/disconnect`, {}, config);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -44,6 +44,8 @@ import * as outsourcedOrdersEndpoints from './outsourcedOrders';
|
|
|
44
44
|
import * as publicsEndpoints from './publics';
|
|
45
45
|
import { validateUserPin } from "./users/post";
|
|
46
46
|
import { getAxiosInstance } from "./axiosInstance";
|
|
47
|
+
import * as integrationsEndpoints from './integrations';
|
|
48
|
+
|
|
47
49
|
type WashdayClientConstructor = {
|
|
48
50
|
new(apiToken: string): WashdayClientInstance
|
|
49
51
|
};
|
|
@@ -57,7 +59,7 @@ function bindMethods<T>(instance: any, methods: any): T {
|
|
|
57
59
|
return boundMethods;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string, env:string = 'PROD') {
|
|
62
|
+
const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string, env: string = 'PROD') {
|
|
61
63
|
this.apiToken = apiToken;
|
|
62
64
|
this.env = env;
|
|
63
65
|
this.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env);
|
|
@@ -329,6 +331,16 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
329
331
|
clockOut: attendanceEndpoints.postModule.clockOut,
|
|
330
332
|
updateById: attendanceEndpoints.putModule.updateById,
|
|
331
333
|
});
|
|
334
|
+
this.integrations = bindMethods(this, {
|
|
335
|
+
getMPConnectionStatus: integrationsEndpoints.getModule.getMPConnectionStatus,
|
|
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
|
+
}
|
|
343
|
+
});
|
|
332
344
|
} as any;
|
|
333
345
|
|
|
334
346
|
export default WashdayClient;
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
|
|
3
|
+
const BASE_ROUTER = 'api/integrations';
|
|
4
|
+
|
|
5
|
+
export const getMPConnectionStatus = async function (this: WashdayClientInstance): Promise<any> {
|
|
6
|
+
try {
|
|
7
|
+
const config = {
|
|
8
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
9
|
+
};
|
|
10
|
+
return await this.axiosInstance.get(`${BASE_ROUTER}/mp/connection`, config);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getDiscoverMPTerminals = async function (this: WashdayClientInstance, {
|
|
18
|
+
mp_store_id
|
|
19
|
+
}: {
|
|
20
|
+
mp_store_id: string;
|
|
21
|
+
}): Promise<any> {
|
|
22
|
+
try {
|
|
23
|
+
const config = {
|
|
24
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
25
|
+
};
|
|
26
|
+
return await this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals/discover?mp_store_id=${mp_store_id}`, config);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const getMPTerminals = async function (this: WashdayClientInstance, {
|
|
34
|
+
storeId
|
|
35
|
+
}: {
|
|
36
|
+
storeId: string;
|
|
37
|
+
}): Promise<any> {
|
|
38
|
+
try {
|
|
39
|
+
const config = {
|
|
40
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
41
|
+
};
|
|
42
|
+
return await this.axiosInstance.get(`${BASE_ROUTER}/mp/terminals?storeId=${storeId}`, config);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
|
|
3
|
+
const BASE_ROUTER = 'api/integrations';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const startMPOAuthFlow = async function (this: WashdayClientInstance, data: {
|
|
7
|
+
redirectUri: string;
|
|
8
|
+
}): Promise<any> {
|
|
9
|
+
try {
|
|
10
|
+
const config = {
|
|
11
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
12
|
+
};
|
|
13
|
+
return await this.axiosInstance.post(`${BASE_ROUTER}/mp/oauth/start`, data, config);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const disconnectMP = async function (this: WashdayClientInstance): Promise<any> {
|
|
21
|
+
try {
|
|
22
|
+
const config = {
|
|
23
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
24
|
+
};
|
|
25
|
+
return await this.axiosInstance.post(`${BASE_ROUTER}/mp/disconnect`, {}, config);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw error;
|
|
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
|
+
};
|
|
File without changes
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { deleteUserById } from "../api/users/delete";
|
|
|
40
40
|
import * as partnersEndpoints from '../api/partners';
|
|
41
41
|
import * as outsourcedOrdersEndpoints from '../api/outsourcedOrders';
|
|
42
42
|
import * as publicsEndpoints from '../api/publics';
|
|
43
|
+
import * as integrationsEndpoints from '../api/integrations';
|
|
43
44
|
import { validateUserPin } from "../api/users/post";
|
|
44
45
|
import { AxiosInstance } from "axios";
|
|
45
46
|
|
|
@@ -313,4 +314,14 @@ export interface WashdayClientInstance {
|
|
|
313
314
|
clockOut: typeof attendanceEndpoints.postModule.clockOut;
|
|
314
315
|
updateById: typeof attendanceEndpoints.putModule.updateById;
|
|
315
316
|
};
|
|
317
|
+
integrations: {
|
|
318
|
+
getMPConnectionStatus: typeof integrationsEndpoints.getModule.getMPConnectionStatus;
|
|
319
|
+
startMPOAuthFlow: typeof integrationsEndpoints.postModule.startMPOAuthFlow;
|
|
320
|
+
mercadoPago: {
|
|
321
|
+
getDiscoverMPTerminals: typeof integrationsEndpoints.getModule.getDiscoverMPTerminals;
|
|
322
|
+
importMPTerminal: typeof integrationsEndpoints.postModule.importMPTerminal;
|
|
323
|
+
getMPTerminals: typeof integrationsEndpoints.getModule.getMPTerminals;
|
|
324
|
+
disconnectMP: typeof integrationsEndpoints.postModule.disconnectMP;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
316
327
|
}
|