washday-sdk 0.0.84 → 0.0.86
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/delete.js +25 -0
- package/dist/api/cfdi/get.js +26 -0
- package/dist/api/cfdi/index.js +4 -0
- package/dist/api/cfdi/post.js +25 -0
- package/dist/api/cfdi/put.js +52 -0
- package/dist/api/index.js +6 -0
- package/dist/api/reviews/get.js +16 -0
- package/package.json +1 -1
- package/src/api/cfdi/delete.ts +21 -0
- package/src/api/cfdi/get.ts +16 -0
- package/src/api/cfdi/index.ts +4 -0
- package/src/api/cfdi/post.ts +22 -0
- package/src/api/cfdi/put.ts +53 -0
- package/src/api/index.ts +8 -0
- package/src/api/reviews/get.ts +14 -0
- package/src/interfaces/Api.ts +6 -0
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_CFDI = 'api/cfdi';
|
|
12
|
+
export const cancelCFDI = function (id, data) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
return yield axiosInstance.delete(`${GET_SET_CFDI}/${id}`, Object.assign(Object.assign({}, config), { data }));
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('Error fetching deleteById:', error);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_ORDERS_CFDI_PREVIEW = (orderID) => `api/order/${orderID}/preview/cfdi`;
|
|
12
|
+
const GET_SET_CFDI = 'api/cfdi';
|
|
13
|
+
export const getCFDIPreviewByOrderId = function (id) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
const config = {
|
|
17
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
18
|
+
};
|
|
19
|
+
return yield axiosInstance.get(`${GET_ORDERS_CFDI_PREVIEW(id)}`, config);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error fetching:', error);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
import axiosInstance from "../axiosInstance";
|
|
11
|
+
const GET_SET_ORDERS_CFDI = (orderID) => `api/order/${orderID}/cfdi`;
|
|
12
|
+
export const createCFDI = function (id, data) {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const config = {
|
|
16
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
17
|
+
};
|
|
18
|
+
return yield axiosInstance.post(`${GET_SET_ORDERS_CFDI(id)}`, data, config);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('Error fetching create:', error);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
3
|
+
// import axiosInstance from "../axiosInstance";
|
|
4
|
+
// const GET_SET_ORDER = 'api/v2/order';
|
|
5
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
6
|
+
// export const updateById = async function (this: WashdayClientInstance, id: string, data: {
|
|
7
|
+
// status?: string,
|
|
8
|
+
// products?: any[],
|
|
9
|
+
// buyAndGetProducts?: any[],
|
|
10
|
+
// customer?: string,
|
|
11
|
+
// discountCode?: string | null,
|
|
12
|
+
// notes?: string,
|
|
13
|
+
// privateNotes?: string,
|
|
14
|
+
// delivery?: boolean,
|
|
15
|
+
// pickup?: boolean,
|
|
16
|
+
// express?: boolean,
|
|
17
|
+
// deliveryInfo?: {
|
|
18
|
+
// date: Date,
|
|
19
|
+
// fromTime: string,
|
|
20
|
+
// toTime?: string
|
|
21
|
+
// },
|
|
22
|
+
// pickupInfo?: {
|
|
23
|
+
// date: Date,
|
|
24
|
+
// fromTime: string,
|
|
25
|
+
// toTime?: string
|
|
26
|
+
// },
|
|
27
|
+
// notifyBy?: string,
|
|
28
|
+
// }): Promise<any> {
|
|
29
|
+
// try {
|
|
30
|
+
// const config = {
|
|
31
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
// };
|
|
33
|
+
// return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
|
|
34
|
+
// } catch (error) {
|
|
35
|
+
// console.error('Error fetching updateById:', error);
|
|
36
|
+
// throw error;
|
|
37
|
+
// }
|
|
38
|
+
// };
|
|
39
|
+
// export const updatePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string, data: {
|
|
40
|
+
// amountPaid: number
|
|
41
|
+
// updatedDate: Date
|
|
42
|
+
// }): Promise<any> {
|
|
43
|
+
// try {
|
|
44
|
+
// const config = {
|
|
45
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
46
|
+
// };
|
|
47
|
+
// return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
|
|
48
|
+
// } catch (error) {
|
|
49
|
+
// console.error('Error fetching updateById:', error);
|
|
50
|
+
// throw error;
|
|
51
|
+
// }
|
|
52
|
+
// };
|
package/dist/api/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import * as customersEndpoints from './customers';
|
|
|
29
29
|
import * as csvExportEndpoints from './csv';
|
|
30
30
|
import * as ordersEndpoints from './order';
|
|
31
31
|
import * as reviewsEndpoints from './reviews';
|
|
32
|
+
import * as cfdiEndpoints from './cfdi';
|
|
32
33
|
function bindMethods(instance, methods) {
|
|
33
34
|
const boundMethods = {};
|
|
34
35
|
for (const key in methods) {
|
|
@@ -40,7 +41,12 @@ function bindMethods(instance, methods) {
|
|
|
40
41
|
}
|
|
41
42
|
const WashdayClient = function WashdayClient(apiToken) {
|
|
42
43
|
this.apiToken = apiToken;
|
|
44
|
+
this.cfdi = bindMethods(this, {
|
|
45
|
+
getCFDIPreviewByOrderId: cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
|
|
46
|
+
createCFDI: cfdiEndpoints.postModule.createCFDI,
|
|
47
|
+
});
|
|
43
48
|
this.review = bindMethods(this, {
|
|
49
|
+
getList: reviewsEndpoints.getModule.getList,
|
|
44
50
|
requestStoreReviewByCustomerId: reviewsEndpoints.getModule.requestStoreReviewByCustomerId,
|
|
45
51
|
});
|
|
46
52
|
this.orders = bindMethods(this, {
|
package/dist/api/reviews/get.js
CHANGED
|
@@ -7,8 +7,24 @@ 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_SET_REVIEWS = 'api/review';
|
|
13
|
+
export const getList = function (storeId, params) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
const config = {
|
|
17
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
18
|
+
};
|
|
19
|
+
const queryParams = generateQueryParamsStr(['sortBy'], params);
|
|
20
|
+
return yield axiosInstance.get(`${GET_SET_REVIEWS}/${storeId}?${queryParams}`, config);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error('Error fetching:', error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
12
28
|
export const requestStoreReviewByCustomerId = function (storeId, customerId) {
|
|
13
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
30
|
try {
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_CFDI = 'api/cfdi';
|
|
4
|
+
|
|
5
|
+
export const cancelCFDI = async function (this: WashdayClientInstance, id: string, data: {
|
|
6
|
+
motive: string
|
|
7
|
+
substitution?: string
|
|
8
|
+
}): Promise<any> {
|
|
9
|
+
try {
|
|
10
|
+
const config = {
|
|
11
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
12
|
+
};
|
|
13
|
+
return await axiosInstance.delete(`${GET_SET_CFDI}/${id}`, {
|
|
14
|
+
...config,
|
|
15
|
+
data
|
|
16
|
+
});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error fetching deleteById:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_ORDERS_CFDI_PREVIEW = (orderID: string) => `api/order/${orderID}/preview/cfdi`;
|
|
4
|
+
const GET_SET_CFDI = 'api/cfdi';
|
|
5
|
+
|
|
6
|
+
export const getCFDIPreviewByOrderId = async function (this: WashdayClientInstance, id: string): Promise<any> {
|
|
7
|
+
try {
|
|
8
|
+
const config = {
|
|
9
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
10
|
+
};
|
|
11
|
+
return await axiosInstance.get(`${GET_ORDERS_CFDI_PREVIEW(id)}`, config);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error fetching:', error);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
import axiosInstance from "../axiosInstance";
|
|
3
|
+
const GET_SET_ORDERS_CFDI = (orderID: string) => `api/order/${orderID}/cfdi`;
|
|
4
|
+
|
|
5
|
+
export const createCFDI = async function (this: WashdayClientInstance, id: string, data: {
|
|
6
|
+
use: string
|
|
7
|
+
payment_method: string
|
|
8
|
+
payment_form: string
|
|
9
|
+
sendEmailInvoice: boolean
|
|
10
|
+
date: Date
|
|
11
|
+
env: 'prod' | 'dev'
|
|
12
|
+
}): Promise<any> {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
return await axiosInstance.post(`${GET_SET_ORDERS_CFDI(id)}`, data, config);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Error fetching create:', error);
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
// import axiosInstance from "../axiosInstance";
|
|
3
|
+
// const GET_SET_ORDER = 'api/v2/order';
|
|
4
|
+
// const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
|
|
5
|
+
|
|
6
|
+
// export const updateById = async function (this: WashdayClientInstance, id: string, data: {
|
|
7
|
+
// status?: string,
|
|
8
|
+
// products?: any[],
|
|
9
|
+
// buyAndGetProducts?: any[],
|
|
10
|
+
// customer?: string,
|
|
11
|
+
// discountCode?: string | null,
|
|
12
|
+
// notes?: string,
|
|
13
|
+
// privateNotes?: string,
|
|
14
|
+
// delivery?: boolean,
|
|
15
|
+
// pickup?: boolean,
|
|
16
|
+
// express?: boolean,
|
|
17
|
+
// deliveryInfo?: {
|
|
18
|
+
// date: Date,
|
|
19
|
+
// fromTime: string,
|
|
20
|
+
// toTime?: string
|
|
21
|
+
// },
|
|
22
|
+
// pickupInfo?: {
|
|
23
|
+
// date: Date,
|
|
24
|
+
// fromTime: string,
|
|
25
|
+
// toTime?: string
|
|
26
|
+
// },
|
|
27
|
+
// notifyBy?: string,
|
|
28
|
+
// }): Promise<any> {
|
|
29
|
+
// try {
|
|
30
|
+
// const config = {
|
|
31
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
32
|
+
// };
|
|
33
|
+
// return await axiosInstance.put(`${GET_SET_ORDER}/${id}`, data, config);
|
|
34
|
+
// } catch (error) {
|
|
35
|
+
// console.error('Error fetching updateById:', error);
|
|
36
|
+
// throw error;
|
|
37
|
+
// }
|
|
38
|
+
// };
|
|
39
|
+
|
|
40
|
+
// export const updatePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string, data: {
|
|
41
|
+
// amountPaid: number
|
|
42
|
+
// updatedDate: Date
|
|
43
|
+
// }): Promise<any> {
|
|
44
|
+
// try {
|
|
45
|
+
// const config = {
|
|
46
|
+
// headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
47
|
+
// };
|
|
48
|
+
// return await axiosInstance.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
|
|
49
|
+
// } catch (error) {
|
|
50
|
+
// console.error('Error fetching updateById:', error);
|
|
51
|
+
// throw error;
|
|
52
|
+
// }
|
|
53
|
+
// };
|
package/src/api/index.ts
CHANGED
|
@@ -30,6 +30,8 @@ import * as customersEndpoints from './customers';
|
|
|
30
30
|
import * as csvExportEndpoints from './csv';
|
|
31
31
|
import * as ordersEndpoints from './order';
|
|
32
32
|
import * as reviewsEndpoints from './reviews';
|
|
33
|
+
import * as cfdiEndpoints from './cfdi';
|
|
34
|
+
import { createCFDI } from './cfdi/post';
|
|
33
35
|
|
|
34
36
|
type WashdayClientConstructor = {
|
|
35
37
|
new(apiToken: string): WashdayClientInstance
|
|
@@ -46,7 +48,13 @@ function bindMethods<T>(instance: any, methods: any): T {
|
|
|
46
48
|
|
|
47
49
|
const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string) {
|
|
48
50
|
this.apiToken = apiToken;
|
|
51
|
+
|
|
52
|
+
this.cfdi = bindMethods(this, {
|
|
53
|
+
getCFDIPreviewByOrderId: cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
|
|
54
|
+
createCFDI: cfdiEndpoints.postModule.createCFDI,
|
|
55
|
+
});
|
|
49
56
|
this.review = bindMethods(this, {
|
|
57
|
+
getList: reviewsEndpoints.getModule.getList,
|
|
50
58
|
requestStoreReviewByCustomerId: reviewsEndpoints.getModule.requestStoreReviewByCustomerId,
|
|
51
59
|
});
|
|
52
60
|
this.orders = bindMethods(this, {
|
package/src/api/reviews/get.ts
CHANGED
|
@@ -4,6 +4,20 @@ import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
|
4
4
|
import axiosInstance from "../axiosInstance";
|
|
5
5
|
const GET_SET_REVIEWS = 'api/review';
|
|
6
6
|
|
|
7
|
+
export const getList = async function (this: WashdayClientInstance, storeId: string, params: { sortBy: 'desc' | 'asc' | -1 | 1 }): Promise<any> {
|
|
8
|
+
try {
|
|
9
|
+
const config = {
|
|
10
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
11
|
+
};
|
|
12
|
+
const queryParams = generateQueryParamsStr(['sortBy'], params);
|
|
13
|
+
|
|
14
|
+
return await axiosInstance.get(`${GET_SET_REVIEWS}/${storeId}?${queryParams}`, config);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Error fetching:', error);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
export const requestStoreReviewByCustomerId = async function (this: WashdayClientInstance, storeId: string, customerId: string): Promise<any> {
|
|
8
22
|
try {
|
|
9
23
|
const config = {
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -29,10 +29,16 @@ import * as customersEndpoints from '../api/customers';
|
|
|
29
29
|
import * as csvExportEndpoints from '../api/csv';
|
|
30
30
|
import * as ordersEndpoints from '../api/order';
|
|
31
31
|
import * as reviewsEndpoints from '../api/reviews';
|
|
32
|
+
import * as cfdiEndpoints from '../api/cfdi';
|
|
32
33
|
|
|
33
34
|
export interface WashdayClientInstance {
|
|
34
35
|
apiToken: string;
|
|
36
|
+
cfdi: {
|
|
37
|
+
getCFDIPreviewByOrderId: typeof cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
|
|
38
|
+
createCFDI: typeof cfdiEndpoints.postModule.createCFDI
|
|
39
|
+
}
|
|
35
40
|
review: {
|
|
41
|
+
getList: typeof reviewsEndpoints.getModule.getList;
|
|
36
42
|
requestStoreReviewByCustomerId: typeof reviewsEndpoints.getModule.requestStoreReviewByCustomerId;
|
|
37
43
|
}
|
|
38
44
|
orders: {
|