@gymspace/sdk 1.0.3 → 1.1.1

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/index.d.mts CHANGED
@@ -35,15 +35,9 @@ type PaginationQueryDto = PaginationParams$1;
35
35
  declare class ApiClient {
36
36
  private axiosInstance;
37
37
  private config;
38
- private refreshPromise;
39
- onTokensUpdated?: (accessToken: string, refreshToken: string) => void;
40
- onAuthError?: (error: any) => void;
38
+ private refreshToken;
41
39
  constructor(config: GymSpaceConfig);
42
40
  private setupInterceptors;
43
- /**
44
- * Refresh the access token using the stored refresh token
45
- */
46
- private refreshAccessToken;
47
41
  private handleError;
48
42
  private mergeOptions;
49
43
  request<T>(method: string, path: string, data?: any, options?: RequestOptions & AxiosRequestConfig): Promise<T>;
@@ -53,7 +47,8 @@ declare class ApiClient {
53
47
  patch<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
54
48
  delete<T>(path: string, options?: RequestOptions): Promise<T>;
55
49
  setAuthToken(token: string): void;
56
- setTokens(accessToken: string, refreshToken: string): void;
50
+ setRefreshToken(token: string | null): void;
51
+ getRefreshToken(): string | null;
57
52
  setGymId(gymId: string): void;
58
53
  clearAuth(): void;
59
54
  getBaseUrl(): string;
@@ -147,6 +142,8 @@ interface InvitationValidationResponse {
147
142
  };
148
143
  }
149
144
  interface CurrentSessionResponse {
145
+ accessToken: string;
146
+ refreshToken?: string;
150
147
  user: {
151
148
  id: string;
152
149
  email: string;
@@ -750,7 +747,7 @@ interface Contract {
750
747
  status: ContractStatus;
751
748
  price: number;
752
749
  discountPercentage?: number;
753
- finalPrice: number;
750
+ finalAmount: number;
754
751
  freezeStartDate?: string;
755
752
  freezeEndDate?: string;
756
753
  receiptIds?: string[];
@@ -1727,6 +1724,11 @@ interface UpdateSaleDto {
1727
1724
  interface UpdatePaymentStatusDto {
1728
1725
  paymentStatus: 'paid' | 'unpaid';
1729
1726
  }
1727
+ interface PaySaleDto {
1728
+ paymentMethodId: string;
1729
+ notes?: string;
1730
+ fileIds?: string[];
1731
+ }
1730
1732
  interface Sale {
1731
1733
  id: string;
1732
1734
  gymId: string;
@@ -1831,6 +1833,7 @@ declare class SalesResource extends BaseResource {
1831
1833
  getSale(id: string, options?: RequestOptions): Promise<Sale>;
1832
1834
  updateSale(id: string, data: UpdateSaleDto, options?: RequestOptions): Promise<Sale>;
1833
1835
  updatePaymentStatus(id: string, paymentStatus: 'paid' | 'unpaid', options?: RequestOptions): Promise<Sale>;
1836
+ paySale(id: string, data: PaySaleDto, options?: RequestOptions): Promise<Sale>;
1834
1837
  deleteSale(id: string, options?: RequestOptions): Promise<void>;
1835
1838
  getSalesStats(startDate?: string, endDate?: string, options?: RequestOptions): Promise<SalesStats>;
1836
1839
  getTopSellingProducts(limit?: number, startDate?: string, endDate?: string, options?: RequestOptions): Promise<TopSellingProduct[]>;
@@ -2029,9 +2032,13 @@ declare class GymSpaceSdk {
2029
2032
  */
2030
2033
  setAuthToken(token: string): void;
2031
2034
  /**
2032
- * Set both access and refresh tokens
2035
+ * Set the refresh token
2036
+ */
2037
+ setRefreshToken(token: string | null): void;
2038
+ /**
2039
+ * Get the current refresh token
2033
2040
  */
2034
- setTokens(accessToken: string, refreshToken: string): void;
2041
+ getRefreshToken(): string | null;
2035
2042
  /**
2036
2043
  * Set the current gym context
2037
2044
  */
@@ -2073,4 +2080,4 @@ declare class NetworkError extends GymSpaceError {
2073
2080
  constructor(message?: string);
2074
2081
  }
2075
2082
 
2076
- export { type AcceptInvitationDto, type AffiliateOrganizationDto, type Amenities, ApiClient, type ApiResponse, type AssetResponseDto, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, type AvailablePlanDto, type BusinessHours, type CatalogGym, type ChangePasswordDto, type ChangePasswordResponseDto, type CheckIn, type CheckInListResponse, type CheckInStats, type CheckInSystemFeatures, type CheckIns, CheckInsResource, type CheckLimitResponse, type CityWithGyms, type Client, type ClientCheckInHistory, type ClientManagementFeatures, type ClientSearchForCheckInResponse, type ClientStat, type ClientStats, ClientsResource, type CompleteGuidedSetupData, type ConfigureFeaturesData, type Contract, ContractsResource, type ContractsRevenue, type CreateCheckInDto, type CreateClientDto, type CreateContractDto, type CreateEvaluationDto, type CreateGymDto, type CreateInvitationDto, type CreateLeadDto, type CreateMembershipPlanDto, type CreatePaymentMethodDto, type CreateProductCategoryDto, type CreateProductDto, type CreateSaleDto, type CreateServiceDto, type CreateSupplierDto, type CurrentSessionResponse, type CurrentlyInGymResponse, type CustomerSalesReport, DashboardResource, type DashboardStats, type DateRangeParams, type DaySchedule, type Debts, type Evaluation, type EvaluationHealthMetrics, type EvaluationMeasurements, type EvaluationPerformanceMetrics, type EvaluationReport, type EvaluationSystemFeatures, EvaluationsResource, type ExpiringContract, type FileResponseDto, FilesResource, type FreezeContractDto, type GetCheckInStatsParams, type GetClientCheckInHistoryParams, type GetClientEvaluationsParams, type GetContractsParams, type GetFeaturedGymsParams, type GetGymInvitationsParams, type GetMembershipPlansParams, type Gym, type GymAmenities, type GymSchedule, type GymSettings, type GymSocialMedia, type GymSpaceConfig, GymSpaceError, GymSpaceSdk, type GymStats, GymsResource, HealthResource, type HealthResponse, type Invitation, type InvitationValidationResponse, InvitationsResource, type Lead, type LeadManagementFeatures, type LeadStats, LeadsResource, type LoginDto, type LoginResponseDto, type MembershipManagementFeatures, type MembershipPlan, type MembershipPlanStats, MembershipPlansResource, NetworkError, type NewClients, NotFoundError, type NotificationSettings, OnboardingResource, type OnboardingResponse, type OnboardingStatus, OnboardingStep, type Organization, type OrganizationStats, type OrganizationWithDetails, OrganizationsResource, type PaginatedResponse, type PaginatedResponseDto, type PaginationParams, type PaginationQueryDto, type PaymentMethod, type PaymentMethodStats, PaymentMethodsResource, type Product, type ProductCategory, ProductsResource, PublicCatalogResource, type ReadyResponse, type RegisterCollaboratorDto, type RegisterOwnerDto, type RenewContractDto, type RequestOptions, type RequestPasswordResetDto, type RequestPasswordResetResponseDto, type ResendResetCodeDto, type ResendResetCodeResponseDto, type ResendVerificationDto, type ResetPasswordDto, type ResetPasswordResponseDto, type Sale, type SaleItem, type SaleItemDto, SalesResource, type SalesRevenue, type SalesStats, type SearchCatalogParams, type SearchCheckInsParams, type SearchClientsParams, type SearchLeadsParams, type SearchPaymentMethodsParams, type SearchProductsParams, type SearchSalesParams, type SearchSuppliersParams, type SocialMedia, type StartOnboardingData, type StartOnboardingResponse, type StockMovement, type Subscription, type SubscriptionPlan, type SubscriptionStatusDto, SubscriptionsResource, type Supplier, SuppliersResource, type SuppliersStats, type TimeSlot, type TopSellingProduct, type UpdateClientDto, type UpdateEvaluationDto, type UpdateGymDto, type UpdateGymScheduleDto, type UpdateGymSettingsData, type UpdateGymSocialMediaDto, type UpdateLeadDto, type UpdateMembershipPlanDto, type UpdateOrganizationDto, type UpdatePaymentMethodDto, type UpdatePaymentStatusDto, type UpdateProductCategoryDto, type UpdateProductDto, type UpdateProfileDto, type UpdateSaleDto, type UpdateStockDto, type UpdateSupplierDto, type UploadAssetDto, type UploadFileDto, type UserProfileDto, UsersResource, ValidationError, type VerifyEmailDto, type VerifyResetCodeDto, type VerifyResetCodeResponseDto, type WeeklySchedule };
2083
+ export { type AcceptInvitationDto, type AffiliateOrganizationDto, type Amenities, ApiClient, type ApiResponse, type AssetResponseDto, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, type AvailablePlanDto, type BusinessHours, type CatalogGym, type ChangePasswordDto, type ChangePasswordResponseDto, type CheckIn, type CheckInListResponse, type CheckInStats, type CheckInSystemFeatures, type CheckIns, CheckInsResource, type CheckLimitResponse, type CityWithGyms, type Client, type ClientCheckInHistory, type ClientManagementFeatures, type ClientSearchForCheckInResponse, type ClientStat, type ClientStats, ClientsResource, type CompleteGuidedSetupData, type ConfigureFeaturesData, type Contract, ContractsResource, type ContractsRevenue, type CreateCheckInDto, type CreateClientDto, type CreateContractDto, type CreateEvaluationDto, type CreateGymDto, type CreateInvitationDto, type CreateLeadDto, type CreateMembershipPlanDto, type CreatePaymentMethodDto, type CreateProductCategoryDto, type CreateProductDto, type CreateSaleDto, type CreateServiceDto, type CreateSupplierDto, type CurrentSessionResponse, type CurrentlyInGymResponse, type CustomerSalesReport, DashboardResource, type DashboardStats, type DateRangeParams, type DaySchedule, type Debts, type Evaluation, type EvaluationHealthMetrics, type EvaluationMeasurements, type EvaluationPerformanceMetrics, type EvaluationReport, type EvaluationSystemFeatures, EvaluationsResource, type ExpiringContract, type FileResponseDto, FilesResource, type FreezeContractDto, type GetCheckInStatsParams, type GetClientCheckInHistoryParams, type GetClientEvaluationsParams, type GetContractsParams, type GetFeaturedGymsParams, type GetGymInvitationsParams, type GetMembershipPlansParams, type Gym, type GymAmenities, type GymSchedule, type GymSettings, type GymSocialMedia, type GymSpaceConfig, GymSpaceError, GymSpaceSdk, type GymStats, GymsResource, HealthResource, type HealthResponse, type Invitation, type InvitationValidationResponse, InvitationsResource, type Lead, type LeadManagementFeatures, type LeadStats, LeadsResource, type LoginDto, type LoginResponseDto, type MembershipManagementFeatures, type MembershipPlan, type MembershipPlanStats, MembershipPlansResource, NetworkError, type NewClients, NotFoundError, type NotificationSettings, OnboardingResource, type OnboardingResponse, type OnboardingStatus, OnboardingStep, type Organization, type OrganizationStats, type OrganizationWithDetails, OrganizationsResource, type PaginatedResponse, type PaginatedResponseDto, type PaginationParams, type PaginationQueryDto, type PaySaleDto, type PaymentMethod, type PaymentMethodStats, PaymentMethodsResource, type Product, type ProductCategory, ProductsResource, PublicCatalogResource, type ReadyResponse, type RegisterCollaboratorDto, type RegisterOwnerDto, type RenewContractDto, type RequestOptions, type RequestPasswordResetDto, type RequestPasswordResetResponseDto, type ResendResetCodeDto, type ResendResetCodeResponseDto, type ResendVerificationDto, type ResetPasswordDto, type ResetPasswordResponseDto, type Sale, type SaleItem, type SaleItemDto, SalesResource, type SalesRevenue, type SalesStats, type SearchCatalogParams, type SearchCheckInsParams, type SearchClientsParams, type SearchLeadsParams, type SearchPaymentMethodsParams, type SearchProductsParams, type SearchSalesParams, type SearchSuppliersParams, type SocialMedia, type StartOnboardingData, type StartOnboardingResponse, type StockMovement, type Subscription, type SubscriptionPlan, type SubscriptionStatusDto, SubscriptionsResource, type Supplier, SuppliersResource, type SuppliersStats, type TimeSlot, type TopSellingProduct, type UpdateClientDto, type UpdateEvaluationDto, type UpdateGymDto, type UpdateGymScheduleDto, type UpdateGymSettingsData, type UpdateGymSocialMediaDto, type UpdateLeadDto, type UpdateMembershipPlanDto, type UpdateOrganizationDto, type UpdatePaymentMethodDto, type UpdatePaymentStatusDto, type UpdateProductCategoryDto, type UpdateProductDto, type UpdateProfileDto, type UpdateSaleDto, type UpdateStockDto, type UpdateSupplierDto, type UploadAssetDto, type UploadFileDto, type UserProfileDto, UsersResource, ValidationError, type VerifyEmailDto, type VerifyResetCodeDto, type VerifyResetCodeResponseDto, type WeeklySchedule };
package/dist/index.d.ts CHANGED
@@ -35,15 +35,9 @@ type PaginationQueryDto = PaginationParams$1;
35
35
  declare class ApiClient {
36
36
  private axiosInstance;
37
37
  private config;
38
- private refreshPromise;
39
- onTokensUpdated?: (accessToken: string, refreshToken: string) => void;
40
- onAuthError?: (error: any) => void;
38
+ private refreshToken;
41
39
  constructor(config: GymSpaceConfig);
42
40
  private setupInterceptors;
43
- /**
44
- * Refresh the access token using the stored refresh token
45
- */
46
- private refreshAccessToken;
47
41
  private handleError;
48
42
  private mergeOptions;
49
43
  request<T>(method: string, path: string, data?: any, options?: RequestOptions & AxiosRequestConfig): Promise<T>;
@@ -53,7 +47,8 @@ declare class ApiClient {
53
47
  patch<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
54
48
  delete<T>(path: string, options?: RequestOptions): Promise<T>;
55
49
  setAuthToken(token: string): void;
56
- setTokens(accessToken: string, refreshToken: string): void;
50
+ setRefreshToken(token: string | null): void;
51
+ getRefreshToken(): string | null;
57
52
  setGymId(gymId: string): void;
58
53
  clearAuth(): void;
59
54
  getBaseUrl(): string;
@@ -147,6 +142,8 @@ interface InvitationValidationResponse {
147
142
  };
148
143
  }
149
144
  interface CurrentSessionResponse {
145
+ accessToken: string;
146
+ refreshToken?: string;
150
147
  user: {
151
148
  id: string;
152
149
  email: string;
@@ -750,7 +747,7 @@ interface Contract {
750
747
  status: ContractStatus;
751
748
  price: number;
752
749
  discountPercentage?: number;
753
- finalPrice: number;
750
+ finalAmount: number;
754
751
  freezeStartDate?: string;
755
752
  freezeEndDate?: string;
756
753
  receiptIds?: string[];
@@ -1727,6 +1724,11 @@ interface UpdateSaleDto {
1727
1724
  interface UpdatePaymentStatusDto {
1728
1725
  paymentStatus: 'paid' | 'unpaid';
1729
1726
  }
1727
+ interface PaySaleDto {
1728
+ paymentMethodId: string;
1729
+ notes?: string;
1730
+ fileIds?: string[];
1731
+ }
1730
1732
  interface Sale {
1731
1733
  id: string;
1732
1734
  gymId: string;
@@ -1831,6 +1833,7 @@ declare class SalesResource extends BaseResource {
1831
1833
  getSale(id: string, options?: RequestOptions): Promise<Sale>;
1832
1834
  updateSale(id: string, data: UpdateSaleDto, options?: RequestOptions): Promise<Sale>;
1833
1835
  updatePaymentStatus(id: string, paymentStatus: 'paid' | 'unpaid', options?: RequestOptions): Promise<Sale>;
1836
+ paySale(id: string, data: PaySaleDto, options?: RequestOptions): Promise<Sale>;
1834
1837
  deleteSale(id: string, options?: RequestOptions): Promise<void>;
1835
1838
  getSalesStats(startDate?: string, endDate?: string, options?: RequestOptions): Promise<SalesStats>;
1836
1839
  getTopSellingProducts(limit?: number, startDate?: string, endDate?: string, options?: RequestOptions): Promise<TopSellingProduct[]>;
@@ -2029,9 +2032,13 @@ declare class GymSpaceSdk {
2029
2032
  */
2030
2033
  setAuthToken(token: string): void;
2031
2034
  /**
2032
- * Set both access and refresh tokens
2035
+ * Set the refresh token
2036
+ */
2037
+ setRefreshToken(token: string | null): void;
2038
+ /**
2039
+ * Get the current refresh token
2033
2040
  */
2034
- setTokens(accessToken: string, refreshToken: string): void;
2041
+ getRefreshToken(): string | null;
2035
2042
  /**
2036
2043
  * Set the current gym context
2037
2044
  */
@@ -2073,4 +2080,4 @@ declare class NetworkError extends GymSpaceError {
2073
2080
  constructor(message?: string);
2074
2081
  }
2075
2082
 
2076
- export { type AcceptInvitationDto, type AffiliateOrganizationDto, type Amenities, ApiClient, type ApiResponse, type AssetResponseDto, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, type AvailablePlanDto, type BusinessHours, type CatalogGym, type ChangePasswordDto, type ChangePasswordResponseDto, type CheckIn, type CheckInListResponse, type CheckInStats, type CheckInSystemFeatures, type CheckIns, CheckInsResource, type CheckLimitResponse, type CityWithGyms, type Client, type ClientCheckInHistory, type ClientManagementFeatures, type ClientSearchForCheckInResponse, type ClientStat, type ClientStats, ClientsResource, type CompleteGuidedSetupData, type ConfigureFeaturesData, type Contract, ContractsResource, type ContractsRevenue, type CreateCheckInDto, type CreateClientDto, type CreateContractDto, type CreateEvaluationDto, type CreateGymDto, type CreateInvitationDto, type CreateLeadDto, type CreateMembershipPlanDto, type CreatePaymentMethodDto, type CreateProductCategoryDto, type CreateProductDto, type CreateSaleDto, type CreateServiceDto, type CreateSupplierDto, type CurrentSessionResponse, type CurrentlyInGymResponse, type CustomerSalesReport, DashboardResource, type DashboardStats, type DateRangeParams, type DaySchedule, type Debts, type Evaluation, type EvaluationHealthMetrics, type EvaluationMeasurements, type EvaluationPerformanceMetrics, type EvaluationReport, type EvaluationSystemFeatures, EvaluationsResource, type ExpiringContract, type FileResponseDto, FilesResource, type FreezeContractDto, type GetCheckInStatsParams, type GetClientCheckInHistoryParams, type GetClientEvaluationsParams, type GetContractsParams, type GetFeaturedGymsParams, type GetGymInvitationsParams, type GetMembershipPlansParams, type Gym, type GymAmenities, type GymSchedule, type GymSettings, type GymSocialMedia, type GymSpaceConfig, GymSpaceError, GymSpaceSdk, type GymStats, GymsResource, HealthResource, type HealthResponse, type Invitation, type InvitationValidationResponse, InvitationsResource, type Lead, type LeadManagementFeatures, type LeadStats, LeadsResource, type LoginDto, type LoginResponseDto, type MembershipManagementFeatures, type MembershipPlan, type MembershipPlanStats, MembershipPlansResource, NetworkError, type NewClients, NotFoundError, type NotificationSettings, OnboardingResource, type OnboardingResponse, type OnboardingStatus, OnboardingStep, type Organization, type OrganizationStats, type OrganizationWithDetails, OrganizationsResource, type PaginatedResponse, type PaginatedResponseDto, type PaginationParams, type PaginationQueryDto, type PaymentMethod, type PaymentMethodStats, PaymentMethodsResource, type Product, type ProductCategory, ProductsResource, PublicCatalogResource, type ReadyResponse, type RegisterCollaboratorDto, type RegisterOwnerDto, type RenewContractDto, type RequestOptions, type RequestPasswordResetDto, type RequestPasswordResetResponseDto, type ResendResetCodeDto, type ResendResetCodeResponseDto, type ResendVerificationDto, type ResetPasswordDto, type ResetPasswordResponseDto, type Sale, type SaleItem, type SaleItemDto, SalesResource, type SalesRevenue, type SalesStats, type SearchCatalogParams, type SearchCheckInsParams, type SearchClientsParams, type SearchLeadsParams, type SearchPaymentMethodsParams, type SearchProductsParams, type SearchSalesParams, type SearchSuppliersParams, type SocialMedia, type StartOnboardingData, type StartOnboardingResponse, type StockMovement, type Subscription, type SubscriptionPlan, type SubscriptionStatusDto, SubscriptionsResource, type Supplier, SuppliersResource, type SuppliersStats, type TimeSlot, type TopSellingProduct, type UpdateClientDto, type UpdateEvaluationDto, type UpdateGymDto, type UpdateGymScheduleDto, type UpdateGymSettingsData, type UpdateGymSocialMediaDto, type UpdateLeadDto, type UpdateMembershipPlanDto, type UpdateOrganizationDto, type UpdatePaymentMethodDto, type UpdatePaymentStatusDto, type UpdateProductCategoryDto, type UpdateProductDto, type UpdateProfileDto, type UpdateSaleDto, type UpdateStockDto, type UpdateSupplierDto, type UploadAssetDto, type UploadFileDto, type UserProfileDto, UsersResource, ValidationError, type VerifyEmailDto, type VerifyResetCodeDto, type VerifyResetCodeResponseDto, type WeeklySchedule };
2083
+ export { type AcceptInvitationDto, type AffiliateOrganizationDto, type Amenities, ApiClient, type ApiResponse, type AssetResponseDto, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, type AvailablePlanDto, type BusinessHours, type CatalogGym, type ChangePasswordDto, type ChangePasswordResponseDto, type CheckIn, type CheckInListResponse, type CheckInStats, type CheckInSystemFeatures, type CheckIns, CheckInsResource, type CheckLimitResponse, type CityWithGyms, type Client, type ClientCheckInHistory, type ClientManagementFeatures, type ClientSearchForCheckInResponse, type ClientStat, type ClientStats, ClientsResource, type CompleteGuidedSetupData, type ConfigureFeaturesData, type Contract, ContractsResource, type ContractsRevenue, type CreateCheckInDto, type CreateClientDto, type CreateContractDto, type CreateEvaluationDto, type CreateGymDto, type CreateInvitationDto, type CreateLeadDto, type CreateMembershipPlanDto, type CreatePaymentMethodDto, type CreateProductCategoryDto, type CreateProductDto, type CreateSaleDto, type CreateServiceDto, type CreateSupplierDto, type CurrentSessionResponse, type CurrentlyInGymResponse, type CustomerSalesReport, DashboardResource, type DashboardStats, type DateRangeParams, type DaySchedule, type Debts, type Evaluation, type EvaluationHealthMetrics, type EvaluationMeasurements, type EvaluationPerformanceMetrics, type EvaluationReport, type EvaluationSystemFeatures, EvaluationsResource, type ExpiringContract, type FileResponseDto, FilesResource, type FreezeContractDto, type GetCheckInStatsParams, type GetClientCheckInHistoryParams, type GetClientEvaluationsParams, type GetContractsParams, type GetFeaturedGymsParams, type GetGymInvitationsParams, type GetMembershipPlansParams, type Gym, type GymAmenities, type GymSchedule, type GymSettings, type GymSocialMedia, type GymSpaceConfig, GymSpaceError, GymSpaceSdk, type GymStats, GymsResource, HealthResource, type HealthResponse, type Invitation, type InvitationValidationResponse, InvitationsResource, type Lead, type LeadManagementFeatures, type LeadStats, LeadsResource, type LoginDto, type LoginResponseDto, type MembershipManagementFeatures, type MembershipPlan, type MembershipPlanStats, MembershipPlansResource, NetworkError, type NewClients, NotFoundError, type NotificationSettings, OnboardingResource, type OnboardingResponse, type OnboardingStatus, OnboardingStep, type Organization, type OrganizationStats, type OrganizationWithDetails, OrganizationsResource, type PaginatedResponse, type PaginatedResponseDto, type PaginationParams, type PaginationQueryDto, type PaySaleDto, type PaymentMethod, type PaymentMethodStats, PaymentMethodsResource, type Product, type ProductCategory, ProductsResource, PublicCatalogResource, type ReadyResponse, type RegisterCollaboratorDto, type RegisterOwnerDto, type RenewContractDto, type RequestOptions, type RequestPasswordResetDto, type RequestPasswordResetResponseDto, type ResendResetCodeDto, type ResendResetCodeResponseDto, type ResendVerificationDto, type ResetPasswordDto, type ResetPasswordResponseDto, type Sale, type SaleItem, type SaleItemDto, SalesResource, type SalesRevenue, type SalesStats, type SearchCatalogParams, type SearchCheckInsParams, type SearchClientsParams, type SearchLeadsParams, type SearchPaymentMethodsParams, type SearchProductsParams, type SearchSalesParams, type SearchSuppliersParams, type SocialMedia, type StartOnboardingData, type StartOnboardingResponse, type StockMovement, type Subscription, type SubscriptionPlan, type SubscriptionStatusDto, SubscriptionsResource, type Supplier, SuppliersResource, type SuppliersStats, type TimeSlot, type TopSellingProduct, type UpdateClientDto, type UpdateEvaluationDto, type UpdateGymDto, type UpdateGymScheduleDto, type UpdateGymSettingsData, type UpdateGymSocialMediaDto, type UpdateLeadDto, type UpdateMembershipPlanDto, type UpdateOrganizationDto, type UpdatePaymentMethodDto, type UpdatePaymentStatusDto, type UpdateProductCategoryDto, type UpdateProductDto, type UpdateProfileDto, type UpdateSaleDto, type UpdateStockDto, type UpdateSupplierDto, type UploadAssetDto, type UploadFileDto, type UserProfileDto, UsersResource, ValidationError, type VerifyEmailDto, type VerifyResetCodeDto, type VerifyResetCodeResponseDto, type WeeklySchedule };
package/dist/index.js CHANGED
@@ -53,7 +53,7 @@ var NetworkError = class extends GymSpaceError {
53
53
  // src/client.ts
54
54
  var ApiClient = class {
55
55
  constructor(config) {
56
- this.refreshPromise = null;
56
+ this.refreshToken = null;
57
57
  this.config = config;
58
58
  this.axiosInstance = axios__default.default.create({
59
59
  baseURL: config.baseURL,
@@ -71,8 +71,8 @@ var ApiClient = class {
71
71
  if (this.config.apiKey && config.headers) {
72
72
  config.headers["Authorization"] = `Bearer ${this.config.apiKey}`;
73
73
  }
74
- if (this.config.refreshToken && config.headers) {
75
- config.headers["X-Refresh-Token"] = this.config.refreshToken;
74
+ if (this.refreshToken && config.url?.includes("current-session") && config.headers) {
75
+ config.headers["X-Refresh-Token"] = this.refreshToken;
76
76
  }
77
77
  return config;
78
78
  },
@@ -82,66 +82,13 @@ var ApiClient = class {
82
82
  );
83
83
  this.axiosInstance.interceptors.response.use(
84
84
  (response) => {
85
- const newAccessToken = response.headers["x-new-access-token"];
86
- const newRefreshToken = response.headers["x-new-refresh-token"];
87
- if (newAccessToken && newRefreshToken) {
88
- this.setTokens(newAccessToken, newRefreshToken);
89
- this.onTokensUpdated?.(newAccessToken, newRefreshToken);
90
- }
91
85
  return response;
92
86
  },
93
87
  async (error) => {
94
- const originalRequest = error.config;
95
- if (error.response?.status === 401 && !originalRequest._retry && this.config.refreshToken) {
96
- originalRequest._retry = true;
97
- try {
98
- if (!this.refreshPromise) {
99
- this.refreshPromise = this.refreshAccessToken();
100
- }
101
- const newTokens = await this.refreshPromise;
102
- this.refreshPromise = null;
103
- if (newTokens) {
104
- if (!originalRequest.headers) {
105
- originalRequest.headers = {};
106
- }
107
- originalRequest.headers["Authorization"] = `Bearer ${newTokens.access_token}`;
108
- return this.axiosInstance(originalRequest);
109
- }
110
- } catch (refreshError) {
111
- this.refreshPromise = null;
112
- this.clearAuth();
113
- this.onAuthError?.(refreshError);
114
- }
115
- }
116
88
  throw this.handleError(error);
117
89
  }
118
90
  );
119
91
  }
120
- /**
121
- * Refresh the access token using the stored refresh token
122
- */
123
- async refreshAccessToken() {
124
- if (!this.config.refreshToken) {
125
- throw new AuthenticationError("No refresh token available");
126
- }
127
- try {
128
- const response = await axios__default.default.post(
129
- `${this.config.baseURL}/auth/refresh`,
130
- { refresh_token: this.config.refreshToken },
131
- {
132
- headers: {
133
- "Content-Type": "application/json"
134
- },
135
- timeout: this.config.timeout || 3e4
136
- }
137
- );
138
- const newTokens = response.data;
139
- this.setTokens(newTokens.access_token, newTokens.refresh_token);
140
- return newTokens;
141
- } catch (error) {
142
- throw new AuthenticationError("Failed to refresh token");
143
- }
144
- }
145
92
  handleError(error) {
146
93
  const requestPath = error.config?.url || "unknown";
147
94
  const method = error.config?.method?.toUpperCase() || "unknown";
@@ -224,16 +171,18 @@ var ApiClient = class {
224
171
  setAuthToken(token) {
225
172
  this.config.apiKey = token;
226
173
  }
227
- setTokens(accessToken, refreshToken) {
228
- this.config.apiKey = accessToken;
229
- this.config.refreshToken = refreshToken;
174
+ setRefreshToken(token) {
175
+ this.refreshToken = token;
176
+ }
177
+ getRefreshToken() {
178
+ return this.refreshToken;
230
179
  }
231
180
  setGymId(gymId) {
232
181
  this.axiosInstance.defaults.headers.common["X-Gym-Id"] = gymId;
233
182
  }
234
183
  clearAuth() {
235
184
  delete this.config.apiKey;
236
- delete this.config.refreshToken;
185
+ this.refreshToken = null;
237
186
  delete this.axiosInstance.defaults.headers.common["Authorization"];
238
187
  delete this.axiosInstance.defaults.headers.common["X-Gym-Id"];
239
188
  }
@@ -908,8 +857,8 @@ var OnboardingResource = class extends BaseResource {
908
857
  */
909
858
  async start(data) {
910
859
  const response = await this.client.post("/onboarding/start", data);
911
- if (response.access_token && response.refresh_token) {
912
- this.client.setTokens(response.access_token, response.refresh_token);
860
+ if (response.access_token) {
861
+ this.client.setAuthToken(response.access_token);
913
862
  }
914
863
  return response;
915
864
  }
@@ -1019,6 +968,9 @@ var SalesResource = class extends BaseResource {
1019
968
  async updatePaymentStatus(id, paymentStatus, options) {
1020
969
  return this.client.put(`${this.basePath}/${id}/payment-status`, { paymentStatus }, options);
1021
970
  }
971
+ async paySale(id, data, options) {
972
+ return this.client.post(`${this.basePath}/${id}/payment`, data, options);
973
+ }
1022
974
  async deleteSale(id, options) {
1023
975
  return this.client.delete(`${this.basePath}/${id}`, options);
1024
976
  }
@@ -1210,10 +1162,16 @@ var GymSpaceSdk = class {
1210
1162
  this.client.setAuthToken(token);
1211
1163
  }
1212
1164
  /**
1213
- * Set both access and refresh tokens
1165
+ * Set the refresh token
1166
+ */
1167
+ setRefreshToken(token) {
1168
+ this.client.setRefreshToken(token);
1169
+ }
1170
+ /**
1171
+ * Get the current refresh token
1214
1172
  */
1215
- setTokens(accessToken, refreshToken) {
1216
- this.client.setTokens(accessToken, refreshToken);
1173
+ getRefreshToken() {
1174
+ return this.client.getRefreshToken();
1217
1175
  }
1218
1176
  /**
1219
1177
  * Set the current gym context
@@ -1235,7 +1193,7 @@ var GymSpaceSdk = class {
1235
1193
  }
1236
1194
  };
1237
1195
 
1238
- // node_modules/@gymspace/shared/dist/index.mjs
1196
+ // ../../node_modules/@gymspace/shared/dist/index.mjs
1239
1197
  var UserType = /* @__PURE__ */ ((UserType2) => {
1240
1198
  UserType2["OWNER"] = "owner";
1241
1199
  UserType2["COLLABORATOR"] = "collaborator";