washday-sdk 0.0.72 → 0.0.73

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/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 ordersEndpoints from './order';
30
31
  const WashdayClient = function WashdayClient(apiToken) {
31
32
  this.apiToken = apiToken;
32
33
  WashdayClient.prototype.customers.apiToken = apiToken;
@@ -44,6 +45,15 @@ const WashdayClient = function WashdayClient(apiToken) {
44
45
  WashdayClient.prototype.supplies.apiToken = apiToken;
45
46
  WashdayClient.prototype.inventory.apiToken = apiToken;
46
47
  WashdayClient.prototype.csv.apiToken = apiToken;
48
+ WashdayClient.prototype.orders.apiToken = apiToken;
49
+ };
50
+ WashdayClient.prototype.orders = {
51
+ getList: ordersEndpoints.getModule.getList,
52
+ getById: ordersEndpoints.getModule.getById,
53
+ updateById: ordersEndpoints.putModule.updateById,
54
+ updatePaymentLineById: ordersEndpoints.putModule.updatePaymentLineById,
55
+ createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
56
+ deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
47
57
  };
48
58
  WashdayClient.prototype.customers = {
49
59
  getCustomers: customersEndpoints.getModule.getList,
@@ -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_ORDER_PAYMENTLINES = (orderId) => `/api/v2/order/${orderId}/paymentLines`;
12
+ export const deletePaymentLineById = function (orderId, id) {
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_ORDER_PAYMENTLINES(orderId)}/${id}`, config);
19
+ }
20
+ catch (error) {
21
+ console.error('Error fetching deleteById:', error);
22
+ throw error;
23
+ }
24
+ });
25
+ };
@@ -0,0 +1,58 @@
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_SET_ORDER = 'api/v2/order';
13
+ const GET_SET_ORDER_PAYMENTLINES = (orderId) => `/api/v2/order/${orderId}/paymentLines`;
14
+ export const getList = function (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
+ 'storeId',
22
+ 'status',
23
+ 'name',
24
+ 'phone',
25
+ 'email',
26
+ 'fromDate',
27
+ 'toDate',
28
+ 'sequence',
29
+ 'pageNum',
30
+ 'limit',
31
+ 'sequenceSort',
32
+ 'cleanedDateTime',
33
+ 'readyDateTime',
34
+ 'collectedDateTime',
35
+ 'q',
36
+ ], params);
37
+ return yield axiosInstance.get(`${GET_SET_ORDER}?${queryParams}`, config);
38
+ }
39
+ catch (error) {
40
+ console.error('Error fetching getList orders:', error);
41
+ throw error;
42
+ }
43
+ });
44
+ };
45
+ export const getById = function (id) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ try {
48
+ const config = {
49
+ headers: { Authorization: `Bearer ${this.apiToken}` }
50
+ };
51
+ return yield axiosInstance.get(`${GET_SET_ORDER}/${id}`, config);
52
+ }
53
+ catch (error) {
54
+ console.error('Error fetching:', error);
55
+ throw error;
56
+ }
57
+ });
58
+ };
@@ -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,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_SET_CUSTOMERS = 'api/customer';
12
+ const GET_SET_ORDER_PAYMENTLINES = (orderId) => `/api/v2/order/${orderId}/paymentLines`;
13
+ export const createPaymentLine = function (id, data) {
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.post(`${GET_SET_ORDER_PAYMENTLINES(id)}`, data, config);
20
+ }
21
+ catch (error) {
22
+ console.error('Error fetching create:', error);
23
+ throw error;
24
+ }
25
+ });
26
+ };
@@ -0,0 +1,40 @@
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_ORDER = 'api/v2/order';
12
+ const GET_SET_ORDER_PAYMENTLINES = (orderId) => `/api/v2/order/${orderId}/paymentLines`;
13
+ export const updateById = function (id, data) {
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.put(`${GET_SET_ORDER}/${id}`, data, config);
20
+ }
21
+ catch (error) {
22
+ console.error('Error fetching updateById:', error);
23
+ throw error;
24
+ }
25
+ });
26
+ };
27
+ export const updatePaymentLineById = function (orderId, id, 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.put(`${GET_SET_ORDER_PAYMENTLINES(orderId)}/${id}`, data, config);
34
+ }
35
+ catch (error) {
36
+ console.error('Error fetching updateById:', error);
37
+ throw error;
38
+ }
39
+ });
40
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.72",
3
+ "version": "0.0.73",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/api/index.ts CHANGED
@@ -29,6 +29,7 @@ import * as sectionsEndpoints from './sections';
29
29
  import * as productsEndpoints from './products';
30
30
  import * as customersEndpoints from './customers';
31
31
  import * as csvExportEndpoints from './csv';
32
+ import * as ordersEndpoints from './order';
32
33
 
33
34
  type WashdayClientConstructor = {
34
35
  new(apiToken: string): {
@@ -53,8 +54,18 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
53
54
  WashdayClient.prototype.supplies.apiToken = apiToken;
54
55
  WashdayClient.prototype.inventory.apiToken = apiToken;
55
56
  WashdayClient.prototype.csv.apiToken = apiToken;
57
+ WashdayClient.prototype.orders.apiToken = apiToken;
56
58
  } as any;
57
59
 
60
+ WashdayClient.prototype.orders = {
61
+ getList: ordersEndpoints.getModule.getList,
62
+ getById: ordersEndpoints.getModule.getById,
63
+ updateById: ordersEndpoints.putModule.updateById,
64
+ updatePaymentLineById: ordersEndpoints.putModule.updatePaymentLineById,
65
+ createPaymentLine: ordersEndpoints.postModule.createPaymentLine,
66
+ deletePaymentLineById: ordersEndpoints.deleteModule.deletePaymentLineById,
67
+ };
68
+
58
69
  WashdayClient.prototype.customers = {
59
70
  getCustomers: customersEndpoints.getModule.getList,
60
71
  getCustomerById: customersEndpoints.getModule.getCustomerById,
@@ -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,64 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { ICustomer } from "../../interfaces/Customer";
3
+ import { IOrder, IOrderInfo } from "../../interfaces/Order";
4
+ import { generateQueryParamsStr } from "../../utils/apiUtils";
5
+ import axiosInstance from "../axiosInstance";
6
+ const GET_SET_ORDER = 'api/v2/order';
7
+ const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
8
+
9
+ export const getList = async function (this: WashdayClientInstance, params: {
10
+ storeId: string | undefined,
11
+ status: string | undefined,
12
+ name: string | undefined,
13
+ phone: string | undefined,
14
+ email: string | undefined,
15
+ fromDate: string | undefined,
16
+ toDate: string | undefined,
17
+ sequence: string | undefined,
18
+ pageNum: string | undefined,
19
+ limit: string | undefined,
20
+ sequenceSort: string,
21
+ cleanedDateTime: string | undefined,
22
+ readyDateTime: string | undefined,
23
+ collectedDateTime: string | undefined,
24
+ q: string | undefined
25
+ }): Promise<any> {
26
+ try {
27
+ const config = {
28
+ headers: { Authorization: `Bearer ${this.apiToken}` }
29
+ };
30
+ const queryParams = generateQueryParamsStr([
31
+ 'storeId',
32
+ 'status',
33
+ 'name',
34
+ 'phone',
35
+ 'email',
36
+ 'fromDate',
37
+ 'toDate',
38
+ 'sequence',
39
+ 'pageNum',
40
+ 'limit',
41
+ 'sequenceSort',
42
+ 'cleanedDateTime',
43
+ 'readyDateTime',
44
+ 'collectedDateTime',
45
+ 'q',
46
+ ], params);
47
+ return await axiosInstance.get(`${GET_SET_ORDER}?${queryParams}`, config);
48
+ } catch (error) {
49
+ console.error('Error fetching getList orders:', error);
50
+ throw error;
51
+ }
52
+ };
53
+
54
+ export const getById = async function (this: WashdayClientInstance, id: string): Promise<IOrder> {
55
+ try {
56
+ const config = {
57
+ headers: { Authorization: `Bearer ${this.apiToken}` }
58
+ };
59
+ return await axiosInstance.get(`${GET_SET_ORDER}/${id}`, config);
60
+ } catch (error) {
61
+ console.error('Error fetching:', error);
62
+ throw error;
63
+ }
64
+ }
@@ -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,21 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import axiosInstance from "../axiosInstance";
3
+ const GET_SET_CUSTOMERS = 'api/customer';
4
+ const GET_SET_ORDER_PAYMENTLINES = (orderId: string) => `/api/v2/order/${orderId}/paymentLines`;
5
+
6
+ export const createPaymentLine = async function (this: WashdayClientInstance, id: string, data: {
7
+ amountPaid: number,
8
+ cashierBox: string,
9
+ paymentMethod: string
10
+ paymentDate: Date
11
+ }): Promise<any> {
12
+ try {
13
+ const config = {
14
+ headers: { Authorization: `Bearer ${this.apiToken}` }
15
+ };
16
+ return await axiosInstance.post(`${GET_SET_ORDER_PAYMENTLINES(id)}`, data, config);
17
+ } catch (error) {
18
+ console.error('Error fetching create:', error);
19
+ throw error;
20
+ }
21
+ };
@@ -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
+ };