washday-sdk 0.0.119 → 0.0.122

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.
@@ -1,7 +1,7 @@
1
1
  import axios from 'axios';
2
2
  // Define the type for the Axios instance
3
3
  let axiosInstance = null;
4
- // const BASE_URL: string = 'http://localhost:5555/';
4
+ //const BASE_URL: string = 'http://localhost:5555/';
5
5
  const BASE_URL = 'https://washday-backend.herokuapp.com/';
6
6
  // Function to create or return the singleton instance
7
7
  const getAxiosInstance = () => {
@@ -63,7 +63,7 @@ export const downloadCFDIPDF = function (id) {
63
63
  return yield axiosInstance.get(`${GET_SET_CFDI}/${id}/download/pdf`, config);
64
64
  }
65
65
  catch (error) {
66
- console.error('Error fetching exportCustomersList:', error);
66
+ console.error('Error fetching downloadCFDIPDF:', error);
67
67
  throw error;
68
68
  }
69
69
  });
package/dist/api/index.js CHANGED
@@ -27,6 +27,7 @@ import * as sectionsEndpoints from './sections';
27
27
  import * as productsEndpoints from './products';
28
28
  import * as customersEndpoints from './customers';
29
29
  import * as csvExportEndpoints from './csv';
30
+ import * as pdfExportEndpoints from './pdf';
30
31
  import * as ordersEndpoints from './order';
31
32
  import * as authEndpoints from './auth';
32
33
  import * as routesEndpoints from './routes';
@@ -93,9 +94,11 @@ const WashdayClient = function WashdayClient(apiToken) {
93
94
  setOrdeDeliveredBySequence: ordersEndpoints.putModule.setOrdeDeliveredBySequence,
94
95
  createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
95
96
  sendEmailReceipt: ordersEndpoints.postModule.sendEmailReceipt,
97
+ createOrderCustomersApp: ordersEndpoints.postModule.createOrderCustomersApp,
96
98
  deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
97
99
  getListCustomersApp: ordersEndpoints.getModule.getListCustomersApp,
98
100
  getByIdCustomersApp: ordersEndpoints.getModule.getByIdCustomersApp,
101
+ setOrderAcceptedBySequence: ordersEndpoints.putModule.setOrderAcceptedBySequence,
99
102
  });
100
103
  this.customers = bindMethods(this, {
101
104
  getCustomers: customersEndpoints.getModule.getList,
@@ -210,5 +213,8 @@ const WashdayClient = function WashdayClient(apiToken) {
210
213
  exportOrdersList: csvExportEndpoints.getModule.exportOrdersList,
211
214
  exportProductsList: csvExportEndpoints.getModule.exportProductsList
212
215
  });
216
+ this.pdf = bindMethods(this, {
217
+ exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
218
+ });
213
219
  };
214
220
  export default WashdayClient;
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import axiosInstance from "../axiosInstance";
11
11
  const GET_SET_ORDER_PAYMENTLINES = (orderId) => `/api/v2/order/${orderId}/paymentLines`;
12
12
  const GET_SET_ORDER = 'api/v2/order';
13
+ const GET_SET_ORDER_CUSTOMERS_APP = 'api/v2/washdayapp/orders';
13
14
  export const createPaymentLine = function (id, data) {
14
15
  return __awaiter(this, void 0, void 0, function* () {
15
16
  try {
@@ -38,3 +39,17 @@ export const sendEmailReceipt = function (id) {
38
39
  }
39
40
  });
40
41
  };
42
+ export const createOrderCustomersApp = function (data) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ try {
45
+ const config = {
46
+ headers: { Authorization: `Bearer ${this.apiToken}` }
47
+ };
48
+ return yield axiosInstance.post(`${GET_SET_ORDER_CUSTOMERS_APP}`, data, config);
49
+ }
50
+ catch (error) {
51
+ console.error('Error fetching createOrderCustomersApp:', error);
52
+ throw error;
53
+ }
54
+ });
55
+ };
@@ -137,3 +137,17 @@ export const setOrdeDeliveredBySequence = function (sequence, storeId, data) {
137
137
  }
138
138
  });
139
139
  };
