washday-sdk 1.5.7 → 1.6.0
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,7 +7,7 @@ const STAGE_BASE_URL = 'https://washday-backend-development.herokuapp.com/';
|
|
|
7
7
|
const PROD_BASE_URL = 'https://washday-backend.herokuapp.com/';
|
|
8
8
|
const BASE_URL = 'https://washday-backend.herokuapp.com/';
|
|
9
9
|
// Function to create or return the singleton instance
|
|
10
|
-
export const getAxiosInstance = (env = 'PROD') => {
|
|
10
|
+
export const getAxiosInstance = (env = 'PROD', clientId = '', clientSecret = '') => {
|
|
11
11
|
let baseURL = BASE_URL;
|
|
12
12
|
switch (env) {
|
|
13
13
|
case 'DEV':
|
|
@@ -48,6 +48,8 @@ export const getAxiosInstance = (env = 'PROD') => {
|
|
|
48
48
|
config.headers['Content-Disposition'] = contentDisposition;
|
|
49
49
|
}
|
|
50
50
|
config.headers['x-request-id'] = v4(); // used to track requests in the backend
|
|
51
|
+
config.headers['x-client-id'] = clientId;
|
|
52
|
+
config.headers['x-client-secret'] = clientSecret;
|
|
51
53
|
return config;
|
|
52
54
|
}, (error) => {
|
|
53
55
|
return Promise.reject(error);
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
const GET_SET_COMPANIES = 'api/company';
|
|
11
|
+
const GET_SET_BILLING = 'api/billing';
|
|
11
12
|
export const updateCompanyTaxInfoCertificates = function (companyId, data) {
|
|
12
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
13
14
|
try {
|
|
@@ -38,3 +39,33 @@ export const updateCFDIOrgLogo = function (companyId, data) {
|
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
41
|
};
|
|
42
|
+
export const enableBillingOverage = function (data) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
try {
|
|
45
|
+
const config = {
|
|
46
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
47
|
+
};
|
|
48
|
+
const response = yield this.axiosInstance.post(`${GET_SET_BILLING}/overage/enable`, data, config);
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error('Error fetching enableBillingOverage:', error);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
export const disableBillingOverage = function (data) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
try {
|
|
60
|
+
const config = {
|
|
61
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
62
|
+
};
|
|
63
|
+
const response = yield this.axiosInstance.post(`${GET_SET_BILLING}/overage/disable`, data, config);
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error('Error fetching disableBillingOverage:', error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
package/dist/api/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesBySt
|
|
|
3
3
|
import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
|
|
4
4
|
import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
|
|
5
5
|
import { getCompanyById } from "./companies/get";
|
|
6
|
-
import { updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
|
|
6
|
+
import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
|
|
7
7
|
import { updateCompanyById, updateCompanyLogoById, updateCompanyTaxInfoById } from "./companies/put";
|
|
8
8
|
import { getCountries } from "./countries/get";
|
|
9
9
|
import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from './discounts/get';
|
|
@@ -52,10 +52,12 @@ function bindMethods(instance, methods) {
|
|
|
52
52
|
}
|
|
53
53
|
return boundMethods;
|
|
54
54
|
}
|
|
55
|
-
const WashdayClient = function WashdayClient(apiToken, env = 'PROD') {
|
|
55
|
+
const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, clientSecret) {
|
|
56
56
|
this.apiToken = apiToken;
|
|
57
57
|
this.env = env;
|
|
58
|
-
this.
|
|
58
|
+
this.clientId = clientId;
|
|
59
|
+
this.clientSecret = clientSecret;
|
|
60
|
+
this.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env, this.clientId, this.clientSecret);
|
|
59
61
|
this.cashup = bindMethods(this, {
|
|
60
62
|
getList: cashupsEndpoints.getModule.getList,
|
|
61
63
|
getById: cashupsEndpoints.getModule.getById,
|
|
@@ -233,7 +235,9 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD') {
|
|
|
233
235
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
234
236
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
235
237
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
236
|
-
updateCFDIOrgLogo: updateCFDIOrgLogo
|
|
238
|
+
updateCFDIOrgLogo: updateCFDIOrgLogo,
|
|
239
|
+
enableBillingOverage: enableBillingOverage,
|
|
240
|
+
disableBillingOverage: disableBillingOverage,
|
|
237
241
|
});
|
|
238
242
|
this.stripe = bindMethods(this, {
|
|
239
243
|
createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
|
package/package.json
CHANGED
package/src/api/axiosInstance.ts
CHANGED
|
@@ -10,7 +10,7 @@ const PROD_BASE_URL: string = 'https://washday-backend.herokuapp.com/';
|
|
|
10
10
|
const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
|
|
11
11
|
|
|
12
12
|
// Function to create or return the singleton instance
|
|
13
|
-
export const getAxiosInstance = (env: string = 'PROD'): AxiosInstance => {
|
|
13
|
+
export const getAxiosInstance = (env: string = 'PROD', clientId: string = '', clientSecret: string = ''): AxiosInstance => {
|
|
14
14
|
let baseURL = BASE_URL;
|
|
15
15
|
switch (env) {
|
|
16
16
|
case 'DEV':
|
|
@@ -54,6 +54,9 @@ export const getAxiosInstance = (env: string = 'PROD'): AxiosInstance => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
config.headers['x-request-id'] = v4(); // used to track requests in the backend
|
|
57
|
+
config.headers['x-client-id'] = clientId;
|
|
58
|
+
config.headers['x-client-secret'] = clientSecret;
|
|
59
|
+
|
|
57
60
|
return config;
|
|
58
61
|
},
|
|
59
62
|
(error) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
2
|
import axiosInstance from "../axiosInstance";
|
|
3
3
|
const GET_SET_COMPANIES = 'api/company';
|
|
4
|
+
const GET_SET_BILLING = 'api/billing';
|
|
4
5
|
|
|
5
6
|
export const updateCompanyTaxInfoCertificates = async function (this: WashdayClientInstance, companyId: string, data: FormData): Promise<any> {
|
|
6
7
|
try {
|
|
@@ -26,4 +27,34 @@ export const updateCFDIOrgLogo = async function (this: WashdayClientInstance, co
|
|
|
26
27
|
console.error('Error fetching updateCFDIOrgLogo:', error);
|
|
27
28
|
throw error;
|
|
28
29
|
}
|
|
29
|
-
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const enableBillingOverage = async function (this: WashdayClientInstance, data: {
|
|
33
|
+
companyId: string;
|
|
34
|
+
}) {
|
|
35
|
+
try {
|
|
36
|
+
const config = {
|
|
37
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
38
|
+
};
|
|
39
|
+
const response = await this.axiosInstance.post(`${GET_SET_BILLING}/overage/enable`, data, config);
|
|
40
|
+
return response;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('Error fetching enableBillingOverage:', error);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const disableBillingOverage = async function (this: WashdayClientInstance, data: {
|
|
48
|
+
companyId: string;
|
|
49
|
+
}) {
|
|
50
|
+
try {
|
|
51
|
+
const config = {
|
|
52
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
53
|
+
};
|
|
54
|
+
const response = await this.axiosInstance.post(`${GET_SET_BILLING}/overage/disable`, data, config);
|
|
55
|
+
return response;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('Error fetching disableBillingOverage:', error);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/api/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesBySt
|
|
|
4
4
|
import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
|
|
5
5
|
import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
|
|
6
6
|
import { getCompanyById } from "./companies/get";
|
|
7
|
-
import { updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
|
|
7
|
+
import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
|
|
8
8
|
import { updateCompanyById, updateCompanyLogoById, updateCompanyTaxInfoById } from "./companies/put";
|
|
9
9
|
import { getCountries } from "./countries/get";
|
|
10
10
|
import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from './discounts/get';
|
|
@@ -47,7 +47,7 @@ import { getAxiosInstance } from "./axiosInstance";
|
|
|
47
47
|
import * as integrationsEndpoints from './integrations';
|
|
48
48
|
|
|
49
49
|
type WashdayClientConstructor = {
|
|
50
|
-
new(apiToken: string): WashdayClientInstance
|
|
50
|
+
new(apiToken: string, env?: string, clientId?: string, clientSecret?: string): WashdayClientInstance
|
|
51
51
|
};
|
|
52
52
|
function bindMethods<T>(instance: any, methods: any): T {
|
|
53
53
|
const boundMethods: any = {};
|
|
@@ -59,10 +59,12 @@ function bindMethods<T>(instance: any, methods: any): T {
|
|
|
59
59
|
return boundMethods;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string, env: string = 'PROD') {
|
|
62
|
+
const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string, env: string = 'PROD', clientId?: string, clientSecret?: string) {
|
|
63
63
|
this.apiToken = apiToken;
|
|
64
64
|
this.env = env;
|
|
65
|
-
this.
|
|
65
|
+
this.clientId = clientId;
|
|
66
|
+
this.clientSecret = clientSecret;
|
|
67
|
+
this.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env, this.clientId, this.clientSecret);
|
|
66
68
|
this.cashup = bindMethods(this, {
|
|
67
69
|
getList: cashupsEndpoints.getModule.getList,
|
|
68
70
|
getById: cashupsEndpoints.getModule.getById,
|
|
@@ -240,7 +242,9 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
240
242
|
updateCompanyLogoById: updateCompanyLogoById,
|
|
241
243
|
updateCompanyTaxInfoById: updateCompanyTaxInfoById,
|
|
242
244
|
updateCompanyTaxInfoCertificates: updateCompanyTaxInfoCertificates,
|
|
243
|
-
updateCFDIOrgLogo: updateCFDIOrgLogo
|
|
245
|
+
updateCFDIOrgLogo: updateCFDIOrgLogo,
|
|
246
|
+
enableBillingOverage: enableBillingOverage,
|
|
247
|
+
disableBillingOverage: disableBillingOverage,
|
|
244
248
|
});
|
|
245
249
|
this.stripe = bindMethods(this, {
|
|
246
250
|
createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesBySt
|
|
|
3
3
|
import { addCashierBoxMovement, createCashierBox } from "../api/cashierbox/post";
|
|
4
4
|
import { updateCashierBoxById, updateCashierBoxMovementById } from "../api/cashierbox/put";
|
|
5
5
|
import { getCompanyById } from "../api/companies/get";
|
|
6
|
-
import { updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "../api/companies/post";
|
|
6
|
+
import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "../api/companies/post";
|
|
7
7
|
import { updateCompanyById, updateCompanyLogoById, updateCompanyTaxInfoById } from "../api/companies/put";
|
|
8
8
|
import { getCountries } from "../api/countries/get";
|
|
9
9
|
import { getAutomaticDiscountById, getAutomaticDiscounts, getAvailableAutomaticDiscounts, getDiscountCodeById, getDiscountCodes, verifyDiscountCode, verifyDiscountCodeCustomersApp } from '../api/discounts/get';
|
|
@@ -47,6 +47,8 @@ import { AxiosInstance } from "axios";
|
|
|
47
47
|
export interface WashdayClientInstance {
|
|
48
48
|
apiToken: string;
|
|
49
49
|
env: string;
|
|
50
|
+
clientId?: string;
|
|
51
|
+
clientSecret?: string;
|
|
50
52
|
axiosInstance: AxiosInstance;
|
|
51
53
|
cashup: {
|
|
52
54
|
getList: typeof cashupsEndpoints.getModule.getList;
|
|
@@ -226,6 +228,8 @@ export interface WashdayClientInstance {
|
|
|
226
228
|
updateCompanyTaxInfoById: typeof updateCompanyTaxInfoById;
|
|
227
229
|
updateCompanyTaxInfoCertificates: typeof updateCompanyTaxInfoCertificates;
|
|
228
230
|
updateCFDIOrgLogo: typeof updateCFDIOrgLogo;
|
|
231
|
+
enableBillingOverage: typeof enableBillingOverage;
|
|
232
|
+
disableBillingOverage: typeof disableBillingOverage;
|
|
229
233
|
};
|
|
230
234
|
stripe: {
|
|
231
235
|
createCreateSuscriptionCheckoutSession: typeof createCreateSuscriptionCheckoutSession;
|