washday-sdk 0.0.86 → 0.0.87

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.
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // import { WashdayClientInstance } from "../../interfaces/Api";
3
+ // import axiosInstance from "../axiosInstance";
4
+ // const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
5
+ // export const deletePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string): Promise<any> {
6
+ // try {
7
+ // const config = {
8
+ // headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ // };
10
+ // return await axiosInstance.delete(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
11
+ // } catch (error) {
12
+ // console.error('Error fetching deleteById:', error);
13
+ // throw error;
14
+ // }
15
+ // };
@@ -0,0 +1,59 @@
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 GET_CASH_UP = 'api/cashup';
13
+ const GET_CASH_UP_REPORTS = 'api/cashupreports';
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
+ 'pageNum',
22
+ 'limit',
23
+ ], params);
24
+ return yield axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}?${queryParams}`, config);
25
+ }
26
+ catch (error) {
27
+ console.error('Error fetching getList orders:', error);
28
+ throw error;
29
+ }
30
+ });
31
+ };
32
+ export const getById = function (storeId, id) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ try {
35
+ const config = {
36
+ headers: { Authorization: `Bearer ${this.apiToken}` }
37
+ };
38
+ return yield axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
39
+ }
40
+ catch (error) {
41
+ console.error('Error fetching:', error);
42
+ throw error;
43
+ }
44
+ });
45
+ };
46
+ export const getPreviewDataForCashClose = function (storeId, id) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ try {
49
+ const config = {
50
+ headers: { Authorization: `Bearer ${this.apiToken}` }
51
+ };
52
+ return yield axiosInstance.get(`${GET_CASH_UP}/${storeId}/${id}`, config);
53
+ }
54
+ catch (error) {
55
+ console.error('Error fetching:', error);
56
+ throw error;
57
+ }
58
+ });
59
+ };
@@ -0,0 +1,4 @@
1
+ // export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
4
+ // export * as putModule from './put';
@@ -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_CASH_UP = 'api/cashup';
12
+ export const create = function (storeId, 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_CASH_UP}/${storeId}/${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
@@ -30,6 +30,7 @@ import * as csvExportEndpoints from './csv';
30
30
  import * as ordersEndpoints from './order';
31
31
  import * as reviewsEndpoints from './reviews';
32
32
  import * as cfdiEndpoints from './cfdi';
33
+ import * as cashupsEndpoints from './cashups';
33
34
  function bindMethods(instance, methods) {
34
35
  const boundMethods = {};
35
36
  for (const key in methods) {
@@ -41,6 +42,12 @@ function bindMethods(instance, methods) {
41
42
  }
42
43
  const WashdayClient = function WashdayClient(apiToken) {
43
44
  this.apiToken = apiToken;
45
+ this.cashup = bindMethods(this, {
46
+ getList: cashupsEndpoints.getModule.getList,
47
+ getById: cashupsEndpoints.getModule.getById,
48
+ getPreviewDataForCashClose: cashupsEndpoints.getModule.getPreviewDataForCashClose,
49
+ create: cashupsEndpoints.postModule.create
50
+ });
44
51
  this.cfdi = bindMethods(this, {
45
52
  getCFDIPreviewByOrderId: cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
46
53
  createCFDI: cfdiEndpoints.postModule.createCFDI,
@@ -17,6 +17,7 @@ export const getList = function (params) {
17
17
  headers: { Authorization: `Bearer ${this.apiToken}` }
18
18
  };
19
19
  const queryParams = generateQueryParamsStr([
20
+ 'store',
20
21
  'storeId',
21
22
  'status',
22
23
  'name',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.86",
3
+ "version": "0.0.87",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -0,0 +1,15 @@
1
+ // import { WashdayClientInstance } from "../../interfaces/Api";
2
+ // import axiosInstance from "../axiosInstance";
3
+ // const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
4
+
5
+ // export const deletePaymentLineById = async function (this: WashdayClientInstance, orderId: string, id: string): Promise<any> {
6
+ // try {
7
+ // const config = {
8
+ // headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ // };
10
+ // return await axiosInstance.delete(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
11
+ // } catch (error) {
12
+ // console.error('Error fetching deleteById:', error);
13
+ // throw error;
14
+ // }
15
+ // };
@@ -0,0 +1,50 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { IOrder } from "../../interfaces/Order";
3
+ import { ICashUpReport } from "../../interfaces/Store";
4
+ import { generateQueryParamsStr } from "../../utils/apiUtils";
5
+ import axiosInstance from "../axiosInstance";
6
+ const GET_CASH_UP = 'api/cashup';
7
+ const GET_CASH_UP_REPORTS = 'api/cashupreports';
8
+
9
+ export const getList = async function (this: WashdayClientInstance, storeId: string, params: {
10
+ pageNum?: string;
11
+ limit?: string;
12
+ }): Promise<any> {
13
+ try {
14
+ const config = {
15
+ headers: { Authorization: `Bearer ${this.apiToken}` }
16
+ };
17
+ const queryParams = generateQueryParamsStr([
18
+ 'pageNum',
19
+ 'limit',
20
+ ], params);
21
+ return await axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}?${queryParams}`, config);
22
+ } catch (error) {
23
+ console.error('Error fetching getList orders:', error);
24
+ throw error;
25
+ }
26
+ };
27
+
28
+ export const getById = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
29
+ try {
30
+ const config = {
31
+ headers: { Authorization: `Bearer ${this.apiToken}` }
32
+ };
33
+ return await axiosInstance.get(`${GET_CASH_UP_REPORTS}/${storeId}/${id}`, config);
34
+ } catch (error) {
35
+ console.error('Error fetching:', error);
36
+ throw error;
37
+ }
38
+ }
39
+
40
+ export const getPreviewDataForCashClose = async function (this: WashdayClientInstance, storeId: string, id: string): Promise<any> {
41
+ try {
42
+ const config = {
43
+ headers: { Authorization: `Bearer ${this.apiToken}` }
44
+ };
45
+ return await axiosInstance.get(`${GET_CASH_UP}/${storeId}/${id}`, config);
46
+ } catch (error) {
47
+ console.error('Error fetching:', error);
48
+ throw error;
49
+ }
50
+ }
@@ -0,0 +1,4 @@
1
+ // export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
4
+ // export * as putModule from './put';
@@ -0,0 +1,23 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_CASH_UP = 'api/cashup';
4
+
5
+ export const create = async function (this: WashdayClientInstance, storeId: string, id: string, data: {
6
+ cashierBox: string;
7
+ startingCash: number;
8
+ declaredCash: number;
9
+ declaredCard: number;
10
+ declaredTransfer: number;
11
+ cashToBank: number;
12
+ notes: string;
13
+ }): Promise<any> {
14
+ try {
15
+ const config = {
16
+ headers: { Authorization: `Bearer ${this.apiToken}` }
17
+ };
18
+ return await axiosInstance.post(`${GET_CASH_UP}/${storeId}/${id}`, data, config);
19
+ } catch (error) {
20
+ console.error('Error fetching create:', error);
21
+ throw error;
22
+ }
23
+ };
@@ -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
@@ -31,7 +31,7 @@ import * as csvExportEndpoints from './csv';
31
31
  import * as ordersEndpoints from './order';