140
+ export const setOrderAcceptedBySequence = function (sequence, storeId) {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ try {
143
+ const config = {
144
+ headers: { Authorization: `Bearer ${this.apiToken}` }
145
+ };
146
+ return yield axiosInstance.put(`${GET_SET_ORDER}/${sequence}/${storeId}/accepted`, {}, config);
147
+ }
148
+ catch (error) {
149
+ console.error('Error fetching setOrderAcceptedBySequence:', error);
150
+ throw error;
151
+ }
152
+ });
153
+ };
@@ -0,0 +1,42 @@
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 { generateQueryParamsStr } from "../../utils/apiUtils";
11
+ import axiosInstance from "../axiosInstance";
12
+ const GENERATE_EXPORT = 'api/export';
13
+ export const exportUnpaidOrdersReportPDF = function (storeId, params) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ try {
16
+ const config = {
17
+ headers: {
18
+ Authorization: `Bearer ${this.apiToken}`,
19
+ },
20
+ params: {
21
+ responseType: 'blob'
22
+ },
23
+ // responseType: 'blob', // Important for handling the PDF blob response
24
+ };
25
+ const queryParams = generateQueryParamsStr(['store', 'fromDate', 'toDate', 'timezone', 'customerName'], params);
26
+ return yield axiosInstance.get(`${GENERATE_EXPORT}/${storeId}/export-unpaid-orders-report/pdf?${queryParams}`, config);
27
+ // // Create a link element, trigger a download
28
+ // const url = window.URL.createObjectURL(new Blob([response.data]));
29
+ // const link = document.createElement('a');
30
+ // link.href = url;
31
+ // link.setAttribute('download', 'Reporte_Pedidos_Pago_Pendiente.pdf'); // Change the filename here if needed
32
+ // document.body.appendChild(link);
33
+ // link.click();
34
+ // link.remove();
35
+ // return response.data;
36
+ }
37
+ catch (error) {
38
+ console.error('Error fetching exportUnpaidOrdersReportPDF:', error);
39
+ throw error;
40
+ }
41
+ });
42
+ };
@@ -0,0 +1 @@
1
+ export * as getModule from './get';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.119",
3
+ "version": "0.0.122",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -3,7 +3,7 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
3
3
  // Define the type for the Axios instance
4
4
  let axiosInstance: AxiosInstance | null = null;
5
5
 
6
- // const BASE_URL: string = 'http://localhost:5555/';
6
+ //const BASE_URL: string = 'http://localhost:5555/';
7
7
  const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
8
8
 
9
9
  // Function to create or return the singleton instance
@@ -59,7 +59,7 @@ export const downloadCFDIPDF = async function (this: WashdayClientInstance, id:
59
59
  };
60
60
  return await axiosInstance.get(`${GET_SET_CFDI}/${id}/download/pdf`, config);
61
61
  } catch (error) {
62
- console.error('Error fetching exportCustomersList:', error);
62
+ console.error('Error fetching downloadCFDIPDF:', error);
63
63
  throw error;
64
64
  }
65
65
  };
