washday-sdk 1.5.6 → 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.
@@ -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);
@@ -17,7 +17,7 @@ export const getList = function (params, options) {
17
17
  headers: { Authorization: `Bearer ${this.apiToken}` },
18
18
  signal: (options === null || options === void 0 ? void 0 : options.signal) || params.signal || undefined
19
19
  };
20
- const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum', 'createdIn'], params);
20
+ const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum', 'createdIn', 'includeOrderMetrics'], params);
21
21
  return yield this.axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
22
22
  }
23
23
  catch (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.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -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) => {
@@ -17,6 +17,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
17
17
  limit: string
18
18
  pageNum: string,
19
19
  createdIn?: string
20
+ includeOrderMetrics?: string
20
21
  signal?: GenericAbortSignal
21
22
  }, options?: { signal?: GenericAbortSignal }): Promise<any> {
22
23
  try {
@@ -24,7 +25,7 @@ export const getList = async function (this: WashdayClientInstance, params: {
24
25
  headers: { Authorization: `Bearer ${this.apiToken}` },
25
26
  signal: options?.signal || params.signal || undefined
26
27
  };
27
- const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum', 'createdIn'], params);
28
+ const queryParams = generateQueryParamsStr(['searchTerm', 'name', 'phone', 'email', 'fromDate', 'toDate', 'limit', 'pageNum', 'createdIn', 'includeOrderMetrics'], params);
28
29
  return await this.axiosInstance.get(`${GET_SET_CUSTOMERS}?${queryParams}`, config);
29
30
  } catch (error) {
30
31
  if (error instanceof Error && (error.name === 'AbortError' || error.name === 'CanceledError')) {
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.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env);
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,
@@ -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;