@gymspace/sdk 1.2.9 → 1.2.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/dist/index.d.mts +19 -181
- package/dist/index.d.ts +19 -181
- package/dist/index.js +38 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +36 -4
- package/src/models/index.ts +0 -2
- package/src/models/onboarding.ts +0 -17
- package/src/models/payment-methods.ts +2 -2
- package/src/models/products.ts +2 -10
- package/src/resources/index.ts +0 -2
- package/src/resources/payment-methods.ts +3 -3
- package/src/resources/products.ts +21 -31
- package/src/sdk.ts +7 -6
- package/src/models/evaluations.ts +0 -91
- package/src/models/leads.ts +0 -52
- package/src/resources/evaluations.ts +0 -63
- package/src/resources/leads.ts +0 -48
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -19,6 +19,7 @@ export class ApiClient {
|
|
|
19
19
|
private axiosInstance: AxiosInstance;
|
|
20
20
|
private config: GymSpaceConfig;
|
|
21
21
|
private refreshToken: string | null = null;
|
|
22
|
+
private onTokenRefreshed?: (accessToken: string, refreshToken?: string) => void;
|
|
22
23
|
|
|
23
24
|
public getAccessToken(): string | null {
|
|
24
25
|
return this.config.apiKey || null;
|
|
@@ -48,8 +49,8 @@ export class ApiClient {
|
|
|
48
49
|
config.headers['Authorization'] = `Bearer ${this.config.apiKey}`;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
// Add refresh token header for
|
|
52
|
-
if (this.refreshToken && config.
|
|
52
|
+
// Add refresh token header for ALL authenticated requests
|
|
53
|
+
if (this.refreshToken && this.config.apiKey && config.headers) {
|
|
53
54
|
config.headers['X-Refresh-Token'] = this.refreshToken;
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -60,13 +61,30 @@ export class ApiClient {
|
|
|
60
61
|
},
|
|
61
62
|
);
|
|
62
63
|
|
|
63
|
-
// Response interceptor -
|
|
64
|
+
// Response interceptor - handle token refresh from backend
|
|
64
65
|
this.axiosInstance.interceptors.response.use(
|
|
65
66
|
(response) => {
|
|
67
|
+
// Check if backend refreshed tokens
|
|
68
|
+
const newAccessToken = response.headers['x-new-access-token'];
|
|
69
|
+
const newRefreshToken = response.headers['x-new-refresh-token'];
|
|
70
|
+
|
|
71
|
+
if (newAccessToken) {
|
|
72
|
+
console.log('Tokens refreshed by backend, updating SDK...');
|
|
73
|
+
this.setAuthToken(newAccessToken);
|
|
74
|
+
|
|
75
|
+
if (newRefreshToken) {
|
|
76
|
+
this.setRefreshToken(newRefreshToken);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Notify client about token refresh
|
|
80
|
+
if (this.onTokenRefreshed) {
|
|
81
|
+
this.onTokenRefreshed(newAccessToken, newRefreshToken);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
66
85
|
return response;
|
|
67
86
|
},
|
|
68
87
|
async (error: AxiosError) => {
|
|
69
|
-
// Simply throw the error - no automatic refresh attempts
|
|
70
88
|
throw this.handleError(error);
|
|
71
89
|
},
|
|
72
90
|
);
|
|
@@ -185,6 +203,20 @@ export class ApiClient {
|
|
|
185
203
|
return this.refreshToken;
|
|
186
204
|
}
|
|
187
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Set callback for when tokens are refreshed by backend
|
|
208
|
+
*/
|
|
209
|
+
setOnTokenRefreshed(callback: (accessToken: string, refreshToken?: string) => void): void {
|
|
210
|
+
this.onTokenRefreshed = callback;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get the token refresh callback
|
|
215
|
+
*/
|
|
216
|
+
getOnTokenRefreshed(): ((accessToken: string, refreshToken?: string) => void) | undefined {
|
|
217
|
+
return this.onTokenRefreshed;
|
|
218
|
+
}
|
|
219
|
+
|
|
188
220
|
setGymId(gymId: string): void {
|
|
189
221
|
this.axiosInstance.defaults.headers.common['X-Gym-Id'] = gymId;
|
|
190
222
|
}
|
package/src/models/index.ts
CHANGED
|
@@ -7,10 +7,8 @@ export * from './clients';
|
|
|
7
7
|
export * from './membership-plans';
|
|
8
8
|
export * from './contracts';
|
|
9
9
|
export * from './dashboard';
|
|
10
|
-
export * from './evaluations';
|
|
11
10
|
export * from './check-ins';
|
|
12
11
|
// invitations types are in @gymspace/shared
|
|
13
|
-
export * from './leads';
|
|
14
12
|
export * from './assets';
|
|
15
13
|
export * from './files';
|
|
16
14
|
export * from './onboarding';
|
package/src/models/onboarding.ts
CHANGED
|
@@ -107,27 +107,12 @@ export interface CheckInSystemFeatures {
|
|
|
107
107
|
allowMultiplePerDay: boolean;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
export interface EvaluationSystemFeatures {
|
|
111
|
-
enabled: boolean;
|
|
112
|
-
trackMeasurements: boolean;
|
|
113
|
-
trackBodyComposition: boolean;
|
|
114
|
-
trackPerformance: boolean;
|
|
115
|
-
defaultFrequencyDays: number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface LeadManagementFeatures {
|
|
119
|
-
enabled: boolean;
|
|
120
|
-
publicCatalogListing: boolean;
|
|
121
|
-
enableOnlineForm: boolean;
|
|
122
|
-
autoAssignLeads: boolean;
|
|
123
|
-
}
|
|
124
110
|
|
|
125
111
|
export interface NotificationSettings {
|
|
126
112
|
emailEnabled: boolean;
|
|
127
113
|
smsEnabled: boolean;
|
|
128
114
|
welcomeEmails: boolean;
|
|
129
115
|
contractExpiryAlerts: boolean;
|
|
130
|
-
evaluationReminders: boolean;
|
|
131
116
|
}
|
|
132
117
|
|
|
133
118
|
export interface ConfigureFeaturesData {
|
|
@@ -135,8 +120,6 @@ export interface ConfigureFeaturesData {
|
|
|
135
120
|
clientManagement: ClientManagementFeatures;
|
|
136
121
|
membershipManagement: MembershipManagementFeatures;
|
|
137
122
|
checkInSystem: CheckInSystemFeatures;
|
|
138
|
-
evaluationSystem: EvaluationSystemFeatures;
|
|
139
|
-
leadManagement: LeadManagementFeatures;
|
|
140
123
|
notifications: NotificationSettings;
|
|
141
124
|
}
|
|
142
125
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
|
|
3
3
|
export interface CreatePaymentMethodDto {
|
|
4
4
|
name: string;
|
|
@@ -41,7 +41,7 @@ export interface PaymentMethod {
|
|
|
41
41
|
} | null;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export interface SearchPaymentMethodsParams
|
|
44
|
+
export interface SearchPaymentMethodsParams {
|
|
45
45
|
search?: string;
|
|
46
46
|
enabledOnly?: boolean;
|
|
47
47
|
code?: string;
|
package/src/models/products.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { PaginationQueryDto } from '../types';
|
|
2
|
-
|
|
3
1
|
// Product Category Models
|
|
4
2
|
export interface CreateProductCategoryDto {
|
|
5
3
|
name: string;
|
|
@@ -42,12 +40,9 @@ export interface CreateProductDto {
|
|
|
42
40
|
description?: string;
|
|
43
41
|
price: number;
|
|
44
42
|
stock?: number;
|
|
45
|
-
minStock?: number;
|
|
46
|
-
maxStock?: number;
|
|
47
43
|
categoryId?: string;
|
|
48
44
|
imageId?: string;
|
|
49
45
|
status?: 'active' | 'inactive';
|
|
50
|
-
trackInventory?: 'none' | 'simple' | 'advanced' | 'capacity';
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
export interface CreateServiceDto {
|
|
@@ -63,12 +58,9 @@ export interface UpdateProductDto {
|
|
|
63
58
|
description?: string;
|
|
64
59
|
price?: number;
|
|
65
60
|
stock?: number;
|
|
66
|
-
minStock?: number;
|
|
67
|
-
maxStock?: number;
|
|
68
61
|
categoryId?: string;
|
|
69
62
|
imageId?: string;
|
|
70
63
|
status?: 'active' | 'inactive';
|
|
71
|
-
trackInventory?: 'none' | 'simple' | 'advanced' | 'capacity';
|
|
72
64
|
}
|
|
73
65
|
|
|
74
66
|
export interface UpdateStockDto {
|
|
@@ -110,7 +102,7 @@ export interface Product {
|
|
|
110
102
|
};
|
|
111
103
|
}
|
|
112
104
|
|
|
113
|
-
export interface SearchProductsParams
|
|
105
|
+
export interface SearchProductsParams {
|
|
114
106
|
search?: string;
|
|
115
107
|
categoryId?: string;
|
|
116
108
|
type?: 'Product' | 'Service';
|
|
@@ -143,4 +135,4 @@ export interface StockMovement {
|
|
|
143
135
|
id: string;
|
|
144
136
|
name: string;
|
|
145
137
|
};
|
|
146
|
-
}
|
|
138
|
+
}
|
package/src/resources/index.ts
CHANGED
|
@@ -7,10 +7,8 @@ export * from './clients';
|
|
|
7
7
|
export * from './membership-plans';
|
|
8
8
|
export * from './contracts';
|
|
9
9
|
export * from './dashboard';
|
|
10
|
-
export * from './evaluations';
|
|
11
10
|
export * from './check-ins';
|
|
12
11
|
export * from './invitations';
|
|
13
|
-
export * from './leads';
|
|
14
12
|
export * from './assets';
|
|
15
13
|
export * from './files';
|
|
16
14
|
export * from './public-catalog';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
SearchPaymentMethodsParams,
|
|
7
7
|
PaymentMethodStats
|
|
8
8
|
} from '../models/payment-methods';
|
|
9
|
-
import { RequestOptions
|
|
9
|
+
import { RequestOptions } from '../types';
|
|
10
10
|
|
|
11
11
|
export class PaymentMethodsResource extends BaseResource {
|
|
12
12
|
private basePath = 'payment-methods';
|
|
@@ -18,8 +18,8 @@ export class PaymentMethodsResource extends BaseResource {
|
|
|
18
18
|
async searchPaymentMethods(
|
|
19
19
|
params?: SearchPaymentMethodsParams,
|
|
20
20
|
options?: RequestOptions
|
|
21
|
-
): Promise<
|
|
22
|
-
return this.
|
|
21
|
+
): Promise<PaymentMethod[]> {
|
|
22
|
+
return this.client.get<PaymentMethod[]>(this.basePath, params, options);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async getPaymentMethod(id: string, options?: RequestOptions): Promise<PaymentMethod> {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
3
|
Product,
|
|
4
4
|
ProductCategory,
|
|
5
5
|
StockMovement,
|
|
6
|
-
CreateProductDto,
|
|
6
|
+
CreateProductDto,
|
|
7
7
|
CreateServiceDto,
|
|
8
8
|
UpdateProductDto,
|
|
9
9
|
UpdateStockDto,
|
|
10
10
|
CreateProductCategoryDto,
|
|
11
11
|
UpdateProductCategoryDto,
|
|
12
|
-
SearchProductsParams
|
|
12
|
+
SearchProductsParams,
|
|
13
13
|
} from '../models/products';
|
|
14
|
-
import { RequestOptions
|
|
14
|
+
import { RequestOptions } from '../types';
|
|
15
15
|
|
|
16
16
|
export class ProductsResource extends BaseResource {
|
|
17
17
|
private basePath = 'products';
|
|
18
18
|
|
|
19
19
|
// Product Category Methods
|
|
20
20
|
async createCategory(
|
|
21
|
-
data: CreateProductCategoryDto,
|
|
22
|
-
options?: RequestOptions
|
|
21
|
+
data: CreateProductCategoryDto,
|
|
22
|
+
options?: RequestOptions,
|
|
23
23
|
): Promise<ProductCategory> {
|
|
24
24
|
return this.client.post<ProductCategory>(`${this.basePath}/categories`, data, options);
|
|
25
25
|
}
|
|
@@ -31,7 +31,7 @@ export class ProductsResource extends BaseResource {
|
|
|
31
31
|
async updateCategory(
|
|
32
32
|
id: string,
|
|
33
33
|
data: UpdateProductCategoryDto,
|
|
34
|
-
options?: RequestOptions
|
|
34
|
+
options?: RequestOptions,
|
|
35
35
|
): Promise<ProductCategory> {
|
|
36
36
|
return this.client.put<ProductCategory>(`${this.basePath}/categories/${id}`, data, options);
|
|
37
37
|
}
|
|
@@ -51,9 +51,9 @@ export class ProductsResource extends BaseResource {
|
|
|
51
51
|
|
|
52
52
|
async searchProducts(
|
|
53
53
|
params?: SearchProductsParams,
|
|
54
|
-
options?: RequestOptions
|
|
55
|
-
): Promise<
|
|
56
|
-
return this.
|
|
54
|
+
options?: RequestOptions,
|
|
55
|
+
): Promise<Product[]> {
|
|
56
|
+
return this.client.get<Product[]>(this.basePath, params, options);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async getProduct(id: string, options?: RequestOptions): Promise<Product> {
|
|
@@ -63,7 +63,7 @@ export class ProductsResource extends BaseResource {
|
|
|
63
63
|
async updateProduct(
|
|
64
64
|
id: string,
|
|
65
65
|
data: UpdateProductDto,
|
|
66
|
-
options?: RequestOptions
|
|
66
|
+
options?: RequestOptions,
|
|
67
67
|
): Promise<Product> {
|
|
68
68
|
return this.client.put<Product>(`${this.basePath}/${id}`, data, options);
|
|
69
69
|
}
|
|
@@ -76,29 +76,19 @@ export class ProductsResource extends BaseResource {
|
|
|
76
76
|
return this.client.patch<Product>(`${this.basePath}/${id}/toggle-status`, undefined, options);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
async updateStock(
|
|
80
|
-
id: string,
|
|
81
|
-
data: UpdateStockDto,
|
|
82
|
-
options?: RequestOptions
|
|
83
|
-
): Promise<Product> {
|
|
79
|
+
async updateStock(id: string, data: UpdateStockDto, options?: RequestOptions): Promise<Product> {
|
|
84
80
|
return this.client.patch<Product>(`${this.basePath}/${id}/stock`, data, options);
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
async getLowStockProducts(
|
|
88
|
-
|
|
89
|
-
options?: RequestOptions
|
|
90
|
-
): Promise<Product[]> {
|
|
91
|
-
return this.client.get<Product[]>(
|
|
92
|
-
`${this.basePath}/low-stock`,
|
|
93
|
-
{ threshold },
|
|
94
|
-
options
|
|
95
|
-
);
|
|
83
|
+
async getLowStockProducts(threshold: number = 10, options?: RequestOptions): Promise<Product[]> {
|
|
84
|
+
return this.client.get<Product[]>(`${this.basePath}/low-stock`, { threshold }, options);
|
|
96
85
|
}
|
|
97
86
|
|
|
98
|
-
async getProductStockMovements(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
async getProductStockMovements(id: string, options?: RequestOptions): Promise<StockMovement[]> {
|
|
88
|
+
return this.client.get<StockMovement[]>(
|
|
89
|
+
`${this.basePath}/${id}/stock-movements`,
|
|
90
|
+
undefined,
|
|
91
|
+
options,
|
|
92
|
+
);
|
|
103
93
|
}
|
|
104
|
-
}
|
|
94
|
+
}
|
package/src/sdk.ts
CHANGED
|
@@ -11,10 +11,8 @@ import {
|
|
|
11
11
|
MembershipPlansResource,
|
|
12
12
|
ContractsResource,
|
|
13
13
|
DashboardResource,
|
|
14
|
-
EvaluationsResource,
|
|
15
14
|
CheckInsResource,
|
|
16
15
|
InvitationsResource,
|
|
17
|
-
LeadsResource,
|
|
18
16
|
AssetsResource,
|
|
19
17
|
FilesResource,
|
|
20
18
|
PublicCatalogResource,
|
|
@@ -46,10 +44,8 @@ export class GymSpaceSdk {
|
|
|
46
44
|
public membershipPlans: MembershipPlansResource;
|
|
47
45
|
public contracts: ContractsResource;
|
|
48
46
|
public dashboard: DashboardResource;
|
|
49
|
-
public evaluations: EvaluationsResource;
|
|
50
47
|
public checkIns: CheckInsResource;
|
|
51
48
|
public invitations: InvitationsResource;
|
|
52
|
-
public leads: LeadsResource;
|
|
53
49
|
public assets: AssetsResource;
|
|
54
50
|
public files: FilesResource;
|
|
55
51
|
public publicCatalog: PublicCatalogResource;
|
|
@@ -79,10 +75,8 @@ export class GymSpaceSdk {
|
|
|
79
75
|
this.membershipPlans = new MembershipPlansResource(this.client);
|
|
80
76
|
this.contracts = new ContractsResource(this.client);
|
|
81
77
|
this.dashboard = new DashboardResource(this.client);
|
|
82
|
-
this.evaluations = new EvaluationsResource(this.client);
|
|
83
78
|
this.checkIns = new CheckInsResource(this.client);
|
|
84
79
|
this.invitations = new InvitationsResource(this.client);
|
|
85
|
-
this.leads = new LeadsResource(this.client);
|
|
86
80
|
this.assets = new AssetsResource(this.client);
|
|
87
81
|
this.files = new FilesResource(this.client);
|
|
88
82
|
this.publicCatalog = new PublicCatalogResource(this.client);
|
|
@@ -152,6 +146,13 @@ export class GymSpaceSdk {
|
|
|
152
146
|
return createAgentFetch(this.client, this.expoFetch);
|
|
153
147
|
}
|
|
154
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Set callback for when tokens are refreshed by backend
|
|
151
|
+
*/
|
|
152
|
+
setOnTokenRefreshed(callback: (accessToken: string, refreshToken?: string) => void): void {
|
|
153
|
+
this.client.setOnTokenRefreshed(callback);
|
|
154
|
+
}
|
|
155
|
+
|
|
155
156
|
/**
|
|
156
157
|
* Get the underlying API client
|
|
157
158
|
*/
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { PaginationQueryDto } from '../types';
|
|
2
|
-
|
|
3
|
-
export interface CreateEvaluationDto {
|
|
4
|
-
gymClientId: string;
|
|
5
|
-
weight: number;
|
|
6
|
-
height: number;
|
|
7
|
-
bodyFatPercentage?: number;
|
|
8
|
-
muscleMassPercentage?: number;
|
|
9
|
-
measurements?: EvaluationMeasurements;
|
|
10
|
-
healthMetrics?: EvaluationHealthMetrics;
|
|
11
|
-
performanceMetrics?: EvaluationPerformanceMetrics;
|
|
12
|
-
notes?: string;
|
|
13
|
-
goals?: string;
|
|
14
|
-
recommendations?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface UpdateEvaluationDto {
|
|
18
|
-
gymClientId?: string;
|
|
19
|
-
weight?: number;
|
|
20
|
-
height?: number;
|
|
21
|
-
bodyFatPercentage?: number;
|
|
22
|
-
muscleMassPercentage?: number;
|
|
23
|
-
measurements?: EvaluationMeasurements;
|
|
24
|
-
healthMetrics?: EvaluationHealthMetrics;
|
|
25
|
-
performanceMetrics?: EvaluationPerformanceMetrics;
|
|
26
|
-
notes?: string;
|
|
27
|
-
goals?: string;
|
|
28
|
-
recommendations?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface EvaluationMeasurements {
|
|
32
|
-
chest?: number;
|
|
33
|
-
waist?: number;
|
|
34
|
-
hips?: number;
|
|
35
|
-
leftArm?: number;
|
|
36
|
-
rightArm?: number;
|
|
37
|
-
leftThigh?: number;
|
|
38
|
-
rightThigh?: number;
|
|
39
|
-
[key: string]: number | undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface EvaluationHealthMetrics {
|
|
43
|
-
bloodPressure?: string;
|
|
44
|
-
restingHeartRate?: number;
|
|
45
|
-
vo2Max?: number;
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface EvaluationPerformanceMetrics {
|
|
50
|
-
benchPress?: number;
|
|
51
|
-
squat?: number;
|
|
52
|
-
deadlift?: number;
|
|
53
|
-
[key: string]: number | undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface Evaluation {
|
|
57
|
-
id: string;
|
|
58
|
-
gymId: string;
|
|
59
|
-
gymClientId: string;
|
|
60
|
-
evaluatorId: string;
|
|
61
|
-
evaluationDate: string;
|
|
62
|
-
weight: number;
|
|
63
|
-
height: number;
|
|
64
|
-
bmi: number;
|
|
65
|
-
bodyFatPercentage?: number;
|
|
66
|
-
muscleMassPercentage?: number;
|
|
67
|
-
measurements?: EvaluationMeasurements;
|
|
68
|
-
healthMetrics?: EvaluationHealthMetrics;
|
|
69
|
-
performanceMetrics?: EvaluationPerformanceMetrics;
|
|
70
|
-
notes?: string;
|
|
71
|
-
goals?: string;
|
|
72
|
-
recommendations?: string;
|
|
73
|
-
createdAt: string;
|
|
74
|
-
updatedAt: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface GetClientEvaluationsParams extends PaginationQueryDto {
|
|
78
|
-
// Additional evaluation-specific parameters can be added here
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface EvaluationReport {
|
|
82
|
-
evaluation: Evaluation;
|
|
83
|
-
client: any;
|
|
84
|
-
previousEvaluation?: Evaluation;
|
|
85
|
-
evolution?: {
|
|
86
|
-
weight: number;
|
|
87
|
-
bodyFat: number;
|
|
88
|
-
muscleMass: number;
|
|
89
|
-
measurements: Record<string, number>;
|
|
90
|
-
};
|
|
91
|
-
}
|
package/src/models/leads.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { LeadStatus } from '@gymspace/shared';
|
|
2
|
-
import { PaginationQueryDto } from '../types';
|
|
3
|
-
|
|
4
|
-
export interface CreateLeadDto {
|
|
5
|
-
name: string;
|
|
6
|
-
email: string;
|
|
7
|
-
phone: string;
|
|
8
|
-
gymId: string;
|
|
9
|
-
message?: string;
|
|
10
|
-
source?: string;
|
|
11
|
-
metadata?: Record<string, any>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface UpdateLeadDto {
|
|
15
|
-
status?: LeadStatus;
|
|
16
|
-
notes?: string;
|
|
17
|
-
assignedToUserId?: string;
|
|
18
|
-
metadata?: Record<string, any>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface Lead {
|
|
22
|
-
id: string;
|
|
23
|
-
gymId: string;
|
|
24
|
-
name: string;
|
|
25
|
-
email: string;
|
|
26
|
-
phone: string;
|
|
27
|
-
status: LeadStatus;
|
|
28
|
-
source?: string;
|
|
29
|
-
message?: string;
|
|
30
|
-
notes?: string;
|
|
31
|
-
assignedToUserId?: string;
|
|
32
|
-
convertedToClientId?: string;
|
|
33
|
-
metadata?: Record<string, any>;
|
|
34
|
-
createdAt: string;
|
|
35
|
-
updatedAt: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface SearchLeadsParams extends PaginationQueryDto {
|
|
39
|
-
status?: LeadStatus;
|
|
40
|
-
search?: string;
|
|
41
|
-
assignedToUserId?: string;
|
|
42
|
-
startDate?: string;
|
|
43
|
-
endDate?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface LeadStats {
|
|
47
|
-
total: number;
|
|
48
|
-
byStatus: Record<LeadStatus, number>;
|
|
49
|
-
conversionRate: number;
|
|
50
|
-
averageResponseTime: number;
|
|
51
|
-
bySource: Record<string, number>;
|
|
52
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
3
|
-
Evaluation,
|
|
4
|
-
CreateEvaluationDto,
|
|
5
|
-
UpdateEvaluationDto,
|
|
6
|
-
GetClientEvaluationsParams,
|
|
7
|
-
EvaluationReport
|
|
8
|
-
} from '../models/evaluations';
|
|
9
|
-
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
10
|
-
|
|
11
|
-
export class EvaluationsResource extends BaseResource {
|
|
12
|
-
private basePath = 'evaluations';
|
|
13
|
-
|
|
14
|
-
async createEvaluation(
|
|
15
|
-
data: CreateEvaluationDto,
|
|
16
|
-
options?: RequestOptions
|
|
17
|
-
): Promise<Evaluation> {
|
|
18
|
-
return this.client.post<Evaluation>(this.basePath, data, options);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async getEvaluation(id: string, options?: RequestOptions): Promise<Evaluation> {
|
|
22
|
-
return this.client.get<Evaluation>(`${this.basePath}/${id}`, undefined, options);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async updateEvaluation(
|
|
26
|
-
id: string,
|
|
27
|
-
data: UpdateEvaluationDto,
|
|
28
|
-
options?: RequestOptions
|
|
29
|
-
): Promise<Evaluation> {
|
|
30
|
-
return this.client.put<Evaluation>(`${this.basePath}/${id}`, data, options);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async deleteEvaluation(id: string, options?: RequestOptions): Promise<void> {
|
|
34
|
-
return this.client.delete<void>(`${this.basePath}/${id}`, options);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async getClientEvaluations(
|
|
38
|
-
clientId: string,
|
|
39
|
-
params?: GetClientEvaluationsParams,
|
|
40
|
-
options?: RequestOptions
|
|
41
|
-
): Promise<PaginatedResponseDto<Evaluation>> {
|
|
42
|
-
return this.paginate<Evaluation>(
|
|
43
|
-
`${this.basePath}/client/${clientId}`,
|
|
44
|
-
params,
|
|
45
|
-
options
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async getGymEvaluationStats(options?: RequestOptions): Promise<any> {
|
|
50
|
-
return this.client.get(`${this.basePath}/gym/stats`, undefined, options);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async generateEvaluationReport(
|
|
54
|
-
id: string,
|
|
55
|
-
options?: RequestOptions
|
|
56
|
-
): Promise<EvaluationReport> {
|
|
57
|
-
return this.client.get<EvaluationReport>(
|
|
58
|
-
`${this.basePath}/${id}/report`,
|
|
59
|
-
undefined,
|
|
60
|
-
options
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/resources/leads.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
3
|
-
Lead,
|
|
4
|
-
CreateLeadDto,
|
|
5
|
-
UpdateLeadDto,
|
|
6
|
-
SearchLeadsParams,
|
|
7
|
-
LeadStats
|
|
8
|
-
} from '../models/leads';
|
|
9
|
-
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
10
|
-
|
|
11
|
-
export class LeadsResource extends BaseResource {
|
|
12
|
-
private basePath = 'leads';
|
|
13
|
-
|
|
14
|
-
async createLead(data: CreateLeadDto, options?: RequestOptions): Promise<Lead> {
|
|
15
|
-
return this.client.post<Lead>(this.basePath, data, options);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async searchLeads(
|
|
19
|
-
params?: SearchLeadsParams,
|
|
20
|
-
options?: RequestOptions
|
|
21
|
-
): Promise<PaginatedResponseDto<Lead>> {
|
|
22
|
-
return this.paginate<Lead>(this.basePath, params, options);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async getLead(id: string, options?: RequestOptions): Promise<Lead> {
|
|
26
|
-
return this.client.get<Lead>(`${this.basePath}/${id}`, undefined, options);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async updateLead(
|
|
30
|
-
id: string,
|
|
31
|
-
data: UpdateLeadDto,
|
|
32
|
-
options?: RequestOptions
|
|
33
|
-
): Promise<Lead> {
|
|
34
|
-
return this.client.put<Lead>(`${this.basePath}/${id}`, data, options);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async getLeadStats(options?: RequestOptions): Promise<LeadStats> {
|
|
38
|
-
return this.client.get<LeadStats>(`${this.basePath}/stats/gym`, undefined, options);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async convertLead(id: string, options?: RequestOptions): Promise<{ clientId: string }> {
|
|
42
|
-
return this.client.post<{ clientId: string }>(
|
|
43
|
-
`${this.basePath}/${id}/convert`,
|
|
44
|
-
undefined,
|
|
45
|
-
options
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|