@gymspace/sdk 1.0.0
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/README.md +160 -0
- package/dist/index.js +1379 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1321 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +76 -0
- package/src/client.ts +200 -0
- package/src/errors.ts +49 -0
- package/src/index.ts +15 -0
- package/src/models/assets.ts +24 -0
- package/src/models/auth.ts +155 -0
- package/src/models/check-ins.ts +75 -0
- package/src/models/clients.ts +109 -0
- package/src/models/contracts.ts +61 -0
- package/src/models/dashboard.ts +32 -0
- package/src/models/evaluations.ts +91 -0
- package/src/models/files.ts +23 -0
- package/src/models/gyms.ts +73 -0
- package/src/models/index.ts +24 -0
- package/src/models/invitations.ts +29 -0
- package/src/models/leads.ts +52 -0
- package/src/models/membership-plans.ts +71 -0
- package/src/models/onboarding.ts +171 -0
- package/src/models/organizations.ts +25 -0
- package/src/models/products.ts +99 -0
- package/src/models/sales.ts +108 -0
- package/src/models/suppliers.ts +57 -0
- package/src/models/users.ts +17 -0
- package/src/resources/assets.ts +102 -0
- package/src/resources/auth.ts +137 -0
- package/src/resources/base.ts +50 -0
- package/src/resources/check-ins.ts +63 -0
- package/src/resources/clients.ts +57 -0
- package/src/resources/contracts.ts +59 -0
- package/src/resources/dashboard.ts +30 -0
- package/src/resources/evaluations.ts +63 -0
- package/src/resources/files.ts +95 -0
- package/src/resources/gyms.ts +61 -0
- package/src/resources/health.ts +28 -0
- package/src/resources/index.ts +20 -0
- package/src/resources/invitations.ts +38 -0
- package/src/resources/leads.ts +48 -0
- package/src/resources/membership-plans.ts +54 -0
- package/src/resources/onboarding.ts +58 -0
- package/src/resources/organizations.ts +23 -0
- package/src/resources/products.ts +91 -0
- package/src/resources/public-catalog.ts +61 -0
- package/src/resources/sales.ts +83 -0
- package/src/resources/suppliers.ts +44 -0
- package/src/resources/users.ts +27 -0
- package/src/sdk.ts +104 -0
- package/src/types.ts +41 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CurrentSessionResponse,
|
|
3
|
+
InvitationValidationResponse,
|
|
4
|
+
LoginDto,
|
|
5
|
+
LoginResponseDto,
|
|
6
|
+
RegisterCollaboratorDto,
|
|
7
|
+
RegisterOwnerDto,
|
|
8
|
+
ResendVerificationDto,
|
|
9
|
+
SubscriptionPlan,
|
|
10
|
+
VerifyEmailDto,
|
|
11
|
+
ChangePasswordDto,
|
|
12
|
+
ChangePasswordResponseDto,
|
|
13
|
+
RequestPasswordResetDto,
|
|
14
|
+
RequestPasswordResetResponseDto,
|
|
15
|
+
VerifyResetCodeDto,
|
|
16
|
+
VerifyResetCodeResponseDto,
|
|
17
|
+
ResetPasswordDto,
|
|
18
|
+
ResetPasswordResponseDto,
|
|
19
|
+
ResendResetCodeDto,
|
|
20
|
+
ResendResetCodeResponseDto,
|
|
21
|
+
} from '../models/auth';
|
|
22
|
+
import { RequestOptions } from '../types';
|
|
23
|
+
import { BaseResource } from './base';
|
|
24
|
+
|
|
25
|
+
export class AuthResource extends BaseResource {
|
|
26
|
+
private basePath = 'auth';
|
|
27
|
+
|
|
28
|
+
async registerOwner(data: RegisterOwnerDto, options?: RequestOptions): Promise<void> {
|
|
29
|
+
return this.client.post(`${this.basePath}/register/owner`, data, options);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async login(data: LoginDto, options?: RequestOptions): Promise<LoginResponseDto> {
|
|
33
|
+
return this.client.post<LoginResponseDto>(`${this.basePath}/login`, data, options);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async refreshToken(options?: RequestOptions): Promise<LoginResponseDto> {
|
|
37
|
+
return this.client.post<LoginResponseDto>(`${this.basePath}/refresh`, undefined, options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async verifyEmail(
|
|
41
|
+
data: VerifyEmailDto,
|
|
42
|
+
options?: RequestOptions,
|
|
43
|
+
): Promise<{ success: boolean; message: string }> {
|
|
44
|
+
return this.client.post(`${this.basePath}/verify-email`, data, options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async resendVerification(
|
|
48
|
+
data: ResendVerificationDto,
|
|
49
|
+
options?: RequestOptions,
|
|
50
|
+
): Promise<{ success: boolean; message: string }> {
|
|
51
|
+
console.log('the path', `${this.basePath}/resend-verification`);
|
|
52
|
+
|
|
53
|
+
return this.client.post(`${this.basePath}/resend-verification`, data, options);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async getSubscriptionPlans(options?: RequestOptions): Promise<{ data: SubscriptionPlan[] }> {
|
|
58
|
+
return this.client.get(`${this.basePath}/subscription-plans`, options);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async validateInvitation(
|
|
62
|
+
token: string,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<InvitationValidationResponse> {
|
|
65
|
+
return this.client.get(`${this.basePath}/invitation/${token}`, options);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async registerCollaborator(
|
|
69
|
+
data: RegisterCollaboratorDto,
|
|
70
|
+
options?: RequestOptions,
|
|
71
|
+
): Promise<LoginResponseDto> {
|
|
72
|
+
return this.client.post<LoginResponseDto>(
|
|
73
|
+
`${this.basePath}/register/collaborator`,
|
|
74
|
+
data,
|
|
75
|
+
options,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getCurrentSession(options?: RequestOptions): Promise<CurrentSessionResponse> {
|
|
80
|
+
return this.client.get<CurrentSessionResponse>(`${this.basePath}/current-session`, options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async changePassword(
|
|
84
|
+
data: ChangePasswordDto,
|
|
85
|
+
options?: RequestOptions,
|
|
86
|
+
): Promise<ChangePasswordResponseDto> {
|
|
87
|
+
return this.client.post<ChangePasswordResponseDto>(
|
|
88
|
+
`${this.basePath}/change-password`,
|
|
89
|
+
data,
|
|
90
|
+
options,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async requestPasswordReset(
|
|
95
|
+
data: RequestPasswordResetDto,
|
|
96
|
+
options?: RequestOptions,
|
|
97
|
+
): Promise<RequestPasswordResetResponseDto> {
|
|
98
|
+
return this.client.post<RequestPasswordResetResponseDto>(
|
|
99
|
+
`${this.basePath}/password-reset/request`,
|
|
100
|
+
data,
|
|
101
|
+
options,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async verifyResetCode(
|
|
106
|
+
data: VerifyResetCodeDto,
|
|
107
|
+
options?: RequestOptions,
|
|
108
|
+
): Promise<VerifyResetCodeResponseDto> {
|
|
109
|
+
return this.client.post<VerifyResetCodeResponseDto>(
|
|
110
|
+
`${this.basePath}/password-reset/verify-code`,
|
|
111
|
+
data,
|
|
112
|
+
options,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async resetPassword(
|
|
117
|
+
data: ResetPasswordDto,
|
|
118
|
+
options?: RequestOptions,
|
|
119
|
+
): Promise<ResetPasswordResponseDto> {
|
|
120
|
+
return this.client.post<ResetPasswordResponseDto>(
|
|
121
|
+
`${this.basePath}/password-reset/reset`,
|
|
122
|
+
data,
|
|
123
|
+
options,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async resendResetCode(
|
|
128
|
+
data: ResendResetCodeDto,
|
|
129
|
+
options?: RequestOptions,
|
|
130
|
+
): Promise<ResendResetCodeResponseDto> {
|
|
131
|
+
return this.client.post<ResendResetCodeResponseDto>(
|
|
132
|
+
`${this.basePath}/password-reset/resend-code`,
|
|
133
|
+
data,
|
|
134
|
+
options,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ApiClient } from '../client';
|
|
2
|
+
import { RequestOptions, PaginatedResponseDto, PaginationQueryDto } from '../types';
|
|
3
|
+
|
|
4
|
+
export abstract class BaseResource {
|
|
5
|
+
constructor(protected client: ApiClient) {}
|
|
6
|
+
|
|
7
|
+
protected async request<T>(
|
|
8
|
+
path: string,
|
|
9
|
+
options: {
|
|
10
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
11
|
+
body?: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
): Promise<T> {
|
|
15
|
+
const data = options.body ? JSON.parse(options.body) : undefined;
|
|
16
|
+
|
|
17
|
+
switch (options.method) {
|
|
18
|
+
case 'GET':
|
|
19
|
+
return this.client.get<T>(path, data, { headers: options.headers });
|
|
20
|
+
case 'POST':
|
|
21
|
+
return this.client.post<T>(path, data, { headers: options.headers });
|
|
22
|
+
case 'PUT':
|
|
23
|
+
return this.client.put<T>(path, data, { headers: options.headers });
|
|
24
|
+
case 'PATCH':
|
|
25
|
+
return this.client.patch<T>(path, data, { headers: options.headers });
|
|
26
|
+
case 'DELETE':
|
|
27
|
+
return this.client.delete<T>(path, { headers: options.headers });
|
|
28
|
+
default:
|
|
29
|
+
throw new Error(`Unsupported HTTP method: ${options.method}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
protected buildPath(base: string, ...segments: (string | undefined)[]): string {
|
|
34
|
+
const parts = [base];
|
|
35
|
+
for (const segment of segments) {
|
|
36
|
+
if (segment !== undefined) {
|
|
37
|
+
parts.push(segment);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return parts.join('/');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected async paginate<T>(
|
|
44
|
+
path: string,
|
|
45
|
+
params?: PaginationQueryDto & Record<string, any>,
|
|
46
|
+
options?: RequestOptions
|
|
47
|
+
): Promise<PaginatedResponseDto<T>> {
|
|
48
|
+
return this.client.get<PaginatedResponseDto<T>>(path, params, options);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import {
|
|
3
|
+
CheckIn,
|
|
4
|
+
CreateCheckInDto,
|
|
5
|
+
SearchCheckInsParams,
|
|
6
|
+
GetCheckInStatsParams,
|
|
7
|
+
CheckInStats,
|
|
8
|
+
GetClientCheckInHistoryParams,
|
|
9
|
+
CurrentlyInGymResponse,
|
|
10
|
+
CheckInListResponse,
|
|
11
|
+
ClientCheckInHistory
|
|
12
|
+
} from '../models/check-ins';
|
|
13
|
+
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
14
|
+
|
|
15
|
+
export class CheckInsResource extends BaseResource {
|
|
16
|
+
private basePath = 'check-ins';
|
|
17
|
+
|
|
18
|
+
async createCheckIn(data: CreateCheckInDto, options?: RequestOptions): Promise<CheckIn> {
|
|
19
|
+
return this.client.post<CheckIn>(this.basePath, data, options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async searchCheckIns(
|
|
23
|
+
params?: SearchCheckInsParams,
|
|
24
|
+
options?: RequestOptions
|
|
25
|
+
): Promise<CheckInListResponse> {
|
|
26
|
+
return this.client.get<CheckInListResponse>(this.basePath, params, options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getCurrentlyInGym(options?: RequestOptions): Promise<CurrentlyInGymResponse> {
|
|
30
|
+
return this.client.get<CurrentlyInGymResponse>(`${this.basePath}/current`, undefined, options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async getCheckIn(id: string, options?: RequestOptions): Promise<CheckIn> {
|
|
34
|
+
return this.client.get<CheckIn>(`${this.basePath}/${id}`, undefined, options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async deleteCheckIn(id: string, options?: RequestOptions): Promise<void> {
|
|
38
|
+
return this.client.delete<void>(`${this.basePath}/${id}`, options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async getGymCheckInStats(
|
|
42
|
+
params: GetCheckInStatsParams,
|
|
43
|
+
options?: RequestOptions
|
|
44
|
+
): Promise<CheckInStats> {
|
|
45
|
+
return this.client.get<CheckInStats>(
|
|
46
|
+
`${this.basePath}/stats/${params.period}`,
|
|
47
|
+
undefined,
|
|
48
|
+
options
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async getClientCheckInHistory(
|
|
53
|
+
clientId: string,
|
|
54
|
+
params?: GetClientCheckInHistoryParams,
|
|
55
|
+
options?: RequestOptions
|
|
56
|
+
): Promise<ClientCheckInHistory> {
|
|
57
|
+
return this.client.get<ClientCheckInHistory>(
|
|
58
|
+
`${this.basePath}/client/${clientId}/history`,
|
|
59
|
+
params,
|
|
60
|
+
options
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import {
|
|
3
|
+
Client,
|
|
4
|
+
CreateClientDto,
|
|
5
|
+
UpdateClientDto,
|
|
6
|
+
ClientStats,
|
|
7
|
+
SearchClientsParams,
|
|
8
|
+
ClientSearchForCheckInResponse
|
|
9
|
+
} from '../models/clients';
|
|
10
|
+
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
11
|
+
|
|
12
|
+
export class ClientsResource extends BaseResource {
|
|
13
|
+
private basePath = 'clients';
|
|
14
|
+
|
|
15
|
+
async createClient(data: CreateClientDto, options?: RequestOptions): Promise<Client> {
|
|
16
|
+
return this.client.post<Client>(this.basePath, data, options);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async searchClients(
|
|
20
|
+
params?: SearchClientsParams,
|
|
21
|
+
options?: RequestOptions
|
|
22
|
+
): Promise<PaginatedResponseDto<Client>> {
|
|
23
|
+
return this.paginate<Client>(this.basePath, params, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async getClient(id: string, options?: RequestOptions): Promise<Client> {
|
|
27
|
+
return this.client.get<Client>(`${this.basePath}/${id}`, undefined, options);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async updateClient(
|
|
31
|
+
id: string,
|
|
32
|
+
data: UpdateClientDto,
|
|
33
|
+
options?: RequestOptions
|
|
34
|
+
): Promise<Client> {
|
|
35
|
+
return this.client.put<Client>(`${this.basePath}/${id}`, data, options);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async toggleClientStatus(id: string, options?: RequestOptions): Promise<Client> {
|
|
39
|
+
return this.client.put<Client>(`${this.basePath}/${id}/toggle-status`, undefined, options);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async getClientStats(id: string, options?: RequestOptions): Promise<ClientStats> {
|
|
43
|
+
return this.client.get<ClientStats>(`${this.basePath}/${id}/stats`, undefined, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async searchClientsForCheckIn(
|
|
47
|
+
params?: SearchClientsParams,
|
|
48
|
+
options?: RequestOptions
|
|
49
|
+
): Promise<ClientSearchForCheckInResponse> {
|
|
50
|
+
// This endpoint automatically includes contract status and only active clients
|
|
51
|
+
return this.client.get<ClientSearchForCheckInResponse>(
|
|
52
|
+
`${this.basePath}/search/check-in`,
|
|
53
|
+
params,
|
|
54
|
+
options
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import {
|
|
3
|
+
Contract,
|
|
4
|
+
CreateContractDto,
|
|
5
|
+
RenewContractDto,
|
|
6
|
+
FreezeContractDto,
|
|
7
|
+
GetContractsParams
|
|
8
|
+
} from '../models/contracts';
|
|
9
|
+
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
10
|
+
|
|
11
|
+
export class ContractsResource extends BaseResource {
|
|
12
|
+
private basePath = 'contracts';
|
|
13
|
+
|
|
14
|
+
async createContract(data: CreateContractDto, options?: RequestOptions): Promise<Contract> {
|
|
15
|
+
return this.client.post<Contract>(this.basePath, data, options);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async getGymContracts(
|
|
19
|
+
params?: GetContractsParams,
|
|
20
|
+
options?: RequestOptions
|
|
21
|
+
): Promise<PaginatedResponseDto<Contract>> {
|
|
22
|
+
return this.paginate<Contract>(this.basePath, params, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async getContract(id: string, options?: RequestOptions): Promise<Contract> {
|
|
26
|
+
return this.client.get<Contract>(`${this.basePath}/${id}`, undefined, options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getClientContracts(
|
|
30
|
+
clientId: string,
|
|
31
|
+
options?: RequestOptions
|
|
32
|
+
): Promise<Contract[]> {
|
|
33
|
+
return this.client.get<Contract[]>(
|
|
34
|
+
`${this.basePath}/client/${clientId}`,
|
|
35
|
+
undefined,
|
|
36
|
+
options
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async renewContract(
|
|
41
|
+
id: string,
|
|
42
|
+
data: RenewContractDto,
|
|
43
|
+
options?: RequestOptions
|
|
44
|
+
): Promise<Contract> {
|
|
45
|
+
return this.client.post<Contract>(`${this.basePath}/${id}/renew`, data, options);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async freezeContract(
|
|
49
|
+
id: string,
|
|
50
|
+
data: FreezeContractDto,
|
|
51
|
+
options?: RequestOptions
|
|
52
|
+
): Promise<Contract> {
|
|
53
|
+
return this.client.post<Contract>(`${this.basePath}/${id}/freeze`, data, options);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async cancelContract(id: string, data: { reason: string }, options?: RequestOptions): Promise<Contract> {
|
|
57
|
+
return this.client.put<Contract>(`${this.basePath}/${id}/cancel`, data, options);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import { DashboardStats, RecentActivity, ExpiringContract } from '../models/dashboard';
|
|
3
|
+
|
|
4
|
+
export class DashboardResource extends BaseResource {
|
|
5
|
+
/**
|
|
6
|
+
* Get dashboard statistics
|
|
7
|
+
* @returns Dashboard statistics including clients, contracts, revenue, and check-ins
|
|
8
|
+
*/
|
|
9
|
+
async getStats(): Promise<DashboardStats> {
|
|
10
|
+
return this.client.get<DashboardStats>('/dashboard/stats');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get recent activity
|
|
15
|
+
* @param limit Maximum number of activities to return (default: 10)
|
|
16
|
+
* @returns List of recent activities in the gym
|
|
17
|
+
*/
|
|
18
|
+
async getRecentActivity(limit: number = 10): Promise<RecentActivity[]> {
|
|
19
|
+
return this.client.get<RecentActivity[]>('/dashboard/recent-activity', { limit });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get expiring contracts
|
|
24
|
+
* @param limit Maximum number of contracts to return (default: 10)
|
|
25
|
+
* @returns List of contracts expiring in the next 30 days
|
|
26
|
+
*/
|
|
27
|
+
async getExpiringContracts(limit: number = 10): Promise<ExpiringContract[]> {
|
|
28
|
+
return this.client.get<ExpiringContract[]>('/dashboard/expiring-contracts', { limit });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import type { FileResponseDto } from '../models/files';
|
|
3
|
+
|
|
4
|
+
export class FilesResource extends BaseResource {
|
|
5
|
+
/**
|
|
6
|
+
* Upload a new file
|
|
7
|
+
*/
|
|
8
|
+
async upload(data: {
|
|
9
|
+
file: File;
|
|
10
|
+
description?: string;
|
|
11
|
+
metadata?: Record<string, any>;
|
|
12
|
+
}): Promise<FileResponseDto> {
|
|
13
|
+
const formData = new FormData();
|
|
14
|
+
formData.append('file', data.file);
|
|
15
|
+
|
|
16
|
+
if (data.description) {
|
|
17
|
+
formData.append('description', data.description);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (data.metadata) {
|
|
21
|
+
formData.append('metadata', JSON.stringify(data.metadata));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return await this.client.post<FileResponseDto>('/files/upload', formData, {
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'multipart/form-data',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get all files for the current user
|
|
33
|
+
*/
|
|
34
|
+
async findAll(): Promise<FileResponseDto[]> {
|
|
35
|
+
return await this.client.get<FileResponseDto[]>('/files');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get a single file by ID
|
|
40
|
+
*/
|
|
41
|
+
async findOne(id: string): Promise<FileResponseDto> {
|
|
42
|
+
return await this.client.get<FileResponseDto>(`/files/${id}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get multiple files by IDs
|
|
47
|
+
*/
|
|
48
|
+
async findByIds(ids: string[]): Promise<FileResponseDto[]> {
|
|
49
|
+
if (!ids || ids.length === 0) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The second parameter of get is the params directly
|
|
54
|
+
return await this.client.get<FileResponseDto[]>('/files/by-ids', {
|
|
55
|
+
ids: ids.join(',')
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Delete a file
|
|
61
|
+
*/
|
|
62
|
+
async delete(id: string): Promise<void> {
|
|
63
|
+
await this.client.delete(`/files/${id}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Download a file as a blob
|
|
68
|
+
*/
|
|
69
|
+
async download(id: string): Promise<Blob> {
|
|
70
|
+
const response = await this.client.get<ArrayBuffer>(`/files/${id}/download`, {
|
|
71
|
+
responseType: 'arraybuffer',
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return new Blob([response]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get the render URL for a file (for inline display)
|
|
79
|
+
* This returns the URL directly without making an API call
|
|
80
|
+
*/
|
|
81
|
+
getRenderUrl(id: string): string {
|
|
82
|
+
return `${this.client.getBaseUrl()}/files/${id}/render`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get file blob for rendering/preview
|
|
87
|
+
*/
|
|
88
|
+
async render(id: string): Promise<Blob> {
|
|
89
|
+
const response = await this.client.get<ArrayBuffer>(`/files/${id}/render`, {
|
|
90
|
+
responseType: 'arraybuffer',
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return new Blob([response]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import { Gym, CreateGymDto, UpdateGymDto, GymStats } from '../models/gyms';
|
|
3
|
+
import { RequestOptions } from '../types';
|
|
4
|
+
|
|
5
|
+
export class GymsResource extends BaseResource {
|
|
6
|
+
private basePath = 'gyms';
|
|
7
|
+
|
|
8
|
+
async createGym(
|
|
9
|
+
data: CreateGymDto,
|
|
10
|
+
options?: RequestOptions
|
|
11
|
+
): Promise<Gym> {
|
|
12
|
+
return this.client.post<Gym>(
|
|
13
|
+
this.basePath,
|
|
14
|
+
data,
|
|
15
|
+
options
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getOrganizationGyms(
|
|
20
|
+
options?: RequestOptions
|
|
21
|
+
): Promise<Gym[]> {
|
|
22
|
+
return this.client.get<Gym[]>(
|
|
23
|
+
this.basePath,
|
|
24
|
+
undefined,
|
|
25
|
+
options
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getGym(id: string, options?: RequestOptions): Promise<Gym> {
|
|
30
|
+
return this.client.get<Gym>(`${this.basePath}/${id}`, undefined, options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async updateGym(
|
|
34
|
+
id: string,
|
|
35
|
+
data: UpdateGymDto,
|
|
36
|
+
options?: RequestOptions
|
|
37
|
+
): Promise<Gym> {
|
|
38
|
+
return this.client.put<Gym>(`${this.basePath}/${id}`, data, options);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async getGymStats(id: string, options?: RequestOptions): Promise<GymStats> {
|
|
42
|
+
return this.client.get<GymStats>(`${this.basePath}/${id}/stats`, undefined, options);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async toggleGymStatus(id: string, options?: RequestOptions): Promise<Gym> {
|
|
46
|
+
return this.client.put<Gym>(`${this.basePath}/${id}/toggle-status`, undefined, options);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async updateCurrentGym(
|
|
50
|
+
data: Partial<{
|
|
51
|
+
name?: string;
|
|
52
|
+
address?: string;
|
|
53
|
+
phone?: string;
|
|
54
|
+
email?: string;
|
|
55
|
+
assetId?: string;
|
|
56
|
+
}>,
|
|
57
|
+
options?: RequestOptions
|
|
58
|
+
): Promise<Gym> {
|
|
59
|
+
return this.client.put<Gym>(`${this.basePath}/current`, data, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import { RequestOptions } from '../types';
|
|
3
|
+
|
|
4
|
+
export interface HealthResponse {
|
|
5
|
+
status: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ReadyResponse {
|
|
10
|
+
status: string;
|
|
11
|
+
services: {
|
|
12
|
+
database: boolean;
|
|
13
|
+
cache: boolean;
|
|
14
|
+
storage: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class HealthResource extends BaseResource {
|
|
19
|
+
private basePath = 'health';
|
|
20
|
+
|
|
21
|
+
async health(options?: RequestOptions): Promise<HealthResponse> {
|
|
22
|
+
return this.client.get<HealthResponse>(this.basePath, undefined, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async ready(options?: RequestOptions): Promise<ReadyResponse> {
|
|
26
|
+
return this.client.get<ReadyResponse>(`${this.basePath}/ready`, undefined, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './auth';
|
|
2
|
+
export * from './organizations';
|
|
3
|
+
export * from './gyms';
|
|
4
|
+
export * from './clients';
|
|
5
|
+
export * from './membership-plans';
|
|
6
|
+
export * from './contracts';
|
|
7
|
+
export * from './dashboard';
|
|
8
|
+
export * from './evaluations';
|
|
9
|
+
export * from './check-ins';
|
|
10
|
+
export * from './invitations';
|
|
11
|
+
export * from './leads';
|
|
12
|
+
export * from './assets';
|
|
13
|
+
export * from './files';
|
|
14
|
+
export * from './public-catalog';
|
|
15
|
+
export * from './health';
|
|
16
|
+
export * from './onboarding';
|
|
17
|
+
export * from './products';
|
|
18
|
+
export * from './sales';
|
|
19
|
+
export * from './suppliers';
|
|
20
|
+
export * from './users';
|