washday-sdk 1.6.54 → 1.6.56

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.
@@ -0,0 +1 @@
1
+ export * as postModule from "./post";
@@ -0,0 +1,56 @@
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 GOOGLE_MAPS_PROXY = "api/v2/google-maps";
11
+ const CUSTOMERS_APP_GOOGLE_MAPS_PROXY = "api/v2/washdayapp/google-maps";
12
+ function authConfig() {
13
+ return {
14
+ headers: { Authorization: `Bearer ${this.apiToken}` },
15
+ };
16
+ }
17
+ export const autocompleteCustomersApp = function (payload) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ return yield this.axiosInstance.post(`${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/autocomplete`, payload, authConfig.call(this));
20
+ });
21
+ };
22
+ export const placeDetailsCustomersApp = function (payload) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return yield this.axiosInstance.post(`${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/place-details`, payload, authConfig.call(this));
25
+ });
26
+ };
27
+ export const geocodeCustomersApp = function (payload) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ return yield this.axiosInstance.post(`${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/geocode`, payload, authConfig.call(this));
30
+ });
31
+ };
32
+ export const reverseGeocodeCustomersApp = function (payload) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ return yield this.axiosInstance.post(`${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/reverse-geocode`, payload, authConfig.call(this));
35
+ });
36
+ };
37
+ export const autocomplete = function (payload) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ return yield this.axiosInstance.post(`${GOOGLE_MAPS_PROXY}/autocomplete`, payload, authConfig.call(this));
40
+ });
41
+ };
42
+ export const placeDetails = function (payload) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ return yield this.axiosInstance.post(`${GOOGLE_MAPS_PROXY}/place-details`, payload, authConfig.call(this));
45
+ });
46
+ };
47
+ export const geocode = function (payload) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ return yield this.axiosInstance.post(`${GOOGLE_MAPS_PROXY}/geocode`, payload, authConfig.call(this));
50
+ });
51
+ };
52
+ export const reverseGeocode = function (payload) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ return yield this.axiosInstance.post(`${GOOGLE_MAPS_PROXY}/reverse-geocode`, payload, authConfig.call(this));
55
+ });
56
+ };
package/dist/api/index.js CHANGED
@@ -47,6 +47,7 @@ import { getAxiosInstance } from "./axiosInstance";
47
47
  import * as integrationsEndpoints from './integrations';
48
48
  import * as updatesEndpoints from './updates';
49
49
  import * as intercomEndpoints from './intercom';