@@ -6,6 +6,8 @@ export const create = async function (this: WashdayClientInstance, data: {
6
6
  name: string;
7
7
  lastName?: string;
8
8
  phone?: string;
9
+ phoneCountryCode?: string;
10
+ phoneCountryName?: string;
9
11
  email?: string;
10
12
  address?: string;
11
13
  notes?: string;
@@ -19,6 +19,8 @@ export const updateById = async function (this: WashdayClientInstance, id: strin
19
19
  name?: string;
20
20
  lastName?: string;
21
21
  phone?: string;
22
+ phoneCountryCode?: string;
23
+ phoneCountryName?: string;
22
24
  email?: string;
23
25
  address?: string;
24
26
  notes?: string;
@@ -48,6 +50,8 @@ export const updateByIdCustomersApp = async function (this: WashdayClientInstanc
48
50
  name?: string;
49
51
  lastName?: string;
50
52
  phone?: string;
53
+ phoneCountryCode?: string;
54
+ phoneCountryName?: string;
51
55
  address?: string;
52
56
  notes?: string;
53
57
  customersAppPushNotificationToken?: string;
package/src/api/index.ts CHANGED
@@ -28,6 +28,7 @@ import * as sectionsEndpoints from './sections';
28
28
  import * as productsEndpoints from './products';
29
29
  import * as customersEndpoints from './customers';
30
30
  import * as csvExportEndpoints from './csv';
31
+ import * as pdfExportEndpoints from './pdf';
31
32
  import * as ordersEndpoints from './order';
32
33
  import * as authEndpoints from './auth';
33
34
  import * as routesEndpoints from './routes';
@@ -99,9 +100,11 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
99
100
  setOrdeDeliveredBySequence: ordersEndpoints.putModule.setOrdeDeliveredBySequence,
100
101
  createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
101
102
  sendEmailReceipt: ordersEndpoints.postModule.sendEmailReceipt,
103
+ createOrderCustomersApp: ordersEndpoints.postModule.createOrderCustomersApp,
102
104
  deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
103
105
  getListCustomersApp: ordersEndpoints.getModule.getListCustomersApp,
104
106
  getByIdCustomersApp: ordersEndpoints.getModule.getByIdCustomersApp,
107
+ setOrderAcceptedBySequence: ordersEndpoints.putModule.setOrderAcceptedBySequence,
105
108
  });
106
109
  this.customers = bindMethods(this, {
107
110
  getCustomers: customersEndpoints.getModule.getList,
@@ -216,6 +219,9 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
216
219
  exportOrdersList: csvExportEndpoints.getModule.exportOrdersList,
217
220
  exportProductsList: csvExportEndpoints.getModule.exportProductsList
218
221
  });
222
+ this.pdf = bindMethods(this, {
223
+ exportUnpaidOrdersReportPDF: pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF,
224
+ });
219
225
  } as any;
220
226
 
221
227
  export default WashdayClient;
@@ -1,7 +1,9 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { OrderDto } from "../../interfaces/Order";
2
3
  import axiosInstance from "../axiosInstance";
3
4
  const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
4
5
  const GET_SET_ORDER = 'api/v2/order';
6
+ const GET_SET_ORDER_CUSTOMERS_APP = 'api/v2/washdayapp/orders';
5
7
 
6
8
  export const createPaymentLine = async function (this: WashdayClientInstance, id: string, data: {
7
9
  amountPaid: number,
@@ -31,4 +33,16 @@ export const sendEmailReceipt = async function (this: WashdayClientInstance, id:
31
33
  console.error('Error fetching create:', error);
32
34
  throw error;
33
35
  }
36
+ };
37
+
38
+ export const createOrderCustomersApp = async function (this: WashdayClientInstance, data: OrderDto): Promise<any> {
39
+ try {
40
+ const config = {
41
+ headers: { Authorization: `Bearer ${this.apiToken}` }
42
+ };
43
+ return await axiosInstance.post(`${GET_SET_ORDER_CUSTOMERS_APP}`, data, config);
44
+ } catch (error) {
45
+ console.error('Error fetching createOrderCustomersApp:', error);
46
+ throw error;
47
+ }
34
48
  };
@@ -149,4 +149,16 @@ export const setOrdeDeliveredBySequence = async function (this: WashdayClientIns
149
149
  console.error('Error fetching setOrdeDeliveredBySequence:', error);
150
150
  throw error;
151
151
  }
152
+ };
153
+
154
+ export const setOrderAcceptedBySequence = async function (this: WashdayClientInstance, sequence: string, storeId: string): Promise<any> {
155
+ try {
156
+ const config = {
157
+ headers: { Authorization: `Bearer ${this.apiToken}` }
158
+ };
159
+ return await axiosInstance.put(`${GET_SET_ORDER}/${sequence}/${storeId}/accepted`, {}, config);
160
+ } catch (error) {
161
+ console.error('Error fetching setOrderAcceptedBySequence:', error);
162
+ throw error;
163
+ }
152
164
  };
@@ -0,0 +1,42 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { generateQueryParamsStr } from "../../utils/apiUtils";
3
+ import axiosInstance from "../axiosInstance";
4
+
5
+ const GENERATE_EXPORT = 'api/export';
6
+
7
+ export const exportUnpaidOrdersReportPDF = async function (this: WashdayClientInstance, storeId: string, params: {
8
+ store: string | undefined,
9
+ fromDate: string | undefined,
10
+ toDate: string | undefined,
11
+ timezone: string | undefined,
12
+ customerName: string | undefined,
13
+ }): Promise<any> {
14
+ try {
15
+ const config = {
16
+ headers: {
17
+ Authorization: `Bearer ${this.apiToken}`,
18
+ },
19
+ params: {
20
+ responseType: 'blob'
21
+ },
22
+ // responseType: 'blob', // Important for handling the PDF blob response
23
+ };
24
+
25
+ const queryParams = generateQueryParamsStr(['store', 'fromDate', 'toDate', 'timezone', 'customerName'], params);
26
+ return await axiosInstance.get(`${GENERATE_EXPORT}/${storeId}/export-unpaid-orders-report/pdf?${queryParams}`, config);
27
+
28
+ // // Create a link element, trigger a download
29
+ // const url = window.URL.createObjectURL(new Blob([response.data]));
30
+ // const link = document.createElement('a');
31
+ // link.href = url;
32
+ // link.setAttribute('download', 'Reporte_Pedidos_Pago_Pendiente.pdf'); // Change the filename here if needed
33
+ // document.body.appendChild(link);
34
+ // link.click();
35
+ // link.remove();
36
+
37
+ // return response.data;
38
+ } catch (error) {
39
+ console.error('Error fetching exportUnpaidOrdersReportPDF:', error);
40
+ throw error;
41
+ }
42
+ };
@@ -0,0 +1 @@
1
+ export * as getModule from './get';
@@ -27,6 +27,7 @@ import * as sectionsEndpoints from '../api/sections';
27
27
  import * as productsEndpoints from '../api/products';
28
28
  import * as customersEndpoints from '../api/customers';
29
29
  import * as csvExportEndpoints from '../api/csv';
30
+ import * as pdfExportEndpoints from '../api/pdf';
30
31
  import * as ordersEndpoints from '../api/order';
31
32
  import * as routesEndpoints from '../api/routes';
32
33
  import * as reviewsEndpoints from '../api/reviews';
@@ -85,9 +86,11 @@ export interface WashdayClientInstance {
85
86
  setOrdeDeliveringBySequence: typeof ordersEndpoints.putModule.setOrdeDeliveringBySequence,
86
87
  setOrdeDeliveredBySequence: typeof ordersEndpoints.putModule.setOrdeDeliveredBySequence,
87
88
  createPaymentLine: typeof ordersEndpoints.postModule.createPaymentLine;
89
+ createOrderCustomersApp: typeof ordersEndpoints.postModule.createOrderCustomersApp,
88
90
  deletePaymentLineById: typeof ordersEndpoints.deleteModule.deletePaymentLineById;
89
91
  getListCustomersApp: typeof ordersEndpoints.getModule.getListCustomersApp;
90
92
  getByIdCustomersApp: typeof ordersEndpoints.getModule.getByIdCustomersApp;
93
+ setOrderAcceptedBySequence: typeof ordersEndpoints.putModule.setOrderAcceptedBySequence,
91
94
  };
92
95
  customers: {
93
96
  getCustomers: typeof customersEndpoints.getModule.getList;
@@ -200,4 +203,7 @@ export interface WashdayClientInstance {
200
203
  csv: {
201
204
  exportCustomersList: typeof csvExportEndpoints.getModule.exportCustomersList;
202
205
  };
206
+ pdf: {
207
+ exportUnpaidOrdersReportPDF: typeof pdfExportEndpoints.getModule.exportUnpaidOrdersReportPDF;
208
+ };
203
209
  }
@@ -1,6 +1,6 @@
1
1
  import { ICustomer } from "./Customer";
2
2
  import { IOrderProduct, IProduct } from "./Product";
3
- import { ICashierBox, IStore, ITaxConfig } from "./Store";
3
+ import { ICashierBox, IStore, IStoreDiscount, ITaxConfig } from "./Store";
4
4
  import { IUser } from "./User";
5
5
 
6
6
  interface IDeliveryInfo {
@@ -93,4 +93,41 @@ export interface IOrderInfo {
93
93
  paid: number;
94
94
  unpaid: number;
95
95
  lastOrderDate: Date;
96
+ }
97
+
98
+ export interface OrderDto {
99
+ delivery: boolean,
100
+ pickup: boolean,
101
+ express: boolean,
102
+ deliveryInfo: IDeliveryInfo,
103
+ pickupInfo?: IPickupInfo,
104
+ phone: string,
105
+ email?: string,
106
+ address: string,
107
+ notes?: string,
108
+ privateNotes?: string,
109
+ taxesType: string,
110
+ products: Array<IOrderProduct> | any,
111
+ creditApplied: number,
112
+ amountPaid: number,
113
+ customer: string,
114
+ pickingUpDateTime: Date | null,
115
+ cleanedDateTime: Date | null,
116
+ readyDateTime: Date | null,
117
+ deliveringDateTime: Date | null,
118
+ collectedDateTime: Date | null,
119
+ cancelledDateTime: Date | null,
120
+ paidDateTime: Date | null,
121
+ status: string,
122
+ store: string,
123
+ paymentMethod: string | null,
124
+ prepaidAmount: number | null,
125
+ prepaidPaymentMethod: string | null,
126
+ notifyBy: string,
127
+ discountsToApply: Array<IStoreDiscount> | null,
128
+ cashierBox: string | null,
129
+ buyAndGetProducts: Array<IOrderProduct>,
130
+ discountCode: string | null,
131
+ createdDate?: Date | null,
132
+ updatedDate?: Date | null
96
133
  }