washday-sdk 1.6.58 → 1.6.59

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
@@ -22,7 +22,7 @@ import { deleteSupplyById } from "./supplies/delete";
22
22
  import { getSupplies, getSupplyById, getSupplyHistory } from "./supplies/get";
23
23
  import { createSupply } from "./supplies/post";
24
24
  import { addSupplyStock, updateSupplyById } from "./supplies/put";
25
- import { updateUserById } from "./users/put";
25
+ import { updatePushNotificationTokenDriversApp, updateUserById } from "./users/put";
26
26
  import { getUserStoreAccess } from "./users/get";
27
27
  import * as inventoryEndpoints from './inventory';
28
28
  import * as sectionsEndpoints from './sections';
@@ -214,6 +214,7 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
214
214
  });
215
215
  this.users = bindMethods(this, {
216
216
  updateUserById: updateUserById,
217
+ updatePushNotificationTokenDriversApp: updatePushNotificationTokenDriversApp,
217
218
  getUserStoreAccess: getUserStoreAccess,
218
219
  deleteUserById: deleteUserById,
219
220
  validateUserPin: validateUserPin,
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  const GET_SET_USER = 'api/user';
11
+ const DRIVERS_APP_PUSH_TOKEN_ENDPOINT = 'api/driversapp/users/me/push-token';
11
12
  const REQUEST_PARAMS = {
12
13
  token: 'LOGGED_USER_TOKEN',
13
14
  };
@@ -26,3 +27,18 @@ export const updateUserById = function (userId, data) {
26
27
  }
27
28
  });
28
29
  };
30
+ export const updatePushNotificationTokenDriversApp = function (data) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ try {
33
+ const config = {
34
+ headers: { Authorization: `Bearer ${this.apiToken}` }
35
+ };
36
+ const response = yield this.axiosInstance.put(DRIVERS_APP_PUSH_TOKEN_ENDPOINT, data, config);
37
+ return response.data || {};
38
+ }
39
+ catch (error) {
40
+ console.error('Error updating drivers app push notification token:', error);
41
+ throw error;
42
+ }
43
+ });
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.58",
3
+ "version": "1.6.59",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/api/index.ts CHANGED
@@ -23,7 +23,7 @@ import { deleteSupplyById } from "./supplies/delete";
23
23
  import { getSupplies, getSupplyById, getSupplyHistory } from "./supplies/get";
24
24
  import { createSupply } from "./supplies/post";
25
25
  import { addSupplyStock, updateSupplyById } from "./supplies/put";
26
- import { updateUserById } from "./users/put";
26
+ import { updatePushNotificationTokenDriversApp, updateUserById } from "./users/put";
27
27
  import { getUserStoreAccess } from "./users/get";
28
28
  import * as inventoryEndpoints from './inventory';
29
29
  import * as sectionsEndpoints from './sections';
@@ -221,6 +221,7 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
221
221
  });