32
32
  import * as reviewsEndpoints from './reviews';
33
33
  import * as cfdiEndpoints from './cfdi';
34
- import { createCFDI } from './cfdi/post';
34
+ import * as cashupsEndpoints from './cashups';
35
35
 
36
36
  type WashdayClientConstructor = {
37
37
  new(apiToken: string): WashdayClientInstance
@@ -48,7 +48,12 @@ function bindMethods<T>(instance: any, methods: any): T {
48
48
 
49
49
  const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string) {
50
50
  this.apiToken = apiToken;
51
-
51
+ this.cashup = bindMethods(this, {
52
+ getList: cashupsEndpoints.getModule.getList,
53
+ getById: cashupsEndpoints.getModule.getById,
54
+ getPreviewDataForCashClose: cashupsEndpoints.getModule.getPreviewDataForCashClose,
55
+ create: cashupsEndpoints.postModule.create
56
+ });
52
57
  this.cfdi = bindMethods(this, {
53
58
  getCFDIPreviewByOrderId: cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
54
59
  createCFDI: cfdiEndpoints.postModule.createCFDI,
@@ -5,6 +5,7 @@ import axiosInstance from "../axiosInstance";
5
5
  const GET_SET_ORDER = 'api/v2/order';
6
6
 
7
7
  export const getList = async function (this: WashdayClientInstance, params: {
8
+ store: string | undefined,
8
9
  storeId: string | undefined,
9
10
  status: string | undefined,
10
11
  name: string | undefined,
@@ -26,6 +27,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
26
27
  headers: { Authorization: `Bearer ${this.apiToken}` }
27
28
  };
28
29
  const queryParams = generateQueryParamsStr([
30
+ 'store',
29
31
  'storeId',
30
32
  'status',
31
33
  'name',
@@ -30,11 +30,18 @@ import * as csvExportEndpoints from '../api/csv';
30
30
  import * as ordersEndpoints from '../api/order';
31
31
  import * as reviewsEndpoints from '../api/reviews';
32
32
  import * as cfdiEndpoints from '../api/cfdi';
33
+ import * as cashupsEndpoints from '../api/cashups';
33
34
 
34
35
  export interface WashdayClientInstance {
35
36
  apiToken: string;
37
+ cashup: {
38
+ getList: typeof cashupsEndpoints.getModule.getList;
39
+ getById: typeof cashupsEndpoints.getModule.getById;
40
+ getPreviewDataForCashClose: typeof cashupsEndpoints.getModule.getPreviewDataForCashClose;
41
+ create: typeof cashupsEndpoints.postModule.create
42
+ }
36
43
  cfdi: {
37
- getCFDIPreviewByOrderId: typeof cfdiEndpoints.getModule.getCFDIPreviewByOrderId,
44
+ getCFDIPreviewByOrderId: typeof cfdiEndpoints.getModule.getCFDIPreviewByOrderId;
38
45
  createCFDI: typeof cfdiEndpoints.postModule.createCFDI
39
46
  }
40
47
  review: {