washday-sdk 0.0.9 → 0.0.11

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/babel.config.js CHANGED
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- presets: [
3
- ['@babel/preset-env', {targets: {node: 'current'}}],
4
- '@babel/preset-typescript',
5
- ],
6
- };
7
-
1
+ module.exports = {
2
+ presets: [
3
+ ['@babel/preset-env', {targets: {node: 'current'}}],
4
+ '@babel/preset-typescript',
5
+ ],
6
+ };
7
+
8
8
 
@@ -40,7 +40,7 @@ const getCustomerHighlightsById = function (customerId) {
40
40
  return response.data;
41
41
  }
42
42
  catch (error) {
43
- console.error('Error fetching customer:', error);
43
+ console.error('Error fetching getCustomerHighlightsById:', error);
44
44
  throw error;
45
45
  }
46
46
  });
package/dist/api/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const get_1 = require("./customers/get");
4
+ const get_2 = require("./stores/get");
4
5
  const WashdayClient = function WashdayClient(apiToken) {
5
6
  this.apiToken = apiToken;
6
7
  WashdayClient.prototype.customers.apiToken = apiToken;
@@ -9,4 +10,8 @@ WashdayClient.prototype.customers = {
9
10
  getCustomerById: get_1.getCustomerById,
10
11
  getCustomerHighlightsById: get_1.getCustomerHighlightsById
11
12
  };
13
+ WashdayClient.prototype.stores = {
14
+ getStores: get_2.getStores,
15
+ getStoreById: get_2.getStoreById
16
+ };
12
17
  exports.default = WashdayClient;
@@ -0,0 +1,50 @@
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.getStoreById = exports.getStores = 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 getStores = function () {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ var _a, _b;
24
+ try {
25
+ REQUEST_PARAMS.token = this.apiToken;
26
+ const response = yield axiosInstance_1.default.get(`${GET_SET_STORES}`, { params: Object.assign({}, REQUEST_PARAMS) });
27
+ return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.stores) || [];
28
+ }
29
+ catch (error) {
30
+ console.error('Error fetching getStores:', error);
31
+ throw error;
32
+ }
33
+ });
34
+ };
35
+ exports.getStores = getStores;
36
+ const getStoreById = function (storeId) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ var _a;
39
+ try {
40
+ REQUEST_PARAMS.token = this.apiToken;
41
+ const response = yield axiosInstance_1.default.get(`${GET_SET_STORES}/${storeId}`, { params: Object.assign({}, REQUEST_PARAMS) });
42
+ return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.data) || {};
43
+ }
44
+ catch (error) {
45
+ console.error('Error fetching getStoreById:', error);
46
+ throw error;
47
+ }
48
+ });
49
+ };
50
+ exports.getStoreById = getStoreById;
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "washday-sdk",
3
- "version": "0.0.9",
4
- "description": "Washday utilities functions and API",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "test": "jest",
8
- "build": "tsc",
9
- "publish": "npm run build && npm publish --access public"
10
- },
11
- "keywords": [
12
- "washday"
13
- ],
14
- "author": "Washday",
15
- "license": "ISC",
16
- "devDependencies": {
17
- "@babel/core": "^7.24.4",
18
- "@babel/preset-env": "^7.24.4",
19
- "@babel/preset-typescript": "^7.24.1",
20
- "babel-jest": "^29.7.0",
21
- "jest": "^29.7.0",
22
- "typescript": "^5.4.4"
23
- },
24
- "dependencies": {
25
- "axios": "^1.6.8",
26
- "joi": "^17.12.3"
27
- }
28
- }
1
+ {
2
+ "name": "washday-sdk",
3
+ "version": "0.0.11",
4
+ "description": "Washday utilities functions and API",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "build": "tsc",
9
+ "publish": "npm run build && npm publish --access public"
10
+ },
11
+ "keywords": [
12
+ "washday"
13
+ ],
14
+ "author": "Washday",
15
+ "license": "ISC",
16
+ "devDependencies": {
17
+ "@babel/core": "^7.24.4",
18
+ "@babel/preset-env": "^7.24.4",
19
+ "@babel/preset-typescript": "^7.24.1",
20
+ "babel-jest": "^29.7.0",
21
+ "jest": "^29.7.0",
22
+ "typescript": "^5.4.4"
23
+ },
24
+ "dependencies": {
25
+ "axios": "^1.6.8",
26
+ "joi": "^17.12.3"
27
+ }
28
+ }
@@ -1,45 +1,45 @@
1
- import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
2
-
3
- // Define the type for the Axios instance
4
- let axiosInstance: AxiosInstance | null = null;
5
-
6
- const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
7
-
8
- // Function to create or return the singleton instance
9
- const getAxiosInstance = (): AxiosInstance => {
10
- if (!axiosInstance) {
11
- axiosInstance = axios.create({
12
- baseURL: BASE_URL,
13
- headers: {
14
- 'Content-Type': 'application/json',
15
- // Add any default headers here
16
- },
17
- });
18
-
19
- // Add interceptor to set token and other options for every request
20
- axiosInstance.interceptors.request.use(
21
- (config) => {
22
- const { token, contentType = 'application/json', responseType = 'json', contentDisposition } = config.params || {};
23
- if (token) {
24
- config.headers.Authorization = `Bearer ${token}`;
25
- }
26
- if (contentType) {
27
- config.headers['Content-Type'] = contentType;
28
- }
29
- if (responseType) {
30
- config.responseType = responseType;
31
- }
32
- if (contentDisposition) {
33
- config.headers['Content-Disposition'] = contentDisposition;
34
- }
35
- return config;
36
- },
37
- (error) => {
38
- return Promise.reject(error);
39
- }
40
- );
41
- }
42
- return axiosInstance;
43
- };
44
-
45
- export default getAxiosInstance();
1
+ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
2
+
3
+ // Define the type for the Axios instance
4
+ let axiosInstance: AxiosInstance | null = null;
5
+
6
+ const BASE_URL: string = 'https://washday-backend.herokuapp.com/';
7
+
8
+ // Function to create or return the singleton instance
9
+ const getAxiosInstance = (): AxiosInstance => {
10
+ if (!axiosInstance) {
11
+ axiosInstance = axios.create({
12
+ baseURL: BASE_URL,
13
+ headers: {
14
+ 'Content-Type': 'application/json',
15
+ // Add any default headers here
16
+ },
17
+ });
18
+
19
+ // Add interceptor to set token and other options for every request
20
+ axiosInstance.interceptors.request.use(
21
+ (config) => {
22
+ const { token, contentType = 'application/json', responseType = 'json', contentDisposition } = config.params || {};
23
+ if (token) {
24
+ config.headers.Authorization = `Bearer ${token}`;
25
+ }
26
+ if (contentType) {
27
+ config.headers['Content-Type'] = contentType;
28
+ }
29
+ if (responseType) {
30
+ config.responseType = responseType;
31
+ }
32
+ if (contentDisposition) {
33
+ config.headers['Content-Disposition'] = contentDisposition;
34
+ }
35
+ return config;
36
+ },
37
+ (error) => {
38
+ return Promise.reject(error);
39
+ }
40
+ );
41
+ }
42
+ return axiosInstance;
43
+ };
44
+
45
+ export default getAxiosInstance();
@@ -1,32 +1,32 @@
1
- import { WashdayClientInstance } from "../../interfaces/Api";
2
- import { ICustomer } from "../../interfaces/Customer";
3
- import { IOrderInfo } from "../../interfaces/Order";
4
- import axiosInstance from "../axiosInstance";
5
-
6
- const GET_SET_CUSTOMERS = 'api/customer';
7
- const REQUEST_PARAMS = {
8
- token: 'LOGGED_USER_TOKEN',
9
- };
10
-
11
-
12
- export const getCustomerById = async function (this: WashdayClientInstance, customerId: string): Promise<{ customer: ICustomer, orderInfo: IOrderInfo }> {
13
- try {
14
- REQUEST_PARAMS.token = this.apiToken;
15
- const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}`, { params: { ...REQUEST_PARAMS } });
16
- return response.data;
17
- } catch (error) {
18
- console.error('Error fetching customer:', error);
19
- throw error;
20
- }
21
- };
22
-
23
- export const getCustomerHighlightsById = async function (this: WashdayClientInstance, customerId: string): Promise<{ customer: ICustomer, orderInfo: IOrderInfo }> {
24
- try {
25
- REQUEST_PARAMS.token = this.apiToken;
26
- const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, { params: { ...REQUEST_PARAMS } });
27
- return response.data;
28
- } catch (error) {
29
- console.error('Error fetching customer:', error);
30
- throw error;
31
- }
32
- };
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { ICustomer } from "../../interfaces/Customer";
3
+ import { IOrderInfo } from "../../interfaces/Order";
4
+ import axiosInstance from "../axiosInstance";
5
+
6
+ const GET_SET_CUSTOMERS = 'api/customer';
7
+ const REQUEST_PARAMS = {
8
+ token: 'LOGGED_USER_TOKEN',
9
+ };
10
+
11
+
12
+ export const getCustomerById = async function (this: WashdayClientInstance, customerId: string): Promise<{ customer: ICustomer, orderInfo: IOrderInfo }> {
13
+ try {
14
+ REQUEST_PARAMS.token = this.apiToken;
15
+ const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}`, { params: { ...REQUEST_PARAMS } });
16
+ return response.data;
17
+ } catch (error) {
18
+ console.error('Error fetching customer:', error);
19
+ throw error;
20
+ }
21
+ };
22
+
23
+ export const getCustomerHighlightsById = async function (this: WashdayClientInstance, customerId: string): Promise<{ customer: ICustomer, orderInfo: IOrderInfo }> {
24
+ try {
25
+ REQUEST_PARAMS.token = this.apiToken;
26
+ const response = await axiosInstance.get(`${GET_SET_CUSTOMERS}/${customerId}/highlights`, { params: { ...REQUEST_PARAMS } });
27
+ return response.data;
28
+ } catch (error) {
29
+ console.error('Error fetching getCustomerHighlightsById:', error);
30
+ throw error;
31
+ }
32
+ };
package/src/api/index.ts CHANGED
@@ -1,21 +1,26 @@
1
- import { WashdayClientInstance } from "../interfaces/Api";
2
- import { getCustomerById, getCustomerHighlightsById } from "./customers/get";
3
-
4
- type WashdayClientConstructor = {
5
- new(apiToken: string): {
6
- apiToken: string;
7
- };
8
- };
9
-
10
- const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string) {
11
- this.apiToken = apiToken;
12
- WashdayClient.prototype.customers.apiToken = apiToken;
13
- } as any;
14
-
15
- WashdayClient.prototype.customers = {
16
- getCustomerById: getCustomerById,
17
- getCustomerHighlightsById: getCustomerHighlightsById
18
- };
19
-
20
-
21
- export default WashdayClient;
1
+ import { WashdayClientInstance } from "../interfaces/Api";
2
+ import { getCustomerById, getCustomerHighlightsById } from "./customers/get";
3
+ import { getStoreById, getStores } from "./stores/get";
4
+
5
+ type WashdayClientConstructor = {
6
+ new(apiToken: string): {
7
+ apiToken: string;
8
+ };
9
+ };
10
+
11
+ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: WashdayClientInstance, apiToken: string) {
12
+ this.apiToken = apiToken;
13
+ WashdayClient.prototype.customers.apiToken = apiToken;
14
+ } as any;
15
+
16
+ WashdayClient.prototype.customers = {
17
+ getCustomerById: getCustomerById,
18
+ getCustomerHighlightsById: getCustomerHighlightsById
19
+ };
20
+
21
+ WashdayClient.prototype.stores = {
22
+ getStores: getStores,
23
+ getStoreById: getStoreById
24
+ };
25
+
26
+ export default WashdayClient;
@@ -0,0 +1,33 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { ICustomer } from "../../interfaces/Customer";
3
+ import { IOrderInfo } from "../../interfaces/Order";
4
+ import { IStore } from "../../interfaces/Store";
5
+ import axiosInstance from "../axiosInstance";
6
+
7
+ const GET_SET_STORES = 'api/store';
8
+ const REQUEST_PARAMS = {
9
+ token: 'LOGGED_USER_TOKEN',
10
+ };
11
+
12
+ export const getStores = async function (this: WashdayClientInstance): Promise<{ stores: IStore[] }> {
13
+ try {
14
+ REQUEST_PARAMS.token = this.apiToken;
15
+ const response = await axiosInstance.get(`${GET_SET_STORES}`, { params: { ...REQUEST_PARAMS } });
16
+ return response.data?.data?.stores || [];
17
+ } catch (error) {
18
+ console.error('Error fetching getStores:', error);
19
+ throw error;
20
+ }
21
+ };
22
+
23
+
24
+ export const getStoreById = async function (this: WashdayClientInstance, storeId: string): Promise<{ store: IStore }> {
25
+ try {
26
+ REQUEST_PARAMS.token = this.apiToken;
27
+ const response = await axiosInstance.get(`${GET_SET_STORES}/${storeId}`, { params: { ...REQUEST_PARAMS } });
28
+ return response.data?.data || {}
29
+ } catch (error) {
30
+ console.error('Error fetching getStoreById:', error);
31
+ throw error;
32
+ }
33
+ };
package/src/enum/index.ts CHANGED
@@ -1,11 +1,11 @@
1
- export enum DiscountCodeTypes {
2
- PERCENTAGE = 'percentage',
3
- NUMBER = 'number',
4
- FREE_DELIVERY = 'freeDelivery',
5
- BUY_X_GET_Y = 'buyXGetY'
6
- }
7
-
8
- export enum BuyAndGetConditionsTypes {
9
- PERCENTAGE = 'percentage',
10
- FREE = 'free'
1
+ export enum DiscountCodeTypes {
2
+ PERCENTAGE = 'percentage',
3
+ NUMBER = 'number',
4
+ FREE_DELIVERY = 'freeDelivery',
5
+ BUY_X_GET_Y = 'buyXGetY'
6
+ }
7
+
8
+ export enum BuyAndGetConditionsTypes {
9
+ PERCENTAGE = 'percentage',
10
+ FREE = 'free'
11
11
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as utils from './utils';
2
- import WashdayClient from './api';
3
-
4
- export { WashdayClient, utils };
1
+ import * as utils from './utils';
2
+ import WashdayClient from './api';
3
+
4
+ export { WashdayClient, utils };
@@ -1,3 +1,3 @@
1
- export type WashdayClientInstance = {
2
- apiToken: string;
1
+ export type WashdayClientInstance = {
2
+ apiToken: string;
3
3
  };
@@ -1,51 +1,51 @@
1
- import { IStore } from './Store'
2
- import { IUser } from "./User"
3
-
4
- interface IInvoiceInfo {
5
- legal_name: string,
6
- tax_system: string,
7
- zipCode: string
8
- }
9
-
10
- interface IAddresses {
11
- addressString: string,
12
- addressName: string,
13
- location: {
14
- latitude: string,
15
- longitude: string
16
- }
17
- }
18
-
19
- interface IPaymentMethod {
20
- stripeId: string,
21
- brand: string,
22
- exp_month: string,
23
- exp_year: string,
24
- last4: string,
25
- }
26
-
27
- export interface ICustomer {
28
- name: string,
29
- phone: string,
30
- address: string,
31
- rfc?: string,
32
- email: string,
33
- notes?: string,
34
- privateNotes?: string,
35
- discount: number,
36
- credit: number,
37
- isActive: boolean,
38
- createdIn: IStore | string,
39
- createdBy: IUser | string,
40
- // company: ICompany | string,
41
- createdDate: Date,
42
- password?: string,
43
- google?: boolean,
44
- facebook?: boolean,
45
- apple?: boolean,
46
- useStoreApp?: boolean,
47
- addresses?: [IAddresses],
48
- paymentMethods?: [IPaymentMethod],
49
- stripeCustomerId?: string,
50
- invoiceInfo?: IInvoiceInfo,
51
- }
1
+ import { IStore } from './Store'
2
+ import { IUser } from "./User"
3
+
4
+ interface IInvoiceInfo {
5
+ legal_name: string,
6
+ tax_system: string,
7
+ zipCode: string
8
+ }
9
+
10
+ interface IAddresses {
11
+ addressString: string,
12
+ addressName: string,
13
+ location: {
14
+ latitude: string,
15
+ longitude: string
16
+ }
17
+ }
18
+
19
+ interface IPaymentMethod {
20
+ stripeId: string,
21
+ brand: string,
22
+ exp_month: string,
23
+ exp_year: string,
24
+ last4: string,
25
+ }
26
+
27
+ export interface ICustomer {
28
+ name: string,
29
+ phone: string,
30
+ address: string,
31
+ rfc?: string,
32
+ email: string,
33
+ notes?: string,
34
+ privateNotes?: string,
35
+ discount: number,
36
+ credit: number,
37
+ isActive: boolean,
38
+ createdIn: IStore | string,
39
+ createdBy: IUser | string,
40
+ // company: ICompany | string,
41
+ createdDate: Date,
42
+ password?: string,
43
+ google?: boolean,
44
+ facebook?: boolean,
45
+ apple?: boolean,
46
+ useStoreApp?: boolean,
47
+ addresses?: [IAddresses],
48
+ paymentMethods?: [IPaymentMethod],
49
+ stripeCustomerId?: string,
50
+ invoiceInfo?: IInvoiceInfo,
51
+ }