washday-sdk 0.0.88 → 0.0.89
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/cfdi/get.js +76 -0
- package/dist/api/cfdi/post.js +15 -0
- package/dist/api/index.js +5 -0
- package/package.json +1 -1
- package/src/api/cfdi/get.ts +83 -1
- package/src/api/cfdi/post.ts +29 -1
- package/src/api/index.ts +5 -0
- package/src/interfaces/Api.ts +7 -2
package/dist/api/cfdi/get.js
CHANGED
|
@@ -7,9 +7,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
10
11
|
import axiosInstance from "../axiosInstance";
|
|
11
12
|
const GET_ORDERS_CFDI_PREVIEW = (orderID) => `api/order/${orderID}/preview/cfdi`;
|
|
12
13
|
const GET_SET_CFDI = 'api/cfdi';
|
|
14
|
+
export const getList = function (storeId, params) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
const config = {
|
|
18
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
19
|
+
};
|
|
20
|
+
const queryParams = generateQueryParamsStr([
|
|
21
|
+
'query',
|
|
22
|
+
'storeId',
|
|
23
|
+
'fromDate',
|
|
24
|
+
'toDate',
|
|
25
|
+
'limit',
|
|
26
|
+
'pageNum'
|
|
27
|
+
], params);
|
|
28
|
+
return yield axiosInstance.get(`${GET_SET_CFDI}?${queryParams}`, config);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error('Error fetching getList CFDI:', error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
13
36
|
export const getCFDIPreviewByOrderId = function (id) {
|
|
14
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
38
|
try {
|
|
@@ -24,3 +47,56 @@ export const getCFDIPreviewByOrderId = function (id) {
|
|
|
24
47
|
}
|
|
25
48
|
});
|
|
26
49
|
};
|
|
50
|
+
export const downloadCFDIPDF = function (id) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
try {
|
|
53
|
+
const config = {
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
56
|
+
'Content-Type': 'multipart/form-data',
|
|
57
|
+
'Content-disposition': 'attachment; filename=[file.pdf]',
|
|
58
|
+
},
|
|
59
|
+
params: {
|
|
60
|
+
responseType: 'arraybuffer'
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return yield axiosInstance.get(`${GET_SET_CFDI}/${id}/download/pdf`, config);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error('Error fetching exportCustomersList:', error);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export const sendCFDIByEmail = function (id) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
try {
|
|
74
|
+
const config = {
|
|
75
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
76
|
+
};
|
|
77
|
+
return yield axiosInstance.get(`${GET_SET_CFDI}/${id}/email`, config);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error('Error fetching:', error);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export const getGlobalCFDIPreview = function (params) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
try {
|
|
88
|
+
const config = {
|
|
89
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
90
|
+
};
|
|
91
|
+
const queryParams = generateQueryParamsStr([
|
|
92
|
+
'ordersID',
|
|
93
|
+
'customerId',
|
|
94
|
+
], params);
|
|
95
|
+
return yield axiosInstance.get(`${GET_SET_CFDI}/global/preview?${queryParams}`, config);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error('Error fetching:', error);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
};
|
package/dist/api/cfdi/post.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_CFDI = 'api/cfdi';
|
|
11
12
|
const GET_SET_ORDERS_CFDI = (orderID) => `api/order/${orderID}/cfdi`;
|
|
12
13
|
export const createCFDI = function (id, data) {
|
|
13
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -23,3 +24,17 @@ export const createCFDI = function (id, data) {
|
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
};
|
|
27
|
+
export const createGlobalCFDI = function (data) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const config = {
|
|
31
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
};
|
|
33
|
+
return yield axiosInstance.post(`${GET_SET_CFDI}/global`, data, config);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error fetching create:', error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
package/dist/api/index.js
CHANGED
|
@@ -49,8 +49,13 @@ const WashdayClient = function WashdayClient(apiToken) {
|
|
|
49
49
|
create: cashupsEndpoints.postModule.create
|
|
50
50
|
});
|
|
51
51
|
this.cfdi = bindMethods(this, {
|
|
52
|
+
getList: cfdiEndpoints.getModule.getList,
|
|
53
|
+
downloadCFDIPDF: cfdiEndpoints.getModule.downloadCFDIPDF,
|
|
54
|
+
sendCFDIByEmail: cfdiEndpoints.getModule.sendCFDIByEmail,
|
|
55
|
+
getGlobalCFDIPreview: cfdiEndpoints.getModule.getGlobalCFDIPreview,
|
|
52
56
|
getCFDIPreviewByOrderId: cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
|
|
53
57
|
createCFDI: cfdiEndpoints.postModule.createCFDI,
|
|
58
|
+
createGlobalCFDI: cfdiEndpoints.postModule.createGlobalCFDI
|
|
54
59
|
});
|
|
55
60
|
this.review = bindMethods(this, {
|
|
56
61
|
getList: reviewsEndpoints.getModule.getList,
|
package/package.json
CHANGED
package/src/api/cfdi/get.ts
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
2
3
|
import axiosInstance from "../axiosInstance";
|
|
3
4
|
const GET_ORDERS_CFDI_PREVIEW = (orderID: string) => `api/order/${orderID}/preview/cfdi`;
|
|
4
5
|
const GET_SET_CFDI = 'api/cfdi';
|
|
5
6
|
|
|
7
|
+
export const getList = async function (this: WashdayClientInstance, storeId: string, params: {
|
|
8
|
+
query?: string;
|
|
9
|
+
storeId?: string;
|
|
10
|
+
fromDate?: string;
|
|
11
|
+
toDate?: string;
|
|
12
|
+
limit?: string;
|
|
13
|
+
pageNum?: string;
|
|
14
|
+
}): Promise<any> {
|
|
15
|
+
try {
|
|
16
|
+
const config = {
|
|
17
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
18
|
+
};
|
|
19
|
+
const queryParams = generateQueryParamsStr([
|
|
20
|
+
'query',
|
|
21
|
+
'storeId',
|
|
22
|
+
'fromDate',
|
|
23
|
+
'toDate',
|
|
24
|
+
'limit',
|
|
25
|
+
'pageNum'
|
|
26
|
+
], params);
|
|
27
|
+
|
|
28
|
+
return await axiosInstance.get(`${GET_SET_CFDI}?${queryParams}`, config);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error fetching getList CFDI:', error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
6
35
|
export const getCFDIPreviewByOrderId = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
7
36
|
try {
|
|
8
37
|
const config = {
|
|
@@ -13,4 +42,57 @@ export const getCFDIPreviewByOrderId = async function (this: WashdayClientInstan
|
|
|
13
42
|
console.error('Error fetching:', error);
|
|
14
43
|
throw error;
|
|
15
44
|
}
|
|
16
|
-
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export const downloadCFDIPDF = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
49
|
+
try {
|
|
50
|
+
const config = {
|
|
51
|
+
headers: {
|
|
52
|
+
Authorization: `Bearer ${this.apiToken}`,
|
|
53
|
+
'Content-Type': 'multipart/form-data',
|
|
54
|
+
'Content-disposition': 'attachment; filename=[file.pdf]',
|
|
55
|
+
},
|
|
56
|
+
params: {
|
|
57
|
+
responseType: 'arraybuffer'
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return await axiosInstance.get(`${GET_SET_CFDI}/${id}/download/pdf`, config);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Error fetching exportCustomersList:', error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
export const sendCFDIByEmail = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
69
|
+
try {
|
|
70
|
+
const config = {
|
|
71
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
72
|
+
};
|
|
73
|
+
return await axiosInstance.get(`${GET_SET_CFDI}/${id}/email`, config);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('Error fetching:', error);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export const getGlobalCFDIPreview = async function (this: WashdayClientInstance, params: {
|
|
82
|
+
ordersID?: string[];
|
|
83
|
+
customerId?: string
|
|
84
|
+
}): Promise<any> {
|
|
85
|
+
try {
|
|
86
|
+
const config = {
|
|
87
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
88
|
+
};
|
|
89
|
+
const queryParams = generateQueryParamsStr([
|
|
90
|
+
'ordersID',
|
|
91
|
+
'customerId',
|
|
92
|
+
], params);
|
|
93
|
+
return await axiosInstance.get(`${GET_SET_CFDI}/global/preview?${queryParams}`, config);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('Error fetching:', error);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/api/cfdi/post.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
2
|
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CFDI = 'api/cfdi';
|
|
3
4
|
const GET_SET_ORDERS_CFDI = (orderID: string) => `api/order/${orderID}/cfdi`;
|
|
4
5
|
|
|
5
6
|
export const createCFDI = async function (this: WashdayClientInstance, id: string, data: {
|
|
@@ -7,7 +8,7 @@ export const createCFDI = async function (this: WashdayClientInstance, id: strin
|
|
|
7
8
|
payment_method: string
|
|
8
9
|
payment_form: string
|
|
9
10
|
sendEmailInvoice: boolean
|
|
10
|
-
date:
|
|
11
|
+
date: string
|
|
11
12
|
env: 'prod' | 'dev'
|
|
12
13
|
}): Promise<any> {
|
|
13
14
|
try {
|
|
@@ -20,3 +21,30 @@ export const createCFDI = async function (this: WashdayClientInstance, id: strin
|
|
|
20
21
|
throw error;
|
|
21
22
|
}
|
|
22
23
|
};
|
|
24
|
+
|
|
25
|
+
export const createGlobalCFDI = async function (this: WashdayClientInstance, data: {
|
|
26
|
+
ordersID: string[],
|
|
27
|
+
CFDIInfo: {
|
|
28
|
+
use: string
|
|
29
|
+
payment_method: string
|
|
30
|
+
payment_form: string
|
|
31
|
+
date: string
|
|
32
|
+
global: {
|
|
33
|
+
periodicity: string
|
|
34
|
+
months: string
|
|
35
|
+
year: string
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
customer?: string
|
|
39
|
+
}
|
|
40
|
+
): Promise<any> {
|
|
41
|
+
try {
|
|
42
|
+
const config = {
|
|
43
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
44
|
+
};
|
|
45
|
+
return await axiosInstance.post(`${GET_SET_CFDI}/global`, data, config);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Error fetching create:', error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
};
|
package/src/api/index.ts
CHANGED
|
@@ -55,8 +55,13 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
55
55
|
create: cashupsEndpoints.postModule.create
|
|
56
56
|
});
|
|
57
57
|
this.cfdi = bindMethods(this, {
|
|
58
|
+
getList: cfdiEndpoints.getModule.getList,
|
|
59
|
+
downloadCFDIPDF: cfdiEndpoints.getModule.downloadCFDIPDF,
|
|
60
|
+
sendCFDIByEmail: cfdiEndpoints.getModule.sendCFDIByEmail,
|
|
61
|
+
getGlobalCFDIPreview: cfdiEndpoints.getModule.getGlobalCFDIPreview,
|
|
58
62
|
getCFDIPreviewByOrderId: cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
|
|
59
63
|
createCFDI: cfdiEndpoints.postModule.createCFDI,
|
|
64
|
+
createGlobalCFDI: cfdiEndpoints.postModule.createGlobalCFDI
|
|
60
65
|
});
|
|
61
66
|
this.review = bindMethods(this, {
|
|
62
67
|
getList: reviewsEndpoints.getModule.getList,
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -41,8 +41,13 @@ export interface WashdayClientInstance {
|
|
|
41
41
|
create: typeof cashupsEndpoints.postModule.create
|
|
42
42
|
}
|
|
43
43
|
cfdi: {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
getList: typeof cfdiEndpoints.getModule.getList,
|
|
45
|
+
downloadCFDIPDF: typeof cfdiEndpoints.getModule.downloadCFDIPDF,
|
|
46
|
+
sendCFDIByEmail: typeof cfdiEndpoints.getModule.sendCFDIByEmail,
|
|
47
|
+
getGlobalCFDIPreview: typeof cfdiEndpoints.getModule.getGlobalCFDIPreview,
|
|
48
|
+
getCFDIPreviewByOrderId: typeof cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
|
|
49
|
+
createCFDI: typeof cfdiEndpoints.postModule.createCFDI,
|
|
50
|
+
createGlobalCFDI: typeof cfdiEndpoints.postModule.createGlobalCFDI
|
|
46
51
|
}
|
|
47
52
|
review: {
|
|
48
53
|
getList: typeof reviewsEndpoints.getModule.getList;
|