washday-sdk 1.6.73 → 1.6.75

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.
@@ -89,3 +89,23 @@ export const getAvailableSubscriptionPlans = function () {
89
89
  }
90
90
  });
91
91
  };
92
+ export const getAvailableBillingExtraPackages = function () {
93
+ return __awaiter(this, arguments, void 0, function* (data = {}) {
94
+ try {
95
+ const config = {
96
+ headers: { Authorization: `Bearer ${this.apiToken}` }
97
+ };
98
+ const params = new URLSearchParams();
99
+ if (data.companyId) {
100
+ params.set("companyId", data.companyId);
101
+ }
102
+ const query = params.toString();
103
+ const response = yield this.axiosInstance.get(`${GET_SET_BILLING}/extra-packages${query ? `?${query}` : ""}`, config);
104
+ return response;
105
+ }
106
+ catch (error) {
107
+ console.error('Error fetching getAvailableBillingExtraPackages:', error);
108
+ throw error;
109
+ }
110
+ });
111
+ };
package/dist/api/index.js CHANGED
@@ -2,7 +2,7 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "./cashierbox
2
2
  import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "./cashierbox/get";
3
3
  import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
4
4
  import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
5
- import { getAvailableSubscriptionPlans, getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
5
+ import { getAvailableBillingExtraPackages, getAvailableSubscriptionPlans, getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
6
6
  import { changeSubscriptionPlan, disableBillingOverage, disableCFDIAddon, enableBillingOverage, enableCFDIAddon, previewSubscriptionPlanChange, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
7
7
  import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "./companies/put";
8
8
  import { getCountries } from "./countries/get";
@@ -290,6 +290,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
290
290
  disableCFDIAddon: disableCFDIAddon,
291
291
  getCFDIAddonStatus: getCFDIAddonStatus,
292
292
  getAvailableSubscriptionPlans: getAvailableSubscriptionPlans,
293
+ getAvailableBillingExtraPackages: getAvailableBillingExtraPackages,
293
294
  previewSubscriptionPlanChange: previewSubscriptionPlanChange,
294
295
  changeSubscriptionPlan: changeSubscriptionPlan,
295
296
  });
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  const GET_SET_STRIPE = 'api/stripe';
11
- const GENERATE_CHECKOUT_SESSION = 'api/orders/create-checkout-session';
11
+ const GENERATE_EXTRA_PACKAGE_CHECKOUT_SESSION = 'api/billing/extra-packages/checkout';
12
12
  export const createCreateSuscriptionCheckoutSession = function (data) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  try {
@@ -61,7 +61,7 @@ export const createGetMoreCheckoutSession = function (data) {
61
61
  const config = {
62
62
  headers: { Authorization: `Bearer ${this.apiToken}` }
63
63
  };
64
- return yield this.axiosInstance.post(`${GENERATE_CHECKOUT_SESSION}`, data, config);
64
+ return yield this.axiosInstance.post(`${GENERATE_EXTRA_PACKAGE_CHECKOUT_SESSION}`, data, config);
65
65
  }
66
66
  catch (error) {
67
67
  console.error('Error fetching createGetMoreCheckoutSession:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.73",
3
+ "version": "1.6.75",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
  import {
3
+ GetAvailableBillingExtraPackagesRequest,
3
4
  GetAvailableSubscriptionPlansRequest,
4
5
  GetCFDIAddonStatusRequest,
5
6
  } from "../../interfaces/Company";
@@ -85,3 +86,27 @@ export const getAvailableSubscriptionPlans = async function (
85
86
  throw error;
86
87
  }
87
88
  };
89
+
90
+ export const getAvailableBillingExtraPackages = async function (
91
+ this: WashdayClientInstance,
92
+ data: GetAvailableBillingExtraPackagesRequest = {},
93
+ ): Promise<any> {
94
+ try {
95
+ const config = {
96
+ headers: { Authorization: `Bearer ${this.apiToken}` }
97
+ };
98
+ const params = new URLSearchParams();
99
+ if (data.companyId) {
100
+ params.set("companyId", data.companyId);
101
+ }
102
+ const query = params.toString();
103
+ const response = await this.axiosInstance.get(
104
+ `${GET_SET_BILLING}/extra-packages${query ? `?${query}` : ""}`,
105
+ config,
106
+ );
107
+ return response;
108
+ } catch (error) {
109
+ console.error('Error fetching getAvailableBillingExtraPackages:', error);
110
+ throw error;
111
+ }
112
+ };
package/src/api/index.ts CHANGED
@@ -3,7 +3,7 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "./cashierbox
3
3
  import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "./cashierbox/get";
4
4
  import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
5
5
  import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
6
- import { getAvailableSubscriptionPlans, getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
6
+ import { getAvailableBillingExtraPackages, getAvailableSubscriptionPlans, getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
7
7
  import { changeSubscriptionPlan, disableBillingOverage, disableCFDIAddon, enableBillingOverage, enableCFDIAddon, previewSubscriptionPlanChange, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
8
8
  import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "./companies/put";
9
9
  import { getCountries } from "./countries/get";
@@ -297,6 +297,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
297
297
  disableCFDIAddon: disableCFDIAddon,
298
298
  getCFDIAddonStatus: getCFDIAddonStatus,
299
299
  getAvailableSubscriptionPlans: getAvailableSubscriptionPlans,
300
+ getAvailableBillingExtraPackages: getAvailableBillingExtraPackages,
300
301
  previewSubscriptionPlanChange: previewSubscriptionPlanChange,
301
302
  changeSubscriptionPlan: changeSubscriptionPlan,
302
303
  });
@@ -2,16 +2,22 @@ import { WashdayClientInstance } from "../../interfaces/Api";
2
2
  import axiosInstance from "../axiosInstance";
3
3
  const GET_SET_OUTSOURCED_ORDERS = 'api/outsourced-orders';
4
4
 
5
- export const createOutsourcedOrder = async function (this: WashdayClientInstance, data: {
5
+ export type OutsourcedOrderDateInput = Date | string;
6
+
7
+ export type CreateOutsourcedOrderPayload = {
6
8
  partner?: string;
7
9
  outsourcedStatus?: "pending" | "in_process" | "returned";
8
- sentDate?: Date;
9
- receivedDate?: Date;
10
+ sentDate?: OutsourcedOrderDateInput;
11
+ receivedDate?: OutsourcedOrderDateInput;
10
12
  externalOrderId?: string;
11
13
  order: string;
12
14
  orderProduct?: string;
13
15
  store: string;
14
- }): Promise<any> {
16
+ partnerNotes?: string;
17
+ internalNotes?: string;
18
+ };
19
+
20
+ export const createOutsourcedOrder = async function (this: WashdayClientInstance, data: CreateOutsourcedOrderPayload): Promise<any> {
15
21
  try {
16
22
  const config = {
17
23
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -1,14 +1,19 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
  import axiosInstance from "../axiosInstance";
3
+ import { OutsourcedOrderDateInput } from "./post";
3
4
  const GET_SET_OUTSOURCED_ORDERS = 'api/outsourced-orders';
4
5
 
5
- export const updateOutsourcedOrderById = async function (this: WashdayClientInstance, id: string, data: {
6
+ export type UpdateOutsourcedOrderPayload = {
6
7
  partner?: string,
7
8
  outsourcedStatus?: "pending" | "in_process" | "returned",
8
- sentDate?: Date,
9
- receivedDate?: Date,
9
+ sentDate?: OutsourcedOrderDateInput,
10
+ receivedDate?: OutsourcedOrderDateInput,
10
11
  externalOrderId?: string,
11
- }): Promise<any> {
12
+ partnerNotes?: string,
13
+ internalNotes?: string,
14
+ };
15
+
16
+ export const updateOutsourcedOrderById = async function (this: WashdayClientInstance, id: string, data: UpdateOutsourcedOrderPayload): Promise<any> {
12
17
  try {
13
18
  const config = {
14
19
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -3,12 +3,14 @@ import { IAddress } from "../../interfaces/Customer";
3
3
  import axiosInstance from "../axiosInstance";
4
4
  const GET_SET_PARTNERS = 'api/partners';
5
5
 
6
- export const createPartner = async function (this: WashdayClientInstance, data: {
6
+ export type CreatePartnerPayload = {
7
7
  name: string,
8
8
  contactEmail?: string,
9
9
  contactPhone?: string,
10
10
  address?: IAddress
11
- }): Promise<any> {
11
+ };
12
+
13
+ export const createPartner = async function (this: WashdayClientInstance, data: CreatePartnerPayload): Promise<any> {
12
14
  try {
13
15
  const config = {
14
16
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -3,12 +3,14 @@ import { IAddress } from "../../interfaces/Customer";
3
3
  import axiosInstance from "../axiosInstance";
4
4
  const GET_SET_PARTNERS = 'api/partners';
5
5
 
6
- export const updatePartnerById = async function (this: WashdayClientInstance, id: string, data: {
7
- name: string,
6
+ export type UpdatePartnerPayload = {
7
+ name?: string,
8
8
  contactEmail?: string,
9
9
  contactPhone?: string,
10
10
  address?: IAddress
11
- }): Promise<any> {
11
+ };
12
+
13
+ export const updatePartnerById = async function (this: WashdayClientInstance, id: string, data: UpdatePartnerPayload): Promise<any> {
12
14
  try {
13
15
  const config = {
14
16
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -1,4 +1,5 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { IProductInvoiceModuleSettings } from "../../interfaces/Product";
2
3
  import axiosInstance from "../axiosInstance";
3
4
  const GET_SET_PRODUCTS_SUPPLY = 'api/product-supply';
4
5
  const GET_SET_PRODUCTS = 'api/product';
@@ -25,6 +26,7 @@ export const create = async function (this: WashdayClientInstance, data: {
25
26
  invoice_product_key: string;
26
27
  invoice_product_unit_key: string;
27
28
  invoice_product_unit_name: string;
29
+ invoiceModuleSettings?: IProductInvoiceModuleSettings;
28
30
  productSupplies: Array<any>
29
31
  isOutsourced?: boolean
30
32
  outsourcingPartner?: string
@@ -1,4 +1,5 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { IProductInvoiceModuleSettings } from "../../interfaces/Product";
2
3
  import axiosInstance from "../axiosInstance";
3
4
  const GET_SET_PRODUCTS = 'api/product';
4
5
 
@@ -34,6 +35,7 @@ export const updateById = async function (this: WashdayClientInstance, id: strin
34
35
  invoice_description?: string,
35
36
  invoice_product_unit_key?: string
36
37
  invoice_product_unit_name?: string
38
+ invoiceModuleSettings?: IProductInvoiceModuleSettings
37
39
  isOutsourced?: boolean
38
40
  outsourcingPartner?: string,
39
41
  barcode?: string
@@ -1,7 +1,7 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
2
  import { StripeReturnUrlOptions } from "../../interfaces/DomainUrls";
3
3
  const GET_SET_STRIPE = 'api/stripe';
4
- const GENERATE_CHECKOUT_SESSION = 'api/orders/create-checkout-session';
4
+ const GENERATE_EXTRA_PACKAGE_CHECKOUT_SESSION = 'api/billing/extra-packages/checkout';
5
5
 
6
6
  export interface CreateSubscriptionCheckoutSessionRequest extends StripeReturnUrlOptions {
7
7
  priceId: string;
@@ -9,7 +9,8 @@ export interface CreateSubscriptionCheckoutSessionRequest extends StripeReturnUr
9
9
  }
10
10
 
11
11
  export interface CreateGetMoreCheckoutSessionRequest extends StripeReturnUrlOptions {
12
- priceId: string;
12
+ companyId: string;
13
+ packageKey: string;
13
14
  }
14
15
 
15
16
  export interface CreateCFDISubscriptionCheckoutSessionRequest extends StripeReturnUrlOptions {}
@@ -73,7 +74,7 @@ export const createGetMoreCheckoutSession = async function (
73
74
  const config = {
74
75
  headers: { Authorization: `Bearer ${this.apiToken}` }
75
76
  };
76
- return await this.axiosInstance.post(`${GENERATE_CHECKOUT_SESSION}`, data, config);
77
+ return await this.axiosInstance.post(`${GENERATE_EXTRA_PACKAGE_CHECKOUT_SESSION}`, data, config);
77
78
  } catch (error) {
78
79
  console.error('Error fetching createGetMoreCheckoutSession:', error);
79
80
  throw error;
@@ -2,7 +2,7 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "../api/cashi
2
2
  import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "../api/cashierbox/get";
3
3
  import { addCashierBoxMovement, createCashierBox } from "../api/cashierbox/post";
4
4
  import { updateCashierBoxById, updateCashierBoxMovementById } from "../api/cashierbox/put";
5
- import { getAvailableSubscriptionPlans, getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "../api/companies/get";
5
+ import { getAvailableBillingExtraPackages, getAvailableSubscriptionPlans, getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "../api/companies/get";
6
6
  import { changeSubscriptionPlan, disableBillingOverage, disableCFDIAddon, enableBillingOverage, enableCFDIAddon, previewSubscriptionPlanChange, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "../api/companies/post";
7
7
  import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "../api/companies/put";
8
8
  import { getCountries } from "../api/countries/get";
@@ -282,6 +282,7 @@ export interface WashdayClientInstance {
282
282
  disableCFDIAddon: typeof disableCFDIAddon;
283
283
  getCFDIAddonStatus: typeof getCFDIAddonStatus;
284
284
  getAvailableSubscriptionPlans: typeof getAvailableSubscriptionPlans;
285
+ getAvailableBillingExtraPackages: typeof getAvailableBillingExtraPackages;
285
286
  previewSubscriptionPlanChange: typeof previewSubscriptionPlanChange;
286
287
  changeSubscriptionPlan: typeof changeSubscriptionPlan;
287
288
  };
@@ -83,6 +83,34 @@ export interface AvailableSubscriptionPlansResponse {
83
83
  plans: AvailableSubscriptionPlan[];
84
84
  }
85
85
 
86
+ export type BillingExtraPackageKey =
87
+ | "extra_orders_100"
88
+ | "extra_orders_150"
89
+ | "extra_orders_200"
90
+ | "extra_orders_400"
91
+ | "sms_credits_300"
92
+ | "sms_credits_600"
93
+ | "sms_credits_1500";
94
+
95
+ export interface GetAvailableBillingExtraPackagesRequest {
96
+ companyId?: string;
97
+ }
98
+
99
+ export interface BillingExtraPackage {
100
+ key: BillingExtraPackageKey;
101
+ quantity: number;
102
+ amountMinor: number;
103
+ displayPrice: string;
104
+ description: string;
105
+ }
106
+
107
+ export interface AvailableBillingExtraPackagesResponse {
108
+ country: string;
109
+ currency: string;
110
+ orders: BillingExtraPackage[];
111
+ sms: BillingExtraPackage[];
112
+ }
113
+
86
114
  export interface PreviewSubscriptionPlanChangeRequest {
87
115
  companyId?: string;
88
116
  targetPlan: SubscriptionPlanChangePlan;
@@ -29,6 +29,22 @@ export interface IPriceOption {
29
29
  isActive?: boolean,
30
30
  }
31
31
 
32
+ export interface IProductCfdiInvoiceModuleSettings {
33
+ description?: string,
34
+ productKey?: string,
35
+ unitKey?: string,
36
+ unitName?: string,
37
+ }
38
+
39
+ export interface IProductSunatInvoiceModuleSettings {
40
+ enabled?: boolean,
41
+ }
42
+
43
+ export interface IProductInvoiceModuleSettings {
44
+ cfdi?: IProductCfdiInvoiceModuleSettings,
45
+ sunat?: IProductSunatInvoiceModuleSettings,
46
+ }
47
+
32
48
 
33
49
  export interface IProduct {
34
50
  _id?: string
@@ -55,6 +71,7 @@ export interface IProduct {
55
71
  invoice_product_key?: string,
56
72
  invoice_product_unit_key?: string,
57
73
  invoice_product_unit_name?: string,
74
+ invoiceModuleSettings?: IProductInvoiceModuleSettings,
58
75
  priceOptions?: IPriceOption[],
59
76
  }
60
77
 
@@ -1,4 +1,7 @@
1
- import { getAvailableSubscriptionPlans } from "../src/api/companies/get";
1
+ import {
2
+ getAvailableBillingExtraPackages,
3
+ getAvailableSubscriptionPlans,
4
+ } from "../src/api/companies/get";
2
5
  import {
3
6
  changeSubscriptionPlan,
4
7
  previewSubscriptionPlanChange,
@@ -39,6 +42,21 @@ describe("subscription plan change company endpoints", () => {
39
42
  );
40
43
  });
41
44
 
45
+ it("fetches extra billing packages through the billing endpoint", async () => {
46
+ const get = jest.fn().mockResolvedValue({ data: { data: { orders: [], sms: [] } } });
47
+ const client = {
48
+ apiToken: "token-1",
49
+ axiosInstance: { get },
50
+ } as any;
51
+
52
+ await getAvailableBillingExtraPackages.call(client, { companyId: "company-1" });
53
+
54
+ expect(get).toHaveBeenCalledWith(
55
+ "api/billing/extra-packages?companyId=company-1",
56
+ { headers: { Authorization: "Bearer token-1" } },
57
+ );
58
+ });
59
+
42
60
  it("previews a subscription plan change through the billing endpoint", async () => {
43
61
  const post = jest.fn().mockResolvedValue({
44
62
  data: {
@@ -38,14 +38,16 @@ describe("stripe checkout return URL options", () => {
38
38
  } as any;
39
39
 
40
40
  await createGetMoreCheckoutSession.call(client, {
41
- priceId: "price_extra",
41
+ companyId: "company-1",
42
+ packageKey: "extra_orders_100",
42
43
  returnToOrigin: "https://app.washday.mx",
43
44
  });
44
45
 
45
46
  expect(post).toHaveBeenCalledWith(
46
- "api/orders/create-checkout-session",
47
+ "api/billing/extra-packages/checkout",
47
48
  {
48
- priceId: "price_extra",
49
+ companyId: "company-1",
50
+ packageKey: "extra_orders_100",
49
51
  returnToOrigin: "https://app.washday.mx",
50
52
  },
51
53
  {