50
+ import * as googleMapsEndpoints from './googleMaps';
50
51
  function bindMethods(instance, methods) {
51
52
  const boundMethods = {};
52
53
  for (const key in methods) {
@@ -223,6 +224,16 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
223
224
  this.config = bindMethods(this, {
224
225
  getTaxPresets: configEndpoints.getModule.getTaxPresets,
225
226
  });
227
+ this.googleMaps = bindMethods(this, {
228
+ autocompleteCustomersApp: googleMapsEndpoints.postModule.autocompleteCustomersApp,
229
+ placeDetailsCustomersApp: googleMapsEndpoints.postModule.placeDetailsCustomersApp,
230
+ geocodeCustomersApp: googleMapsEndpoints.postModule.geocodeCustomersApp,
231
+ reverseGeocodeCustomersApp: googleMapsEndpoints.postModule.reverseGeocodeCustomersApp,
232
+ autocomplete: googleMapsEndpoints.postModule.autocomplete,
233
+ placeDetails: googleMapsEndpoints.postModule.placeDetails,
234
+ geocode: googleMapsEndpoints.postModule.geocode,
235
+ reverseGeocode: googleMapsEndpoints.postModule.reverseGeocode,
236
+ });
226
237
  this.supplies = bindMethods(this, {
227
238
  getSupplies: getSupplies,
228
239
  getSupplyById: getSupplyById,
package/dist/index.js CHANGED
@@ -5,4 +5,6 @@ export * from './interfaces/Config';
5
5
  export * from './interfaces/Cfdi';
6
6
  export * from './interfaces/Auth';
7
7
  export * from './interfaces/Customer';
8
+ export * from './interfaces/DomainUrls';
9
+ export * from './interfaces/GoogleMaps';
8
10
  export { WashdayClient, utils };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.54",
3
+ "version": "1.6.56",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -0,0 +1 @@
1
+ export * as postModule from "./post";
@@ -0,0 +1,108 @@
1
+ import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import {
3
+ GoogleMapsAutocompletePayload,
4
+ GoogleMapsAutocompleteResponse,
5
+ GoogleMapsGeocodePayload,
6
+ GoogleMapsGeocodeResponse,
7
+ GoogleMapsPlaceDetailsPayload,
8
+ GoogleMapsPlaceDetailsResponse,
9
+ GoogleMapsReverseGeocodePayload,
10
+ GoogleMapsReverseGeocodeResponse,
11
+ } from "../../interfaces/GoogleMaps";
12
+
13
+ const GOOGLE_MAPS_PROXY = "api/v2/google-maps";
14
+ const CUSTOMERS_APP_GOOGLE_MAPS_PROXY = "api/v2/washdayapp/google-maps";
15
+
16
+ function authConfig(this: WashdayClientInstance) {
17
+ return {
18
+ headers: { Authorization: `Bearer ${this.apiToken}` },
19
+ };
20
+ }
21
+
22
+ export const autocompleteCustomersApp = async function (
23
+ this: WashdayClientInstance,
24
+ payload: GoogleMapsAutocompletePayload
25
+ ): Promise<GoogleMapsAutocompleteResponse> {
26
+ return await this.axiosInstance.post(
27
+ `${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/autocomplete`,
28
+ payload,
29
+ authConfig.call(this)
30
+ );
31
+ };
32
+
33
+ export const placeDetailsCustomersApp = async function (
34
+ this: WashdayClientInstance,
35
+ payload: GoogleMapsPlaceDetailsPayload
36
+ ): Promise<GoogleMapsPlaceDetailsResponse> {
37
+ return await this.axiosInstance.post(
38
+ `${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/place-details`,
39
+ payload,
40
+ authConfig.call(this)
41
+ );
42
+ };
43
+
44
+ export const geocodeCustomersApp = async function (
45
+ this: WashdayClientInstance,
46
+ payload: GoogleMapsGeocodePayload
47
+ ): Promise<GoogleMapsGeocodeResponse> {
48
+ return await this.axiosInstance.post(
49
+ `${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/geocode`,
50
+ payload,
51
+ authConfig.call(this)
52
+ );
53
+ };
54
+
55
+ export const reverseGeocodeCustomersApp = async function (
56
+ this: WashdayClientInstance,
57
+ payload: GoogleMapsReverseGeocodePayload
58
+ ): Promise<GoogleMapsReverseGeocodeResponse> {
59
+ return await this.axiosInstance.post(
60
+ `${CUSTOMERS_APP_GOOGLE_MAPS_PROXY}/reverse-geocode`,
61
+ payload,
62
+ authConfig.call(this)
63
+ );
64
+ };
65
+
66
+ export const autocomplete = async function (
67
+ this: WashdayClientInstance,
68
+ payload: GoogleMapsAutocompletePayload
69
+ ): Promise<GoogleMapsAutocompleteResponse> {
70
+ return await this.axiosInstance.post(
71
+ `${GOOGLE_MAPS_PROXY}/autocomplete`,
72
+ payload,
73
+ authConfig.call(this)
74
+ );
75
+ };
76
+
77
+ export const placeDetails = async function (
78
+ this: WashdayClientInstance,
79
+ payload: GoogleMapsPlaceDetailsPayload
80
+ ): Promise<GoogleMapsPlaceDetailsResponse> {
81
+ return await this.axiosInstance.post(
82
+ `${GOOGLE_MAPS_PROXY}/place-details`,
83
+ payload,
84
+ authConfig.call(this)
85
+ );
86
+ };
87
+
88
+ export const geocode = async function (
89
+ this: WashdayClientInstance,
90
+ payload: GoogleMapsGeocodePayload
91
+ ): Promise<GoogleMapsGeocodeResponse> {
92
+ return await this.axiosInstance.post(
93
+ `${GOOGLE_MAPS_PROXY}/geocode`,
94
+ payload,
95
+ authConfig.call(this)
96
+ );
97
+ };
98
+
99
+ export const reverseGeocode = async function (
100
+ this: WashdayClientInstance,
101
+ payload: GoogleMapsReverseGeocodePayload
102
+ ): Promise<GoogleMapsReverseGeocodeResponse> {
103
+ return await this.axiosInstance.post(
104
+ `${GOOGLE_MAPS_PROXY}/reverse-geocode`,
105
+ payload,
106
+ authConfig.call(this)
107
+ );
108
+ };
package/src/api/index.ts CHANGED
@@ -49,6 +49,7 @@ import { getAxiosInstance } from "./axiosInstance";
49
49
  import * as integrationsEndpoints from './integrations';
50
50
  import * as updatesEndpoints from './updates';
51
51
  import * as intercomEndpoints from './intercom';
52
+ import * as googleMapsEndpoints from './googleMaps';
52
53
 
53
54
  type WashdayClientConstructor = {
54
55
  new(apiToken: string, env?: string, clientId?: string, clientSecret?: string): WashdayClientInstance
@@ -230,6 +231,16 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
230
231
  this.config = bindMethods(this, {
231
232
  getTaxPresets: configEndpoints.getModule.getTaxPresets,
232
233
  });
234
+ this.googleMaps = bindMethods(this, {
235
+ autocompleteCustomersApp: googleMapsEndpoints.postModule.autocompleteCustomersApp,
236
+ placeDetailsCustomersApp: googleMapsEndpoints.postModule.placeDetailsCustomersApp,
237
+ geocodeCustomersApp: googleMapsEndpoints.postModule.geocodeCustomersApp,
238
+ reverseGeocodeCustomersApp: googleMapsEndpoints.postModule.reverseGeocodeCustomersApp,
239
+ autocomplete: googleMapsEndpoints.postModule.autocomplete,
240
+ placeDetails: googleMapsEndpoints.postModule.placeDetails,
241
+ geocode: googleMapsEndpoints.postModule.geocode,
242
+ reverseGeocode: googleMapsEndpoints.postModule.reverseGeocode,
243
+ });
233
244
  this.supplies = bindMethods(this, {
234
245
  getSupplies: getSupplies,
235
246
  getSupplyById: getSupplyById,
@@ -1,11 +1,21 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { AppReturnUrlOptions } from "../../interfaces/DomainUrls";
2
3
 
3
4
  const BASE_ROUTER = 'api/integrations';
4
5
  const BASE_ROUTER_MP_ATTEMPTS = 'api/payments/mp/attempts';
5
6
 
6
- export const startMPOAuthFlow = async function (this: WashdayClientInstance, data: {
7
- redirectUri: string;
8
- }): Promise<any> {
7
+ export interface StartMPOAuthFlowRequest extends AppReturnUrlOptions {
8
+ /**
9
+ * @deprecated The backend owns the Mercado Pago OAuth callback now.
10
+ * Use returnToUrl or returnToOrigin/returnPath for the final app redirect.
11
+ */
12
+ redirectUri?: string;
13
+ }
14
+
15
+ export const startMPOAuthFlow = async function (
16
+ this: WashdayClientInstance,
17
+ data: StartMPOAuthFlowRequest
18
+ ): Promise<any> {
9
19
  try {
10
20
  const config = {
11
21
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -119,4 +129,4 @@ export const cancelMPAttempt = async function (this: WashdayClientInstance, data
119
129
  catch (error) {
120
130
  throw error;
121
131
  }
122
- };
132
+ };
@@ -1,11 +1,25 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
- import axiosInstance from "../axiosInstance";
2
+ import { StripeReturnUrlOptions } from "../../interfaces/DomainUrls";
3
3
  const GET_SET_STRIPE = 'api/stripe';
4
4
  const GENERATE_CHECKOUT_SESSION = 'api/orders/create-checkout-session';
5
5
 
6
- export const createCreateSuscriptionCheckoutSession = async function (this: WashdayClientInstance, data: {
7
- priceId: string
8
- }): Promise<any> {
6
+ export interface CreateSubscriptionCheckoutSessionRequest extends StripeReturnUrlOptions {
7
+ priceId: string;
8
+ planKey?: string;
9
+ }
10
+
11
+ export interface CreateGetMoreCheckoutSessionRequest extends StripeReturnUrlOptions {
12
+ priceId: string;
13
+ }
14
+
15
+ export interface CreateCFDISubscriptionCheckoutSessionRequest extends StripeReturnUrlOptions {}
16
+
17
+ export interface CreateCustomerPortalSessionRequest extends StripeReturnUrlOptions {}
18
+
19
+ export const createCreateSuscriptionCheckoutSession = async function (
20
+ this: WashdayClientInstance,
21
+ data: CreateSubscriptionCheckoutSessionRequest
22
+ ): Promise<any> {
9
23
  try {
10
24
  const config = {
11
25
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -18,7 +32,10 @@ export const createCreateSuscriptionCheckoutSession = async function (this: Wash
18
32
  }
19
33
  };
20
34
 
21
- export const createCustomerPortalSession = async function (this: WashdayClientInstance, data?: any): Promise<any> {
35
+ export const createCustomerPortalSession = async function (
36
+ this: WashdayClientInstance,
37
+ data?: CreateCustomerPortalSessionRequest
38
+ ): Promise<any> {
22
39
  try {
23
40
  const config = {
24
41
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -31,7 +48,10 @@ export const createCustomerPortalSession = async function (this: WashdayClientIn
31
48
  }
32
49
  };
33
50
 
34
- export const createCFDISuscrptionCheckoutSession = async function (this: WashdayClientInstance, data?: any): Promise<any> {
51
+ export const createCFDISuscrptionCheckoutSession = async function (
52
+ this: WashdayClientInstance,
53
+ data?: CreateCFDISubscriptionCheckoutSessionRequest
54
+ ): Promise<any> {
35
55
  try {
36
56
  const config = {
37
57
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -44,9 +64,10 @@ export const createCFDISuscrptionCheckoutSession = async function (this: Washday
44
64
  }
45
65
  };
46
66
 
47
- export const createGetMoreCheckoutSession = async function (this: WashdayClientInstance, data: {
48
- priceId: string
49
- }): Promise<any> {
67
+ export const createGetMoreCheckoutSession = async function (
68
+ this: WashdayClientInstance,
69
+ data: CreateGetMoreCheckoutSessionRequest
70
+ ): Promise<any> {
50
71
  try {
51
72
  const config = {
52
73
  headers: { Authorization: `Bearer ${this.apiToken}` }
@@ -56,4 +77,4 @@ export const createGetMoreCheckoutSession = async function (this: WashdayClientI
56
77
  console.error('Error fetching createGetMoreCheckoutSession:', error);
57
78
  throw error;
58
79
  }
59
- };
80
+ };
package/src/index.ts CHANGED
@@ -5,5 +5,14 @@ export * from './interfaces/Config';
5
5
  export * from './interfaces/Cfdi';
6
6
  export * from './interfaces/Auth';
7
7
  export * from './interfaces/Customer';
8
+ export * from './interfaces/DomainUrls';
9
+ export * from './interfaces/GoogleMaps';
10
+ export type { StartMPOAuthFlowRequest } from './api/integrations/post';
11
+ export type {
12
+ CreateCFDISubscriptionCheckoutSessionRequest,
13
+ CreateCustomerPortalSessionRequest,
14
+ CreateGetMoreCheckoutSessionRequest,
15
+ CreateSubscriptionCheckoutSessionRequest,
16
+ } from './api/stripe/post';
8
17
 
9
18
  export { WashdayClient, utils };
@@ -45,6 +45,7 @@ import * as publicsEndpoints from '../api/publics';
45
45
  import * as integrationsEndpoints from '../api/integrations';
46
46
  import * as updatesEndpoints from '../api/updates';
47
47
  import * as intercomEndpoints from '../api/intercom';
48
+ import * as googleMapsEndpoints from '../api/googleMaps';
48
49
  import { validateUserPin } from "../api/users/post";
49
50
  import { AxiosInstance } from "axios";
50
51
 
@@ -215,6 +216,16 @@ export interface WashdayClientInstance {
215
216
  config: {
216
217
  getTaxPresets: typeof configEndpoints.getModule.getTaxPresets;
217
218
  };
219
+ googleMaps: {
220
+ autocompleteCustomersApp: typeof googleMapsEndpoints.postModule.autocompleteCustomersApp;
221
+ placeDetailsCustomersApp: typeof googleMapsEndpoints.postModule.placeDetailsCustomersApp;
222
+ geocodeCustomersApp: typeof googleMapsEndpoints.postModule.geocodeCustomersApp;
223
+ reverseGeocodeCustomersApp: typeof googleMapsEndpoints.postModule.reverseGeocodeCustomersApp;
224
+ autocomplete: typeof googleMapsEndpoints.postModule.autocomplete;
225
+ placeDetails: typeof googleMapsEndpoints.postModule.placeDetails;
226
+ geocode: typeof googleMapsEndpoints.postModule.geocode;
227
+ reverseGeocode: typeof googleMapsEndpoints.postModule.reverseGeocode;
228
+ };
218
229
  supplies: {
219
230
  getSupplies: typeof getSupplies;
220
231
  getSupplyById: typeof getSupplyById;
@@ -0,0 +1,11 @@
1
+ export interface AppReturnUrlOptions {
2
+ returnToUrl?: string;
3
+ returnToOrigin?: string;
4
+ returnPath?: string;
5
+ returnToPath?: string;
6
+ }
7
+
8
+ export interface StripeReturnUrlOptions {
9
+ returnToUrl?: string;
10
+ returnToOrigin?: string;
11
+ }
@@ -0,0 +1,97 @@
1
+ export interface GoogleMapsLatLng {
2
+ lat: number;
3
+ lng: number;
4
+ }
5
+
6
+ export interface GoogleMapsLocationBias {
7
+ circle: {
8
+ center: {
9
+ latitude: number;
10
+ longitude: number;
11
+ };
12
+ radius: number;
13
+ };
14
+ }
15
+
16
+ export interface GoogleMapsAutocompletePayload {
17
+ input: string;
18
+ sessionToken: string;
19
+ storeId?: string;
20
+ locationBias?: GoogleMapsLocationBias;
21
+ regionCode?: string;
22
+ }
23
+
24
+ export interface GoogleMapsPlaceDetailsPayload {
25
+ placeId?: string;
26
+ placeResourceName?: string;
27
+ sessionToken: string;
28
+ storeId?: string;
29
+ }
30
+
31
+ export interface GoogleMapsGeocodePayload {
32
+ address: string;
33
+ storeId?: string;
34
+ regionCode?: string;
35
+ }
36
+
37
+ export interface GoogleMapsReverseGeocodePayload {
38
+ latLng: GoogleMapsLatLng;
39
+ storeId?: string;
40
+ }
41
+
42
+ export interface GoogleMapsParsedAddressComponents {
43
+ street?: string;
44
+ number?: string;
45
+ neighborhood?: string;
46
+ postalCode?: string;
47
+ city?: string;
48
+ state?: string;
49
+ country?: string;
50
+ }
51
+
52
+ export interface GoogleMapsAutocompleteSuggestion {
53
+ placeId: string;
54
+ placeResourceName: string;
55
+ text: string;
56
+ }
57
+
58
+ export interface GoogleMapsPlaceDetailsResult {
59
+ placeId: string;
60
+ placeResourceName: string;
61
+ formattedAddress?: string;
62
+ latLng: GoogleMapsLatLng;
63
+ address: GoogleMapsParsedAddressComponents;
64
+ }
65
+
66
+ export interface GoogleMapsGeocodeResult {
67
+ placeId?: string;
68
+ formattedAddress?: string;
69
+ latLng: GoogleMapsLatLng;
70
+ address: GoogleMapsParsedAddressComponents;
71
+ }
72
+
73
+ export interface GoogleMapsAutocompleteResponse {
74
+ data: {
75
+ suggestions: GoogleMapsAutocompleteSuggestion[];
76
+ };
77
+ errors?: string[];
78
+ }
79
+
80
+ export interface GoogleMapsPlaceDetailsResponse {
81
+ data: GoogleMapsPlaceDetailsResult;
82
+ errors?: string[];
83
+ }
84
+
85
+ export interface GoogleMapsGeocodeResponse {
86
+ data: {
87
+ result: GoogleMapsGeocodeResult | null;
88
+ };
89
+ errors?: string[];
90
+ }
91
+
92
+ export interface GoogleMapsReverseGeocodeResponse {
93
+ data: {
94
+ result: GoogleMapsGeocodeResult | null;
95
+ };
96
+ errors?: string[];
97
+ }
@@ -0,0 +1,52 @@
1
+ import { StartMPOAuthFlowRequest } from "../src/api/integrations/post";
2
+ import {
3
+ CreateCFDISubscriptionCheckoutSessionRequest,
4
+ CreateCustomerPortalSessionRequest,
5
+ CreateGetMoreCheckoutSessionRequest,
6
+ CreateSubscriptionCheckoutSessionRequest,
7
+ } from "../src/api/stripe/post";
8
+ import { AppReturnUrlOptions } from "../src/interfaces/DomainUrls";
9
+
10
+ describe("domain return URL request types", () => {
11
+ it("supports app and provider return URL options", () => {
12
+ const appReturnUrlOptions: AppReturnUrlOptions = {
13
+ returnToUrl: "https://app.washdaypos.com/settings/mercado-pago?storeId=store-1",
14
+ returnToOrigin: "https://app.washdaypos.com",
15
+ returnPath: "/settings/mercado-pago?storeId=store-1",
16
+ };
17
+
18
+ const mpRequest: StartMPOAuthFlowRequest = {
19
+ returnToUrl: "https://app.washdaypos.com/settings/mercado-pago?storeId=store-1",
20
+ };
21
+
22
+ const legacyMpRequest: StartMPOAuthFlowRequest = {
23
+ redirectUri: "https://app.washday.mx/integrations/mercadopago/callback",
24
+ };
25
+
26
+ const subscriptionRequest: CreateSubscriptionCheckoutSessionRequest = {
27
+ priceId: "price_1",
28
+ returnToOrigin: "https://app.washdaypos.com",
29
+ };
30
+
31
+ const extraOrdersRequest: CreateGetMoreCheckoutSessionRequest = {
32
+ priceId: "price_extra",
33
+ returnToOrigin: "https://app.washday.mx",
34
+ };
35
+
36
+ const cfdiRequest: CreateCFDISubscriptionCheckoutSessionRequest = {
37
+ returnToUrl: "https://app.washdaypos.com/settings/company-info",
38
+ };
39
+
40
+ const portalRequest: CreateCustomerPortalSessionRequest = {
41
+ returnToUrl: "https://app.washdaypos.com/settings",
42
+ };
43
+
44
+ expect(appReturnUrlOptions.returnToOrigin).toBe("https://app.washdaypos.com");
45
+ expect(mpRequest.returnToUrl).toBe("https://app.washdaypos.com/settings/mercado-pago?storeId=store-1");
46
+ expect(legacyMpRequest.redirectUri).toBe("https://app.washday.mx/integrations/mercadopago/callback");
47
+ expect(subscriptionRequest.returnToOrigin).toBe("https://app.washdaypos.com");
48
+ expect(extraOrdersRequest.returnToOrigin).toBe("https://app.washday.mx");
49
+ expect(cfdiRequest.returnToUrl).toBe("https://app.washdaypos.com/settings/company-info");
50
+ expect(portalRequest.returnToUrl).toBe("https://app.washdaypos.com/settings");
51
+ });
52
+ });
@@ -0,0 +1,154 @@
1
+ import WashdayClient from "../src/api";
2
+ import {
3
+ autocomplete,
4
+ autocompleteCustomersApp,
5
+ geocode,
6
+ geocodeCustomersApp,
7
+ placeDetails,
8
+ placeDetailsCustomersApp,
9
+ reverseGeocode,
10
+ reverseGeocodeCustomersApp,
11
+ } from "../src/api/googleMaps/post";
12
+ import {
13
+ GoogleMapsAutocompletePayload,
14
+ GoogleMapsGeocodePayload,
15
+ GoogleMapsPlaceDetailsPayload,
16
+ GoogleMapsReverseGeocodePayload,
17
+ } from "../src/interfaces/GoogleMaps";
18
+
19
+ const autocompletePayload: GoogleMapsAutocompletePayload = {
20
+ input: "Calle 60",
21
+ sessionToken: "session-123",
22
+ storeId: "store-123",
23
+ regionCode: "MX",
24
+ locationBias: {
25
+ circle: {
26
+ center: { latitude: 20.97, longitude: -89.62 },
27
+ radius: 12000,
28
+ },
29
+ },
30
+ };
31
+
32
+ const placeDetailsPayload: GoogleMapsPlaceDetailsPayload = {
33
+ placeResourceName: "places/abc",
34
+ sessionToken: "session-123",
35
+ storeId: "store-123",
36
+ };
37
+
38
+ const geocodePayload: GoogleMapsGeocodePayload = {
39
+ address: "Calle 60, Merida",
40
+ storeId: "store-123",
41
+ regionCode: "MX",
42
+ };
43
+
44
+ const reverseGeocodePayload: GoogleMapsReverseGeocodePayload = {
45
+ latLng: { lat: 20.97, lng: -89.62 },
46
+ storeId: "store-123",
47
+ };
48
+
49
+ function createClient() {
50
+ return {
51
+ apiToken: "token-123",
52
+ axiosInstance: {
53
+ post: jest.fn().mockResolvedValue({ data: { data: {} } }),
54
+ },
55
+ } as any;
56
+ }
57
+
58
+ describe("google maps proxy endpoints", () => {
59
+ it("calls Customers App Google Maps proxy endpoints with customer token", async () => {
60
+ const client = createClient();
61
+
62
+ await autocompleteCustomersApp.call(client, autocompletePayload);
63
+ await placeDetailsCustomersApp.call(client, placeDetailsPayload);
64
+ await geocodeCustomersApp.call(client, geocodePayload);
65
+ await reverseGeocodeCustomersApp.call(client, reverseGeocodePayload);
66
+
67
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
68
+ 1,
69
+ "api/v2/washdayapp/google-maps/autocomplete",
70
+ autocompletePayload,
71
+ { headers: { Authorization: "Bearer token-123" } }
72
+ );
73
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
74
+ 2,
75
+ "api/v2/washdayapp/google-maps/place-details",
76
+ placeDetailsPayload,
77
+ { headers: { Authorization: "Bearer token-123" } }
78
+ );
79
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
80
+ 3,
81
+ "api/v2/washdayapp/google-maps/geocode",
82
+ geocodePayload,
83
+ { headers: { Authorization: "Bearer token-123" } }
84
+ );
85
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
86
+ 4,
87
+ "api/v2/washdayapp/google-maps/reverse-geocode",
88
+ reverseGeocodePayload,
89
+ { headers: { Authorization: "Bearer token-123" } }
90
+ );
91
+ });
92
+
93
+ it("calls internal user Google Maps proxy endpoints with user token", async () => {
94
+ const client = createClient();
95
+
96
+ await autocomplete.call(client, autocompletePayload);
97
+ await placeDetails.call(client, placeDetailsPayload);
98
+ await geocode.call(client, geocodePayload);
99
+ await reverseGeocode.call(client, reverseGeocodePayload);
100
+
101
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
102
+ 1,
103
+ "api/v2/google-maps/autocomplete",
104
+ autocompletePayload,
105
+ { headers: { Authorization: "Bearer token-123" } }
106
+ );
107
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
108
+ 2,
109
+ "api/v2/google-maps/place-details",
110
+ placeDetailsPayload,
111
+ { headers: { Authorization: "Bearer token-123" } }
112
+ );
113
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
114
+ 3,
115
+ "api/v2/google-maps/geocode",
116
+ geocodePayload,
117
+ { headers: { Authorization: "Bearer token-123" } }
118
+ );
119
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
120
+ 4,
121
+ "api/v2/google-maps/reverse-geocode",
122
+ reverseGeocodePayload,
123
+ { headers: { Authorization: "Bearer token-123" } }
124
+ );
125
+ });
126
+
127
+ it("exposes Google Maps proxy methods through wdClient.googleMaps", async () => {
128
+ const client = new (WashdayClient as any)("token-123", "DEV");
129
+ client.axiosInstance.post = jest.fn().mockResolvedValue({ data: { data: {} } });
130
+
131
+ await client.googleMaps.autocompleteCustomersApp(autocompletePayload);
132
+ await client.googleMaps.placeDetailsCustomersApp(placeDetailsPayload);
133
+ await client.googleMaps.geocodeCustomersApp(geocodePayload);
134
+ await client.googleMaps.reverseGeocodeCustomersApp(reverseGeocodePayload);
135
+ await client.googleMaps.autocomplete(autocompletePayload);
136
+ await client.googleMaps.placeDetails(placeDetailsPayload);
137
+ await client.googleMaps.geocode(geocodePayload);
138
+ await client.googleMaps.reverseGeocode(reverseGeocodePayload);
139
+
140
+ expect(client.axiosInstance.post).toHaveBeenCalledTimes(8);
141
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
142
+ 1,
143
+ "api/v2/washdayapp/google-maps/autocomplete",
144
+ autocompletePayload,
145
+ { headers: { Authorization: "Bearer token-123" } }
146
+ );
147
+ expect(client.axiosInstance.post).toHaveBeenNthCalledWith(
148
+ 8,
149
+ "api/v2/google-maps/reverse-geocode",
150
+ reverseGeocodePayload,
151
+ { headers: { Authorization: "Bearer token-123" } }
152
+ );
153
+ });
154
+ });
@@ -0,0 +1,25 @@
1
+ import { startMPOAuthFlow } from "../src/api/integrations/post";
2
+
3
+ describe("startMPOAuthFlow return URL options", () => {
4
+ it("posts returnToUrl without requiring callers to provide the OAuth callback redirectUri", async () => {
5
+ const post = jest.fn().mockResolvedValue({ data: { data: { authUrl: "https://mp.example/auth" } } });
6
+ const client = {
7
+ apiToken: "token-1",
8
+ axiosInstance: { post },
9
+ } as any;
10
+
11
+ await startMPOAuthFlow.call(client, {
12
+ returnToUrl: "https://app.washdaypos.com/settings/mercado-pago?storeId=store-1",
13
+ });
14
+
15
+ expect(post).toHaveBeenCalledWith(
16
+ "api/integrations/mp/oauth/start",
17
+ {
18
+ returnToUrl: "https://app.washdaypos.com/settings/mercado-pago?storeId=store-1",
19
+ },
20
+ {
21
+ headers: { Authorization: "Bearer token-1" },
22
+ },
23
+ );
24
+ });
25
+ });
@@ -0,0 +1,92 @@
1
+ import {
2
+ createCFDISuscrptionCheckoutSession,
3
+ createCreateSuscriptionCheckoutSession,
4
+ createCustomerPortalSession,
5
+ createGetMoreCheckoutSession,
6
+ } from "../src/api/stripe/post";
7
+
8
+ describe("stripe checkout return URL options", () => {
9
+ it("passes returnToOrigin for subscription checkout", async () => {
10
+ const post = jest.fn().mockResolvedValue({ data: { data: { url: "https://stripe.example" } } });
11
+ const client = {
12
+ apiToken: "token-1",
13
+ axiosInstance: { post },
14
+ } as any;
15
+
16
+ await createCreateSuscriptionCheckoutSession.call(client, {
17
+ priceId: "price_1",
18
+ returnToOrigin: "https://app.washdaypos.com",
19
+ });
20
+
21
+ expect(post).toHaveBeenCalledWith(
22
+ "api/stripe/create-subscription-checkout-session",
23
+ {
24
+ priceId: "price_1",
25
+ returnToOrigin: "https://app.washdaypos.com",
26
+ },
27
+ {
28
+ headers: { Authorization: "Bearer token-1" },
29
+ },
30
+ );
31
+ });
32
+
33
+ it("passes returnToOrigin for extra orders checkout", async () => {
34
+ const post = jest.fn().mockResolvedValue({ data: { data: { url: "https://stripe.example" } } });
35
+ const client = {
36
+ apiToken: "token-1",
37
+ axiosInstance: { post },
38
+ } as any;
39
+
40
+ await createGetMoreCheckoutSession.call(client, {
41
+ priceId: "price_extra",
42
+ returnToOrigin: "https://app.washday.mx",
43
+ });
44
+
45
+ expect(post).toHaveBeenCalledWith(
46
+ "api/orders/create-checkout-session",
47
+ {
48
+ priceId: "price_extra",
49
+ returnToOrigin: "https://app.washday.mx",
50
+ },
51
+ {
52
+ headers: { Authorization: "Bearer token-1" },
53
+ },
54
+ );
55
+ });
56
+
57
+ it("passes returnToUrl for CFDI checkout and customer portal", async () => {
58
+ const post = jest.fn().mockResolvedValue({ data: { data: { url: "https://stripe.example" } } });
59
+ const client = {
60
+ apiToken: "token-1",
61
+ axiosInstance: { post },
62
+ } as any;
63
+
64
+ await createCFDISuscrptionCheckoutSession.call(client, {
65
+ returnToUrl: "https://app.washdaypos.com/settings/company-info",
66
+ });
67
+ await createCustomerPortalSession.call(client, {
68
+ returnToUrl: "https://app.washdaypos.com/settings",
69
+ });
70
+
71
+ expect(post).toHaveBeenNthCalledWith(
72
+ 1,
73
+ "api/stripe/create-cfdi-subscription-checkout-session",
74
+ {
75
+ returnToUrl: "https://app.washdaypos.com/settings/company-info",
76
+ },
77
+ {
78
+ headers: { Authorization: "Bearer token-1" },
79
+ },
80
+ );
81
+ expect(post).toHaveBeenNthCalledWith(
82
+ 2,
83
+ "api/stripe/create-customer-portal-session",
84
+ {
85
+ returnToUrl: "https://app.washdaypos.com/settings",
86
+ },
87
+ {
88
+ headers: { Authorization: "Bearer token-1" },
89
+ },
90
+ );
91
+ });
92
+ });