@gymspace/sdk 1.1.0 → 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/src/client.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  export class ApiClient {
19
19
  private axiosInstance: AxiosInstance;
20
20
  private config: GymSpaceConfig;
21
+ private refreshToken: string | null = null;
21
22
 
22
23
  constructor(config: GymSpaceConfig) {
23
24
  this.config = config;
@@ -43,6 +44,11 @@ export class ApiClient {
43
44
  config.headers['Authorization'] = `Bearer ${this.config.apiKey}`;
44
45
  }
45
46
 
47
+ // Add refresh token header for current-session endpoint
48
+ if (this.refreshToken && config.url?.includes('current-session') && config.headers) {
49
+ config.headers['X-Refresh-Token'] = this.refreshToken;
50
+ }
51
+
46
52
  return config;
47
53
  },
48
54
  (error) => {
@@ -168,12 +174,21 @@ export class ApiClient {
168
174
  this.config.apiKey = token;
169
175
  }
170
176
 
177
+ setRefreshToken(token: string | null): void {
178
+ this.refreshToken = token;
179
+ }
180
+
181
+ getRefreshToken(): string | null {
182
+ return this.refreshToken;
183
+ }
184
+
171
185
  setGymId(gymId: string): void {
172
186
  this.axiosInstance.defaults.headers.common['X-Gym-Id'] = gymId;
173
187
  }
174
188
 
175
189
  clearAuth(): void {
176
190
  delete this.config.apiKey;
191
+ this.refreshToken = null;
177
192
  delete this.axiosInstance.defaults.headers.common['Authorization'];
178
193
  delete this.axiosInstance.defaults.headers.common['X-Gym-Id'];
179
194
  }
@@ -106,6 +106,7 @@ export interface InvitationValidationResponse {
106
106
 
107
107
  export interface CurrentSessionResponse {
108
108
  accessToken: string;
109
+ refreshToken?: string;
109
110
  user: {
110
111
  id: string;
111
112
  email: string;
@@ -43,7 +43,7 @@ export interface Contract {
43
43
  status: ContractStatus;
44
44
  price: number;
45
45
  discountPercentage?: number;
46
- finalPrice: number;
46
+ finalAmount: number;
47
47
  freezeStartDate?: string;
48
48
  freezeEndDate?: string;
49
49
  receiptIds?: string[];
@@ -52,6 +52,12 @@ export interface UpdatePaymentStatusDto {
52
52
  paymentStatus: 'paid' | 'unpaid';
53
53
  }
54
54
 
55
+ export interface PaySaleDto {
56
+ paymentMethodId: string;
57
+ notes?: string;
58
+ fileIds?: string[];
59
+ }
60
+
55
61
  export interface Sale {
56
62
  id: string;
57
63
  gymId: string;
@@ -1,9 +1,10 @@
1
1
  import { BaseResource } from './base';
2
- import {
2
+ import {
3
3
  Sale,
4
- CreateSaleDto,
4
+ CreateSaleDto,
5
5
  UpdateSaleDto,
6
6
  UpdatePaymentStatusDto,
7
+ PaySaleDto,
7
8
  SearchSalesParams,
8
9
  SalesStats,
9
10
  TopSellingProduct,
@@ -45,6 +46,14 @@ export class SalesResource extends BaseResource {
45
46
  return this.client.put<Sale>(`${this.basePath}/${id}/payment-status`, { paymentStatus }, options);
46
47
  }
47
48
 
49
+ async paySale(
50
+ id: string,
51
+ data: PaySaleDto,
52
+ options?: RequestOptions
53
+ ): Promise<Sale> {
54
+ return this.client.post<Sale>(`${this.basePath}/${id}/payment`, data, options);
55
+ }
56
+
48
57
  async deleteSale(id: string, options?: RequestOptions): Promise<void> {
49
58
  return this.client.delete<void>(`${this.basePath}/${id}`, options);
50
59
  }
package/src/sdk.ts CHANGED
@@ -87,6 +87,19 @@ export class GymSpaceSdk {
87
87
  this.client.setAuthToken(token);
88
88
  }
89
89
 
90
+ /**
91
+ * Set the refresh token
92
+ */
93
+ setRefreshToken(token: string | null): void {
94
+ this.client.setRefreshToken(token);
95
+ }
96
+
97
+ /**
98
+ * Get the current refresh token
99
+ */
100
+ getRefreshToken(): string | null {
101
+ return this.client.getRefreshToken();
102
+ }
90
103
 
91
104
  /**
92
105
  * Set the current gym context