washday-sdk 1.5.7 → 1.5.8
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/axiosInstance.js +3 -1
- package/dist/api/index.js +4 -2
- package/package.json +1 -1
- package/src/api/axiosInstance.ts +4 -1
- package/src/api/index.ts +5 -3
- package/src/interfaces/Api.ts +2 -0
|
@@ -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);
|
package/dist/api/index.js
CHANGED
|
@@ -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,
|
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) => {
|
package/src/api/index.ts
CHANGED
|
@@ -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,
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -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;
|