222
222
  this.users = bindMethods(this, {
223
223
  updateUserById: updateUserById,
224
+ updatePushNotificationTokenDriversApp: updatePushNotificationTokenDriversApp,
224
225
  getUserStoreAccess: getUserStoreAccess,
225
226
  deleteUserById: deleteUserById,
226
227
  validateUserPin: validateUserPin,
@@ -3,6 +3,7 @@ import { IStore } from "../../interfaces/Store";
3
3
  import { IUser } from "../../interfaces/User";
4
4
  import axiosInstance from "../axiosInstance";
5
5
  const GET_SET_USER = 'api/user';
6
+ const DRIVERS_APP_PUSH_TOKEN_ENDPOINT = 'api/driversapp/users/me/push-token';
6
7
  const REQUEST_PARAMS = {
7
8
  token: 'LOGGED_USER_TOKEN',
8
9
  };
@@ -22,6 +23,10 @@ interface userDTO {
22
23
  confirmNewPassword?: string;
23
24
  }
24
25
 
26
+ export interface updatePushNotificationTokenDriversAppDTO {
27
+ driversAppPushNotificationToken: string | null;
28
+ }
29
+
25
30
  export const updateUserById = async function (this: WashdayClientInstance, userId: string, data: userDTO): Promise<any> {
26
31
  try {
27
32
  const config = {
@@ -34,3 +39,19 @@ export const updateUserById = async function (this: WashdayClientInstance, userI
34
39
  throw error;
35
40
  }
36
41
  };
42
+
43
+ export const updatePushNotificationTokenDriversApp = async function (
44
+ this: WashdayClientInstance,
45
+ data: updatePushNotificationTokenDriversAppDTO
46
+ ): Promise<any> {
47
+ try {
48
+ const config = {
49
+ headers: { Authorization: `Bearer ${this.apiToken}` }
50
+ };
51
+ const response = await this.axiosInstance.put(DRIVERS_APP_PUSH_TOKEN_ENDPOINT, data, config);
52
+ return response.data || {}
53
+ } catch (error) {
54
+ console.error('Error updating drivers app push notification token:', error);
55
+ throw error;
56
+ }
57
+ };
@@ -22,7 +22,7 @@ import { deleteSupplyById } from "../api/supplies/delete";
22
22
  import { getSupplies, getSupplyById, getSupplyHistory } from "../api/supplies/get";
23
23
  import { createSupply } from "../api/supplies/post";
24
24
  import { addSupplyStock, updateSupplyById } from "../api/supplies/put";
25
- import { updateUserById } from "../api/users/put";
25
+ import { updatePushNotificationTokenDriversApp, updateUserById } from "../api/users/put";
26
26
  import { getUserStoreAccess } from "../api/users/get";
27
27
  import * as inventoryEndpoints from '../api/inventory';
28
28
  import * as sectionsEndpoints from '../api/sections';
@@ -206,6 +206,7 @@ export interface WashdayClientInstance {
206
206
  };
207
207
  users: {
208
208
  updateUserById: typeof updateUserById;
209
+ updatePushNotificationTokenDriversApp: typeof updatePushNotificationTokenDriversApp;
209
210
  getUserStoreAccess: typeof getUserStoreAccess;
210
211
  deleteUserById: typeof deleteUserById;
211
212
  validateUserPin: typeof validateUserPin;
@@ -20,6 +20,8 @@ export interface IUser {
20
20
  verified: boolean,
21
21
  cashierBox?: ICashierBox | string | null,
22
22
  printer?: IPrinterConfig,
23
+ pushNotificationToken?: string,
24
+ driversAppPushNotificationToken?: string,
23
25
  }
24
26
 
25
27
  export interface ISecretCode {
@@ -40,4 +42,4 @@ export interface ISuperAdmin extends IUser {
40
42
  export interface IStaff extends IUser {
41
43
  store: IStore | string,
42
44
  cashierBox: ICashierBox | string,
43
- }
45
+ }
@@ -0,0 +1,44 @@
1
+ import { WashdayClient } from "../src";
2
+ import { updatePushNotificationTokenDriversApp } from "../src/api/users/put";
3
+
4
+ describe("driver app user push token api", () => {
5
+ it("updates the driver app push token through the driver-scoped endpoint", async () => {
6
+ const put = jest.fn().mockResolvedValue({ data: { data: { ok: true } } });
7
+ const client = {
8
+ apiToken: "token-123",
9
+ axiosInstance: { put },
10
+ } as any;
11
+
12
+ await updatePushNotificationTokenDriversApp.call(client, {
13
+ driversAppPushNotificationToken: "ExponentPushToken[driver]",
14
+ });
15
+
16
+ expect(put).toHaveBeenCalledWith(
17
+ "api/driversapp/users/me/push-token",
18
+ { driversAppPushNotificationToken: "ExponentPushToken[driver]" },
19
+ {
20
+ headers: { Authorization: "Bearer token-123" },
21
+ }
22
+ );
23
+ });
24
+
25
+ it("exposes updatePushNotificationTokenDriversApp through the users module", async () => {
26
+ const put = jest.fn().mockResolvedValue({ data: { data: { ok: true } } });
27
+ const client = new WashdayClient("token-123", "DEV") as any;
28
+ client.axiosInstance = { put };
29
+
30
+ expect(typeof client.users.updatePushNotificationTokenDriversApp).toBe("function");
31
+
32
+ await client.users.updatePushNotificationTokenDriversApp({
33
+ driversAppPushNotificationToken: null,
34
+ });
35
+
36
+ expect(put).toHaveBeenCalledWith(
37
+ "api/driversapp/users/me/push-token",
38
+ { driversAppPushNotificationToken: null },
39
+ {
40
+ headers: { Authorization: "Bearer token-123" },
41
+ }
42
+ );
43
+ });
44
+ });