washday-sdk 0.0.87 → 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.
@@ -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
+ };
@@ -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
@@ -16,7 +16,7 @@ import { updateStoreStaffById } from "./staff/put";
16
16
  import { getStoreById, getStoreImages, getStoreReviewLink, getStores } from "./stores/get";
17
17
  import { copyStore, createStore, createStoreImage } from "./stores/post";
18
18
  import { deleteStoreById, updateStoreById } from "./stores/put";
19
- import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession } from "./stripe/post";
19
+ import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession, createGetMoreCheckoutSession } from "./stripe/post";
20
20
  import { deleteSupplyById } from "./supplies/delete";
21
21
  import { getSupplies, getSupplyById, getSupplyHistory } from "./supplies/get";
22
22
  import { createSupply } from "./supplies/post";
@@ -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,
@@ -145,6 +150,7 @@ const WashdayClient = function WashdayClient(apiToken) {
145
150
  this.stripe = bindMethods(this, {
146
151
  createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
147
152
  createCFDISuscrptionCheckoutSession: createCFDISuscrptionCheckoutSession,
153
+ createGetMoreCheckoutSession: createGetMoreCheckoutSession,
148
154
  createCustomerPortalSession: createCustomerPortalSession
149
155
  });
150
156
  this.staff = bindMethods(this, {
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import axiosInstance from "../axiosInstance";
11
11
  const GET_SET_STRIPE = 'api/stripe';
12
+ const GENERATE_CHECKOUT_SESSION = 'api/orders/create-checkout-session';
12
13
  export const createCreateSuscriptionCheckoutSession = function (data) {
13
14
  return __awaiter(this, void 0, void 0, function* () {
14
15
  try {
@@ -54,3 +55,17 @@ export const createCFDISuscrptionCheckoutSession = function (data) {
54
55
  }
55
56
  });
56
57
  };
58
+ export const createGetMoreCheckoutSession = function (data) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ try {
61
+ const config = {
62
+ headers: { Authorization: `Bearer ${this.apiToken}` }
63
+ };
64
+ return yield axiosInstance.post(`${GENERATE_CHECKOUT_SESSION}`, data, config);
65
+ }
66
+ catch (error) {
67
+ console.error('Error fetching createGetMoreCheckoutSession:', error);
68
+ throw error;
69
+ }
70
+ });
71
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.87",
3
+ "version": "0.0.89",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -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
+ }
@@ -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: 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
@@ -17,7 +17,7 @@ import { updateStoreStaffById } from "./staff/put";
17
17
  import { getStoreById, getStoreImages, getStoreReviewLink, getStores } from "./stores/get";
18
18
  import { copyStore, createStore, createStoreImage } from "./stores/post";
19
19
  import { deleteStoreById, updateStoreById } from "./stores/put";
20
- import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession } from "./stripe/post";
20
+ import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession, createGetMoreCheckoutSession } from "./stripe/post";
21
21
  import { deleteSupplyById } from "./supplies/delete";
22
22
  import { getSupplies, getSupplyById, getSupplyHistory } from "./supplies/get";
23
23
  import { createSupply } from "./supplies/post";
@@ -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,
@@ -151,6 +156,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
151
156
  this.stripe = bindMethods(this, {
152
157
  createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
153
158
  createCFDISuscrptionCheckoutSession: createCFDISuscrptionCheckoutSession,
159
+ createGetMoreCheckoutSession: createGetMoreCheckoutSession,
154
160
  createCustomerPortalSession: createCustomerPortalSession
155
161
  });
156
162
  this.staff = bindMethods(this, {
@@ -1,6 +1,7 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
  import axiosInstance from "../axiosInstance";
3
3
  const GET_SET_STRIPE = 'api/stripe';
4
+ const GENERATE_CHECKOUT_SESSION = 'api/orders/create-checkout-session';
4
5
 
5
6
  export const createCreateSuscriptionCheckoutSession = async function (this: WashdayClientInstance, data: {
6
7
  priceId: string
@@ -42,3 +43,17 @@ export const createCFDISuscrptionCheckoutSession = async function (this: Washday
42
43
  throw error;
43
44
  }
44
45
  };
46
+
47
+ export const createGetMoreCheckoutSession = async function (this: WashdayClientInstance, data: {
48
+ priceId: string
49
+ }): Promise<any> {
50
+ try {
51
+ const config = {
52
+ headers: { Authorization: `Bearer ${this.apiToken}` }
53
+ };
54
+ return await axiosInstance.post(`${GENERATE_CHECKOUT_SESSION}`, data, config);
55
+ } catch (error) {
56
+ console.error('Error fetching createGetMoreCheckoutSession:', error);
57
+ throw error;
58
+ }
59
+ };
@@ -16,7 +16,7 @@ import { updateStoreStaffById } from "../api/staff/put";
16
16
  import { getStoreById, getStoreImages, getStoreReviewLink, getStores } from "../api/stores/get";
17
17
  import { copyStore, createStore, createStoreImage } from "../api/stores/post";
18
18
  import { deleteStoreById, updateStoreById } from "../api/stores/put";
19
- import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession } from "../api/stripe/post";
19
+ import { createCFDISuscrptionCheckoutSession, createCreateSuscriptionCheckoutSession, createCustomerPortalSession, createGetMoreCheckoutSession } from "../api/stripe/post";
20
20
  import { deleteSupplyById } from "../api/supplies/delete";
21
21
  import { getSupplies, getSupplyById, getSupplyHistory } from "../api/supplies/get";
22
22
  import { createSupply } from "../api/supplies/post";
@@ -41,8 +41,13 @@ export interface WashdayClientInstance {
41
41
  create: typeof cashupsEndpoints.postModule.create
42
42
  }
43
43
  cfdi: {
44
- getCFDIPreviewByOrderId: typeof cfdiEndpoints.getModule.getCFDIPreviewByOrderId;
45
- createCFDI: typeof cfdiEndpoints.postModule.createCFDI
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;
@@ -136,6 +141,7 @@ export interface WashdayClientInstance {
136
141
  stripe: {
137
142
  createCreateSuscriptionCheckoutSession: typeof createCreateSuscriptionCheckoutSession;
138
143
  createCFDISuscrptionCheckoutSession: typeof createCFDISuscrptionCheckoutSession;
144
+ createGetMoreCheckoutSession: typeof createGetMoreCheckoutSession;
139
145
  createCustomerPortalSession: typeof createCustomerPortalSession;
140
146
  };
141
147
  staff: {