washday-sdk 0.0.16 → 0.0.18

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
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const get_1 = require("./customers/get");
4
4
  const get_2 = require("./stores/get");
5
+ const put_1 = require("./stores/put");
5
6
  const WashdayClient = function WashdayClient(apiToken) {
6
7
  this.apiToken = apiToken;
7
8
  WashdayClient.prototype.customers.apiToken = apiToken;
@@ -13,6 +14,7 @@ WashdayClient.prototype.customers = {
13
14
  };
14
15
  WashdayClient.prototype.stores = {
15
16
  getStores: get_2.getStores,
16
- getStoreById: get_2.getStoreById
17
+ getStoreById: get_2.getStoreById,
18
+ updateStoreById: put_1.updateStoreById
17
19
  };
18
20
  exports.default = WashdayClient;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.updateStoreById = void 0;
16
+ const axiosInstance_1 = __importDefault(require("../axiosInstance"));
17
+ const GET_SET_STORES = 'api/store';
18
+ const REQUEST_PARAMS = {
19
+ token: 'LOGGED_USER_TOKEN',
20
+ };
21
+ const updateStoreById = function (storeId, data) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ var _a;
24
+ try {
25
+ REQUEST_PARAMS.token = this.apiToken;
26
+ const response = yield axiosInstance_1.default.put(`${GET_SET_STORES}/${storeId}`, { params: Object.assign(Object.assign({}, REQUEST_PARAMS), { data }) });
27
+ return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.data) || {};
28
+ }
29
+ catch (error) {
30
+ console.error('Error fetching getStoreById:', error);
31
+ throw error;
32
+ }
33
+ });
34
+ };
35
+ exports.updateStoreById = updateStoreById;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/api/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { WashdayClientInstance } from "../interfaces/Api";
2
2
  import { getCustomerById, getCustomerHighlightsById } from "./customers/get";
3
3
  import { getStoreById, getStores } from "./stores/get";
4
+ import { updateStoreById } from "./stores/put";
4
5
 
5
6
  type WashdayClientConstructor = {
6
7
  new(apiToken: string): {
@@ -21,7 +22,8 @@ WashdayClient.prototype.customers = {
21
22
 
22
23
  WashdayClient.prototype.stores = {
23
24
  getStores: getStores,
24
- getStoreById: getStoreById
25
+ getStoreById: getStoreById,
26
+ updateStoreById: updateStoreById
25
27
  };
26
28
 
27
29
  export default WashdayClient;
@@ -0,0 +1,18 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { IStore } from "../../interfaces/Store";
3
+ import axiosInstance from "../axiosInstance";
4
+ const GET_SET_STORES = 'api/store';
5
+ const REQUEST_PARAMS = {
6
+ token: 'LOGGED_USER_TOKEN',
7
+ };
8
+
9
+ export const updateStoreById = async function (this: WashdayClientInstance, storeId: string, data: IStore): Promise<{ store: IStore }> {
10
+ try {
11
+ REQUEST_PARAMS.token = this.apiToken;
12
+ const response = await axiosInstance.put(`${GET_SET_STORES}/${storeId}`, { params: { ...REQUEST_PARAMS, data } });
13
+ return response.data?.data || {}
14
+ } catch (error) {
15
+ console.error('Error fetching getStoreById:', error);
16
+ throw error;
17
+ }
18
+ };