washday-sdk 1.2.1 → 1.3.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.
package/dist/api/index.js CHANGED
@@ -42,6 +42,7 @@ import * as outsourcedOrdersEndpoints from './outsourcedOrders';
42
42
  import * as publicsEndpoints from './publics';
43
43
  import { validateUserPin } from "./users/post";
44
44
  import { getAxiosInstance } from "./axiosInstance";
45
+ import * as integrationsEndpoints from './integrations';
45
46
  function bindMethods(instance, methods) {
46
47
  const boundMethods = {};
47
48
  for (const key in methods) {
@@ -323,5 +324,10 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD') {
323
324
  clockOut: attendanceEndpoints.postModule.clockOut,
324
325
  updateById: attendanceEndpoints.putModule.updateById,
325
326
  });
327
+ this.integrations = bindMethods(this, {
328
+ getMPConnectionStatus: integrationsEndpoints.getModule.getMPConnectionStatus,
329
+ startMPOAuthFlow: integrationsEndpoints.postModule.startMPOAuthFlow,
330
+ disconnectMP: integrationsEndpoints.postModule.disconnectMP,
331
+ });
326
332
  };
327
333
  export default WashdayClient;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,23 @@
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
+ const BASE_ROUTER = 'api/integrations';
11
+ export const getMPConnectionStatus = function () {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ try {
14
+ const config = {
15
+ headers: { Authorization: `Bearer ${this.apiToken}` }
16
+ };
17
+ return yield this.axiosInstance.get(`${BASE_ROUTER}/mp/connection`, config);
18
+ }
19
+ catch (error) {
20
+ throw error;
21
+ }
22
+ });
23
+ };
@@ -0,0 +1,3 @@
1
+ // export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
@@ -0,0 +1,36 @@
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
+ const BASE_ROUTER = 'api/integrations';
11
+ export const startMPOAuthFlow = function (data) {
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ try {
14
+ const config = {
15
+ headers: { Authorization: `Bearer ${this.apiToken}` }
16
+ };
17
+ return yield this.axiosInstance.post(`${BASE_ROUTER}/mp/oauth/start`, data, config);
18
+ }
19
+ catch (error) {
20
+ throw error;
21
+ }
22
+ });
23
+ };
24
+ export const disconnectMP = function () {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ try {
27
+ const config = {
28
+ headers: { Authorization: `Bearer ${this.apiToken}` }
29
+ };
30
+ return yield this.axiosInstance.post(`${BASE_ROUTER}/mp/disconnect`, {}, config);
31
+ }
32
+ catch (error) {
33
+ throw error;
34
+ }
35
+ });
36
+ };
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/api/index.ts CHANGED
@@ -44,6 +44,8 @@ import * as outsourcedOrdersEndpoints from './outsourcedOrders';
44
44
  import * as publicsEndpoints from './publics';
45
45
  import { validateUserPin } from "./users/post";
46
46
  import { getAxiosInstance } from "./axiosInstance";
47
+ import * as integrationsEndpoints from './integrations';
48
+
47
49
  type WashdayClientConstructor = {
48
50
  new(apiToken: string): WashdayClientInstance
49
51
  };
@@ -57,7 +59,7 @@ function bindMethods<T>(instance: any, methods: any): T {
57
59
  return boundMethods;
58
60
  }
59
61
 
60
- 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') {
61
63
  this.apiToken = apiToken;
62
64
  this.env = env;
63
65
  this.axiosInstance = this.axiosInstance ? this.axiosInstance : getAxiosInstance(env);
@@ -329,6 +331,11 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
329
331
  clockOut: attendanceEndpoints.postModule.clockOut,
330
332
  updateById: attendanceEndpoints.putModule.updateById,
331
333
  });
334
+ this.integrations = bindMethods(this, {
335
+ getMPConnectionStatus: integrationsEndpoints.getModule.getMPConnectionStatus,
336
+ startMPOAuthFlow: integrationsEndpoints.postModule.startMPOAuthFlow,
337
+ disconnectMP: integrationsEndpoints.postModule.disconnectMP,
338
+ });
332
339
  } as any;
333
340
 
334
341
  export default WashdayClient;
File without changes
@@ -0,0 +1,15 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+
3
+ const BASE_ROUTER = 'api/integrations';
4
+
5
+ export const getMPConnectionStatus = async function (this: WashdayClientInstance): Promise<any> {
6
+ try {
7
+ const config = {
8
+ headers: { Authorization: `Bearer ${this.apiToken}` }
9
+ };
10
+ return await this.axiosInstance.get(`${BASE_ROUTER}/mp/connection`, config);
11
+ }
12
+ catch (error) {
13
+ throw error;
14
+ }
15
+ };
@@ -0,0 +1,3 @@
1
+ // export * as deleteModule from './delete';
2
+ export * as getModule from './get';
3
+ export * as postModule from './post';
@@ -0,0 +1,30 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+
3
+ const BASE_ROUTER = 'api/integrations';
4
+
5
+
6
+ export const startMPOAuthFlow = async function (this: WashdayClientInstance, data: {
7
+ redirectUri: string;
8
+ }): Promise<any> {
9
+ try {
10
+ const config = {
11
+ headers: { Authorization: `Bearer ${this.apiToken}` }
12
+ };
13
+ return await this.axiosInstance.post(`${BASE_ROUTER}/mp/oauth/start`, data, config);
14
+ }
15
+ catch (error) {
16
+ throw error;
17
+ }
18
+ };
19
+
20
+ export const disconnectMP = async function (this: WashdayClientInstance): Promise<any> {
21
+ try {
22
+ const config = {
23
+ headers: { Authorization: `Bearer ${this.apiToken}` }
24
+ };
25
+ return await this.axiosInstance.post(`${BASE_ROUTER}/mp/disconnect`, {}, config);
26
+ }
27
+ catch (error) {
28
+ throw error;
29
+ }
30
+ };
File without changes
@@ -40,6 +40,7 @@ import { deleteUserById } from "../api/users/delete";
40
40
  import * as partnersEndpoints from '../api/partners';
41
41
  import * as outsourcedOrdersEndpoints from '../api/outsourcedOrders';
42
42
  import * as publicsEndpoints from '../api/publics';
43
+ import * as integrationsEndpoints from '../api/integrations';
43
44
  import { validateUserPin } from "../api/users/post";
44
45
  import { AxiosInstance } from "axios";
45
46
 
@@ -313,4 +314,9 @@ export interface WashdayClientInstance {
313
314
  clockOut: typeof attendanceEndpoints.postModule.clockOut;
314
315
  updateById: typeof attendanceEndpoints.putModule.updateById;
315
316
  };
317
+ integrations: {
318
+ getMPConnectionStatus: typeof integrationsEndpoints.getModule.getMPConnectionStatus;
319
+ startMPOAuthFlow: typeof integrationsEndpoints.postModule.startMPOAuthFlow;
320
+ disconnectMP: typeof integrationsEndpoints.postModule.disconnectMP;
321
+ };
316
322
  }