@gymspace/sdk 1.2.4 → 1.2.8
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/.tsbuildinfo +1 -0
- package/dist/index.d.mts +289 -42
- package/dist/index.d.ts +289 -42
- package/dist/index.js +363 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +352 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/models/auth.ts +18 -2
- package/src/models/clients.ts +1 -13
- package/src/models/collaborators.ts +2 -0
- package/src/models/index.ts +5 -2
- package/src/models/invitations.ts +2 -29
- package/src/models/payment-methods.ts +15 -2
- package/src/models/roles.ts +5 -0
- package/src/models/whatsapp.ts +142 -0
- package/src/resources/clients.ts +27 -28
- package/src/resources/collaborators.ts +68 -0
- package/src/resources/contracts.ts +27 -19
- package/src/resources/index.ts +5 -1
- package/src/resources/invitations.ts +21 -17
- package/src/resources/roles.ts +29 -0
- package/src/resources/sales.ts +28 -25
- package/src/resources/whatsapp-templates.ts +80 -0
- package/src/resources/whatsapp.ts +97 -0
- package/src/sdk.ts +34 -3
- package/src/types.ts +2 -2
- package/src/utils/agent-fetch.ts +25 -0
package/package.json
CHANGED
package/src/models/auth.ts
CHANGED
|
@@ -20,8 +20,15 @@ export interface LoginDto {
|
|
|
20
20
|
export interface LoginResponseDto {
|
|
21
21
|
access_token: string;
|
|
22
22
|
refresh_token: string;
|
|
23
|
-
user:
|
|
24
|
-
|
|
23
|
+
user: {
|
|
24
|
+
id: string;
|
|
25
|
+
email: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
userType: string;
|
|
28
|
+
};
|
|
29
|
+
lastActiveGymId?: string;
|
|
30
|
+
lastActiveOrganizationId?: string;
|
|
31
|
+
redirectPath?: string;
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
export interface VerifyEmailDto {
|
|
@@ -104,6 +111,14 @@ export interface InvitationValidationResponse {
|
|
|
104
111
|
};
|
|
105
112
|
}
|
|
106
113
|
|
|
114
|
+
export interface CollaboratorRoleDto {
|
|
115
|
+
collaboratorId: string;
|
|
116
|
+
roleId: string;
|
|
117
|
+
roleName: string;
|
|
118
|
+
gymId: string;
|
|
119
|
+
gymName: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
107
122
|
export interface CurrentSessionResponse {
|
|
108
123
|
accessToken: string;
|
|
109
124
|
refreshToken?: string;
|
|
@@ -161,5 +176,6 @@ export interface CurrentSessionResponse {
|
|
|
161
176
|
isActive: boolean;
|
|
162
177
|
};
|
|
163
178
|
permissions: string[];
|
|
179
|
+
collaborator?: CollaboratorRoleDto;
|
|
164
180
|
isAuthenticated: boolean;
|
|
165
181
|
}
|
package/src/models/clients.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { PaginationQueryDto } from '../types';
|
|
2
|
-
|
|
3
1
|
export interface CreateClientDto {
|
|
4
2
|
name: string;
|
|
5
3
|
email?: string;
|
|
@@ -124,7 +122,7 @@ export interface ClientStats {
|
|
|
124
122
|
}>;
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
export interface SearchClientsParams
|
|
125
|
+
export interface SearchClientsParams {
|
|
128
126
|
search?: string;
|
|
129
127
|
activeOnly?: boolean;
|
|
130
128
|
clientNumber?: string;
|
|
@@ -133,13 +131,3 @@ export interface SearchClientsParams extends PaginationQueryDto {
|
|
|
133
131
|
notCheckedInToday?: boolean;
|
|
134
132
|
checkedInToday?: boolean;
|
|
135
133
|
}
|
|
136
|
-
|
|
137
|
-
export interface ClientSearchForCheckInResponse {
|
|
138
|
-
data: Client[];
|
|
139
|
-
pagination: {
|
|
140
|
-
total: number;
|
|
141
|
-
page: number;
|
|
142
|
-
limit: number;
|
|
143
|
-
totalPages: number;
|
|
144
|
-
};
|
|
145
|
-
}
|
package/src/models/index.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
export * from './auth';
|
|
3
3
|
export * from './organizations';
|
|
4
4
|
export * from './gyms';
|
|
5
|
+
// collaborators types are in @gymspace/shared
|
|
5
6
|
export * from './clients';
|
|
6
7
|
export * from './membership-plans';
|
|
7
8
|
export * from './contracts';
|
|
8
9
|
export * from './dashboard';
|
|
9
10
|
export * from './evaluations';
|
|
10
11
|
export * from './check-ins';
|
|
11
|
-
|
|
12
|
+
// invitations types are in @gymspace/shared
|
|
12
13
|
export * from './leads';
|
|
13
14
|
export * from './assets';
|
|
14
15
|
export * from './files';
|
|
@@ -21,8 +22,10 @@ export * from './subscriptions';
|
|
|
21
22
|
export * from './subscription-plans';
|
|
22
23
|
export * from './admin-subscription-management';
|
|
23
24
|
export * from './payment-methods';
|
|
25
|
+
export * from './roles';
|
|
26
|
+
export * from './whatsapp';
|
|
24
27
|
|
|
25
28
|
export interface ApiResponse<T> {
|
|
26
29
|
data: T;
|
|
27
30
|
meta?: any;
|
|
28
|
-
}
|
|
31
|
+
}
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
gymId: string;
|
|
4
|
-
roleId: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface AcceptInvitationDto {
|
|
8
|
-
name: string;
|
|
9
|
-
phone: string;
|
|
10
|
-
password: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Invitation {
|
|
14
|
-
id: string;
|
|
15
|
-
email: string;
|
|
16
|
-
gymId: string;
|
|
17
|
-
roleId: string;
|
|
18
|
-
token: string;
|
|
19
|
-
status: 'pending' | 'accepted' | 'cancelled' | 'expired';
|
|
20
|
-
invitedById: string;
|
|
21
|
-
acceptedAt?: string;
|
|
22
|
-
expiresAt: string;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
updatedAt: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface GetGymInvitationsParams {
|
|
28
|
-
gymId: string;
|
|
29
|
-
}
|
|
1
|
+
// All types are exported from @gymspace/shared via types.ts
|
|
2
|
+
// No need to duplicate them here
|
|
@@ -18,14 +18,27 @@ export interface UpdatePaymentMethodDto {
|
|
|
18
18
|
|
|
19
19
|
export interface PaymentMethod {
|
|
20
20
|
id: string;
|
|
21
|
-
|
|
21
|
+
organizationId: string;
|
|
22
22
|
name: string;
|
|
23
23
|
description?: string;
|
|
24
24
|
code: string;
|
|
25
25
|
enabled: boolean;
|
|
26
26
|
metadata?: Record<string, any>;
|
|
27
|
+
createdByUserId: string;
|
|
28
|
+
updatedByUserId?: string | null;
|
|
27
29
|
createdAt: string;
|
|
28
30
|
updatedAt: string;
|
|
31
|
+
deletedAt?: string | null;
|
|
32
|
+
createdBy?: {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
email: string;
|
|
36
|
+
};
|
|
37
|
+
updatedBy?: {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
email: string;
|
|
41
|
+
} | null;
|
|
29
42
|
}
|
|
30
43
|
|
|
31
44
|
export interface SearchPaymentMethodsParams extends PaginationQueryDto {
|
|
@@ -38,4 +51,4 @@ export interface PaymentMethodStats {
|
|
|
38
51
|
totalPaymentMethods: number;
|
|
39
52
|
enabledPaymentMethods: number;
|
|
40
53
|
disabledPaymentMethods: number;
|
|
41
|
-
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { PaginationQueryDto } from '../types';
|
|
2
|
+
|
|
3
|
+
// Import types for WhatsApp templates
|
|
4
|
+
// Note: TemplateCode and TemplateType are re-exported from @gymspace/shared via ../types
|
|
5
|
+
// They should be imported directly from the SDK index when needed
|
|
6
|
+
type TemplateCode = string;
|
|
7
|
+
type TemplateType = string;
|
|
8
|
+
|
|
9
|
+
// WhatsApp Config interfaces
|
|
10
|
+
export interface WhatsAppConfig {
|
|
11
|
+
id: string;
|
|
12
|
+
gymId: string;
|
|
13
|
+
instanceName: string;
|
|
14
|
+
phoneNumber?: string;
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
connectionStatus: string;
|
|
17
|
+
lastConnectedAt?: string;
|
|
18
|
+
settings?: Record<string, any>;
|
|
19
|
+
createdByUserId: string;
|
|
20
|
+
updatedByUserId?: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface CreateWhatsAppConfigDto {
|
|
26
|
+
settings?: Record<string, any>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface UpdateWhatsAppConfigDto {
|
|
30
|
+
settings?: Record<string, any>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ConnectionStatusResponse {
|
|
34
|
+
status: 'connected' | 'waiting_qr_scan' | 'connecting' | 'not_initialized' | 'disconnected';
|
|
35
|
+
qrCode?: string;
|
|
36
|
+
isActive?: boolean;
|
|
37
|
+
connectionStatus?: string;
|
|
38
|
+
lastConnectedAt?: string;
|
|
39
|
+
message?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface InitializeConnectionResponse {
|
|
43
|
+
status: 'connected' | 'waiting_qr_scan' | 'connecting' | 'not_initialized' | 'disconnected';
|
|
44
|
+
qrCode?: string;
|
|
45
|
+
isActive?: boolean;
|
|
46
|
+
connectionStatus?: string;
|
|
47
|
+
lastConnectedAt?: string;
|
|
48
|
+
message?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// WhatsApp Template interfaces
|
|
52
|
+
export interface WhatsAppTemplate {
|
|
53
|
+
id: string;
|
|
54
|
+
gymId: string;
|
|
55
|
+
code: TemplateCode;
|
|
56
|
+
name: string;
|
|
57
|
+
type: TemplateType;
|
|
58
|
+
message: string;
|
|
59
|
+
variables: string[];
|
|
60
|
+
isActive: boolean;
|
|
61
|
+
metadata?: Record<string, any>;
|
|
62
|
+
createdByUserId: string;
|
|
63
|
+
updatedByUserId?: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface CreateTemplateDto {
|
|
69
|
+
code: TemplateCode;
|
|
70
|
+
name: string;
|
|
71
|
+
type: TemplateType;
|
|
72
|
+
message: string;
|
|
73
|
+
variables?: string[];
|
|
74
|
+
isActive?: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface UpdateTemplateDto {
|
|
78
|
+
name?: string;
|
|
79
|
+
type?: TemplateType;
|
|
80
|
+
message?: string;
|
|
81
|
+
variables?: string[];
|
|
82
|
+
isActive?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface SearchTemplatesDto extends PaginationQueryDto {
|
|
86
|
+
code?: TemplateCode;
|
|
87
|
+
type?: TemplateType;
|
|
88
|
+
isActive?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface PreviewTemplateResponse {
|
|
92
|
+
content: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// WhatsApp Message interfaces
|
|
96
|
+
export interface WhatsAppMessage {
|
|
97
|
+
id: string;
|
|
98
|
+
gymId: string;
|
|
99
|
+
clientId?: string;
|
|
100
|
+
templateId?: string;
|
|
101
|
+
phoneNumber: string;
|
|
102
|
+
content: string;
|
|
103
|
+
direction: 'incoming' | 'outgoing';
|
|
104
|
+
status: 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
|
|
105
|
+
externalMessageId?: string;
|
|
106
|
+
metadata?: Record<string, any>;
|
|
107
|
+
sentAt?: string;
|
|
108
|
+
deliveredAt?: string;
|
|
109
|
+
readAt?: string;
|
|
110
|
+
failedAt?: string;
|
|
111
|
+
failureReason?: string;
|
|
112
|
+
createdAt: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface SendWhatsAppMessageDto {
|
|
116
|
+
clientId?: string;
|
|
117
|
+
phoneNumber: string;
|
|
118
|
+
content?: string;
|
|
119
|
+
templateId?: string;
|
|
120
|
+
variables?: Record<string, any>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface SearchWhatsAppMessagesDto extends PaginationQueryDto {
|
|
124
|
+
clientId?: string;
|
|
125
|
+
status?: string;
|
|
126
|
+
direction?: string;
|
|
127
|
+
phoneNumber?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface Contact {
|
|
131
|
+
id: string;
|
|
132
|
+
name: string;
|
|
133
|
+
pushname: string;
|
|
134
|
+
phoneNumber?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type ListContactsResponse = Contact[];
|
|
138
|
+
|
|
139
|
+
export interface DisconnectResponse {
|
|
140
|
+
success: boolean;
|
|
141
|
+
message: string;
|
|
142
|
+
}
|
package/src/resources/clients.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
3
|
-
Client,
|
|
4
|
-
CreateClientDto,
|
|
5
|
-
UpdateClientDto,
|
|
2
|
+
import {
|
|
3
|
+
Client,
|
|
4
|
+
CreateClientDto,
|
|
5
|
+
UpdateClientDto,
|
|
6
6
|
ClientStats,
|
|
7
7
|
ClientStat,
|
|
8
8
|
SearchClientsParams,
|
|
9
|
-
ClientSearchForCheckInResponse
|
|
10
9
|
} from '../models/clients';
|
|
11
|
-
import { RequestOptions
|
|
10
|
+
import { RequestOptions } from '../types';
|
|
12
11
|
|
|
13
12
|
export class ClientsResource extends BaseResource {
|
|
14
13
|
private basePath = 'clients';
|
|
@@ -17,23 +16,15 @@ export class ClientsResource extends BaseResource {
|
|
|
17
16
|
return this.client.post<Client>(this.basePath, data, options);
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
async searchClients(
|
|
21
|
-
params
|
|
22
|
-
options?: RequestOptions
|
|
23
|
-
): Promise<PaginatedResponseDto<Client>> {
|
|
24
|
-
|
|
25
|
-
return this.paginate<Client>(this.basePath, params, options);
|
|
19
|
+
async searchClients(params?: SearchClientsParams, options?: RequestOptions): Promise<Client[]> {
|
|
20
|
+
return this.client.get<Client[]>(this.basePath, params, options);
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
async getClient(id: string, options?: RequestOptions): Promise<Client> {
|
|
29
24
|
return this.client.get<Client>(`${this.basePath}/${id}`, undefined, options);
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
async updateClient(
|
|
33
|
-
id: string,
|
|
34
|
-
data: UpdateClientDto,
|
|
35
|
-
options?: RequestOptions
|
|
36
|
-
): Promise<Client> {
|
|
27
|
+
async updateClient(id: string, data: UpdateClientDto, options?: RequestOptions): Promise<Client> {
|
|
37
28
|
return this.client.put<Client>(`${this.basePath}/${id}`, data, options);
|
|
38
29
|
}
|
|
39
30
|
|
|
@@ -46,11 +37,23 @@ export class ClientsResource extends BaseResource {
|
|
|
46
37
|
}
|
|
47
38
|
|
|
48
39
|
async getClientStat(id: string, statKey: string, options?: RequestOptions): Promise<ClientStat> {
|
|
49
|
-
return this.client.get<ClientStat>(
|
|
40
|
+
return this.client.get<ClientStat>(
|
|
41
|
+
`${this.basePath}/${id}/stats/${statKey}`,
|
|
42
|
+
undefined,
|
|
43
|
+
options,
|
|
44
|
+
);
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
async getClientStatsByCategory(
|
|
53
|
-
|
|
47
|
+
async getClientStatsByCategory(
|
|
48
|
+
id: string,
|
|
49
|
+
category: string,
|
|
50
|
+
options?: RequestOptions,
|
|
51
|
+
): Promise<ClientStat[]> {
|
|
52
|
+
return this.client.get<ClientStat[]>(
|
|
53
|
+
`${this.basePath}/${id}/stats/category/${category}`,
|
|
54
|
+
undefined,
|
|
55
|
+
options,
|
|
56
|
+
);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
async getAvailableStats(options?: RequestOptions): Promise<ClientStat[]> {
|
|
@@ -59,13 +62,9 @@ export class ClientsResource extends BaseResource {
|
|
|
59
62
|
|
|
60
63
|
async searchClientsForCheckIn(
|
|
61
64
|
params?: SearchClientsParams,
|
|
62
|
-
options?: RequestOptions
|
|
63
|
-
): Promise<
|
|
65
|
+
options?: RequestOptions,
|
|
66
|
+
): Promise<Client[]> {
|
|
64
67
|
// This endpoint automatically includes contract status and only active clients
|
|
65
|
-
return this.client.get<
|
|
66
|
-
`${this.basePath}/search/check-in`,
|
|
67
|
-
params,
|
|
68
|
-
options
|
|
69
|
-
);
|
|
68
|
+
return this.client.get<Client[]>(`${this.basePath}/search/check-in`, params, options);
|
|
70
69
|
}
|
|
71
|
-
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import type {
|
|
3
|
+
Collaborator,
|
|
4
|
+
ListCollaboratorsParams,
|
|
5
|
+
UpdateCollaboratorDto,
|
|
6
|
+
UpdateCollaboratorStatusDto,
|
|
7
|
+
UpdateCollaboratorRoleDto,
|
|
8
|
+
ActivityQueryParams,
|
|
9
|
+
StatsQueryParams,
|
|
10
|
+
CollaboratorStats,
|
|
11
|
+
ActivityItem,
|
|
12
|
+
} from '@gymspace/shared';
|
|
13
|
+
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
14
|
+
|
|
15
|
+
export class CollaboratorsResource extends BaseResource {
|
|
16
|
+
private basePath = 'collaborators';
|
|
17
|
+
|
|
18
|
+
async list(
|
|
19
|
+
params?: ListCollaboratorsParams,
|
|
20
|
+
options?: RequestOptions,
|
|
21
|
+
): Promise<PaginatedResponseDto<Collaborator>> {
|
|
22
|
+
return this.paginate<Collaborator>(this.basePath, params, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async get(id: string, options?: RequestOptions): Promise<Collaborator> {
|
|
26
|
+
return this.client.get<Collaborator>(`${this.basePath}/${id}`, undefined, options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async update(
|
|
30
|
+
id: string,
|
|
31
|
+
data: UpdateCollaboratorDto,
|
|
32
|
+
options?: RequestOptions,
|
|
33
|
+
): Promise<Collaborator> {
|
|
34
|
+
return this.client.patch<Collaborator>(`${this.basePath}/${id}`, data, options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async updateRole(
|
|
38
|
+
id: string,
|
|
39
|
+
data: UpdateCollaboratorRoleDto,
|
|
40
|
+
options?: RequestOptions,
|
|
41
|
+
): Promise<Collaborator> {
|
|
42
|
+
return this.client.patch<Collaborator>(`${this.basePath}/${id}/role`, data, options);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async updateStatus(
|
|
46
|
+
id: string,
|
|
47
|
+
data: UpdateCollaboratorStatusDto,
|
|
48
|
+
options?: RequestOptions,
|
|
49
|
+
): Promise<Collaborator> {
|
|
50
|
+
return this.client.patch<Collaborator>(`${this.basePath}/${id}/status`, data, options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async getActivity(
|
|
54
|
+
id: string,
|
|
55
|
+
params?: ActivityQueryParams,
|
|
56
|
+
options?: RequestOptions,
|
|
57
|
+
): Promise<ActivityItem[]> {
|
|
58
|
+
return this.client.get<ActivityItem[]>(`${this.basePath}/${id}/activity`, params, options);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getStats(
|
|
62
|
+
id: string,
|
|
63
|
+
params?: StatsQueryParams,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): Promise<CollaboratorStats> {
|
|
66
|
+
return this.client.get<CollaboratorStats>(`${this.basePath}/${id}/stats`, params, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
3
|
-
Contract,
|
|
4
|
-
CreateContractDto,
|
|
5
|
-
RenewContractDto,
|
|
2
|
+
import {
|
|
3
|
+
Contract,
|
|
4
|
+
CreateContractDto,
|
|
5
|
+
RenewContractDto,
|
|
6
6
|
FreezeContractDto,
|
|
7
|
-
GetContractsParams
|
|
7
|
+
GetContractsParams,
|
|
8
8
|
} from '../models/contracts';
|
|
9
9
|
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
10
10
|
|
|
@@ -17,7 +17,7 @@ export class ContractsResource extends BaseResource {
|
|
|
17
17
|
|
|
18
18
|
async getGymContracts(
|
|
19
19
|
params?: GetContractsParams,
|
|
20
|
-
options?: RequestOptions
|
|
20
|
+
options?: RequestOptions,
|
|
21
21
|
): Promise<PaginatedResponseDto<Contract>> {
|
|
22
22
|
return this.paginate<Contract>(this.basePath, params, options);
|
|
23
23
|
}
|
|
@@ -26,21 +26,14 @@ export class ContractsResource extends BaseResource {
|
|
|
26
26
|
return this.client.get<Contract>(`${this.basePath}/${id}`, undefined, options);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
async getClientContracts(
|
|
30
|
-
clientId
|
|
31
|
-
options?: RequestOptions
|
|
32
|
-
): Promise<Contract[]> {
|
|
33
|
-
return this.client.get<Contract[]>(
|
|
34
|
-
`${this.basePath}/client/${clientId}`,
|
|
35
|
-
undefined,
|
|
36
|
-
options
|
|
37
|
-
);
|
|
29
|
+
async getClientContracts(clientId: string, options?: RequestOptions): Promise<Contract[]> {
|
|
30
|
+
return this.client.get<Contract[]>(`${this.basePath}/client/${clientId}`, undefined, options);
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
async renewContract(
|
|
41
34
|
id: string,
|
|
42
35
|
data: RenewContractDto,
|
|
43
|
-
options?: RequestOptions
|
|
36
|
+
options?: RequestOptions,
|
|
44
37
|
): Promise<Contract> {
|
|
45
38
|
return this.client.post<Contract>(`${this.basePath}/${id}/renew`, data, options);
|
|
46
39
|
}
|
|
@@ -48,12 +41,27 @@ export class ContractsResource extends BaseResource {
|
|
|
48
41
|
async freezeContract(
|
|
49
42
|
id: string,
|
|
50
43
|
data: FreezeContractDto,
|
|
51
|
-
options?: RequestOptions
|
|
44
|
+
options?: RequestOptions,
|
|
52
45
|
): Promise<Contract> {
|
|
53
46
|
return this.client.post<Contract>(`${this.basePath}/${id}/freeze`, data, options);
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
async cancelContract(
|
|
49
|
+
async cancelContract(
|
|
50
|
+
id: string,
|
|
51
|
+
data: { reason: string },
|
|
52
|
+
options?: RequestOptions,
|
|
53
|
+
): Promise<Contract> {
|
|
57
54
|
return this.client.put<Contract>(`${this.basePath}/${id}/cancel`, data, options);
|
|
58
55
|
}
|
|
59
|
-
|
|
56
|
+
|
|
57
|
+
async resendWhatsAppNotification(
|
|
58
|
+
contractId: string,
|
|
59
|
+
options?: RequestOptions,
|
|
60
|
+
): Promise<{ success: boolean; message: string }> {
|
|
61
|
+
return this.client.post<{ success: boolean; message: string }>(
|
|
62
|
+
`${this.basePath}/${contractId}/resend-whatsapp`,
|
|
63
|
+
{},
|
|
64
|
+
options,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/resources/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './auth';
|
|
2
2
|
export * from './organizations';
|
|
3
3
|
export * from './gyms';
|
|
4
|
+
export * from './collaborators';
|
|
5
|
+
export * from './roles';
|
|
4
6
|
export * from './clients';
|
|
5
7
|
export * from './membership-plans';
|
|
6
8
|
export * from './contracts';
|
|
@@ -21,4 +23,6 @@ export * from './users';
|
|
|
21
23
|
export * from './subscriptions';
|
|
22
24
|
export * from './subscription-plans';
|
|
23
25
|
export * from './admin-subscription-management';
|
|
24
|
-
export * from './payment-methods';
|
|
26
|
+
export * from './payment-methods';
|
|
27
|
+
export * from './whatsapp';
|
|
28
|
+
export * from './whatsapp-templates';
|
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
3
|
-
Invitation,
|
|
4
|
-
CreateInvitationDto,
|
|
2
|
+
import type {
|
|
3
|
+
Invitation,
|
|
4
|
+
CreateInvitationDto,
|
|
5
5
|
AcceptInvitationDto,
|
|
6
|
-
|
|
7
|
-
} from '
|
|
6
|
+
ValidateByCodeDto,
|
|
7
|
+
} from '@gymspace/shared';
|
|
8
8
|
import { RequestOptions } from '../types';
|
|
9
9
|
|
|
10
|
+
export interface GetGymInvitationsParams {
|
|
11
|
+
gymId: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export class InvitationsResource extends BaseResource {
|
|
11
15
|
private basePath = 'invitations';
|
|
12
16
|
|
|
13
|
-
async createInvitation(
|
|
14
|
-
data: CreateInvitationDto,
|
|
15
|
-
options?: RequestOptions
|
|
16
|
-
): Promise<Invitation> {
|
|
17
|
+
async createInvitation(data: CreateInvitationDto, options?: RequestOptions): Promise<Invitation> {
|
|
17
18
|
return this.client.post<Invitation>(this.basePath, data, options);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
async getGymInvitations(
|
|
21
22
|
params: GetGymInvitationsParams,
|
|
22
|
-
options?: RequestOptions
|
|
23
|
+
options?: RequestOptions,
|
|
23
24
|
): Promise<Invitation[]> {
|
|
24
25
|
return this.client.get<Invitation[]>(this.basePath, params, options);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
async
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
async validateByCode(
|
|
29
|
+
data: ValidateByCodeDto,
|
|
30
|
+
options?: RequestOptions,
|
|
31
|
+
): Promise<{ email: string; gymName: string; roleName: string; token: string }> {
|
|
32
|
+
return this.client.post(`${this.basePath}/validate-by-code`, data, options);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async acceptInvitation(data: AcceptInvitationDto, options?: RequestOptions): Promise<void> {
|
|
36
|
+
return this.client.post<void>(`${this.basePath}/accept`, data, options);
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
async cancelInvitation(id: string, options?: RequestOptions): Promise<void> {
|
|
36
40
|
return this.client.put<void>(`${this.basePath}/${id}/cancel`, undefined, options);
|
|
37
41
|
}
|
|
38
|
-
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import type { Role } from '@gymspace/shared';
|
|
3
|
+
import type { PermissionsGroup } from '../models/roles';
|
|
4
|
+
import { RequestOptions } from '../types';
|
|
5
|
+
|
|
6
|
+
export class RolesResource extends BaseResource {
|
|
7
|
+
private basePath = 'roles';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get all roles of the organization (without pagination)
|
|
11
|
+
*/
|
|
12
|
+
async getRoles(options?: RequestOptions): Promise<Role[]> {
|
|
13
|
+
return this.client.get<Role[]>(this.basePath, undefined, options);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get a specific role by ID
|
|
18
|
+
*/
|
|
19
|
+
async getRole(id: string, options?: RequestOptions): Promise<Role> {
|
|
20
|
+
return this.client.get<Role>(`${this.basePath}/${id}`, undefined, options);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get all available permissions organized by category
|
|
25
|
+
*/
|
|
26
|
+
async getAvailablePermissions(options?: RequestOptions): Promise<PermissionsGroup> {
|
|
27
|
+
return this.client.get<PermissionsGroup>(`${this.basePath}/permissions`, undefined, options);
|
|
28
|
+
}
|
|
29
|
+
}
|