@gymspace/sdk 1.2.13 → 1.2.15
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 -1
- package/dist/index.d.mts +515 -18
- package/dist/index.d.ts +515 -18
- package/dist/index.js +239 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +236 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/models/activities.ts +139 -0
- package/src/models/clients.ts +6 -0
- package/src/models/contracts.ts +127 -9
- package/src/models/gyms.ts +7 -6
- package/src/models/index.ts +2 -0
- package/src/models/tags.ts +151 -0
- package/src/resources/activities.ts +113 -0
- package/src/resources/check-ins.ts +42 -10
- package/src/resources/contracts.ts +53 -1
- package/src/resources/index.ts +2 -0
- package/src/resources/tags.ts +147 -0
- package/src/sdk.ts +6 -0
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
3
|
-
CheckIn,
|
|
4
|
-
CreateCheckInDto,
|
|
2
|
+
import {
|
|
3
|
+
CheckIn,
|
|
4
|
+
CreateCheckInDto,
|
|
5
5
|
SearchCheckInsParams,
|
|
6
6
|
GetCheckInStatsParams,
|
|
7
7
|
CheckInStats,
|
|
8
8
|
GetClientCheckInHistoryParams,
|
|
9
9
|
CurrentlyInGymResponse,
|
|
10
10
|
CheckInListResponse,
|
|
11
|
-
ClientCheckInHistory
|
|
11
|
+
ClientCheckInHistory,
|
|
12
12
|
} from '../models/check-ins';
|
|
13
13
|
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
14
14
|
|
|
15
15
|
export class CheckInsResource extends BaseResource {
|
|
16
16
|
private basePath = 'check-ins';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new check-in for a client.
|
|
20
|
+
*
|
|
21
|
+
* **Permissions Required:**
|
|
22
|
+
* - Gym owners with full gym access
|
|
23
|
+
* - Active collaborators with CHECKINS_CREATE permission
|
|
24
|
+
*
|
|
25
|
+
* @param data - The check-in data including client ID and optional notes
|
|
26
|
+
* @param options - Optional request configuration
|
|
27
|
+
* @returns The created check-in record with client and user details
|
|
28
|
+
* @throws {ValidationError} When client is not found or already checked in
|
|
29
|
+
* @throws {AuthorizationError} When user lacks required permissions
|
|
30
|
+
*/
|
|
18
31
|
async createCheckIn(data: CreateCheckInDto, options?: RequestOptions): Promise<CheckIn> {
|
|
19
32
|
return this.client.post<CheckIn>(this.basePath, data, options);
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
async searchCheckIns(
|
|
23
36
|
params?: SearchCheckInsParams,
|
|
24
|
-
options?: RequestOptions
|
|
37
|
+
options?: RequestOptions,
|
|
25
38
|
): Promise<CheckInListResponse> {
|
|
26
39
|
return this.client.get<CheckInListResponse>(this.basePath, params, options);
|
|
27
40
|
}
|
|
@@ -34,30 +47,49 @@ export class CheckInsResource extends BaseResource {
|
|
|
34
47
|
return this.client.get<CheckIn>(`${this.basePath}/${id}`, undefined, options);
|
|
35
48
|
}
|
|
36
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Deletes a check-in record.
|
|
52
|
+
*
|
|
53
|
+
* **Permissions Required:**
|
|
54
|
+
* - Gym owners with full gym access
|
|
55
|
+
* - Active collaborators with CHECKINS_CREATE permission
|
|
56
|
+
*
|
|
57
|
+
* **Business Rules:**
|
|
58
|
+
* - Only check-ins from today can be deleted
|
|
59
|
+
* - The same permission level required for creation is required for deletion
|
|
60
|
+
* - Cannot delete check-ins from previous days
|
|
61
|
+
*
|
|
62
|
+
* @param id - The ID of the check-in to delete
|
|
63
|
+
* @param options - Optional request configuration
|
|
64
|
+
* @returns Promise that resolves when the check-in is successfully deleted
|
|
65
|
+
* @throws {NotFoundError} When the check-in is not found
|
|
66
|
+
* @throws {AuthorizationError} When user lacks required permissions
|
|
67
|
+
* @throws {ValidationError} When trying to delete a check-in from a previous day
|
|
68
|
+
*/
|
|
37
69
|
async deleteCheckIn(id: string, options?: RequestOptions): Promise<void> {
|
|
38
70
|
return this.client.delete<void>(`${this.basePath}/${id}`, options);
|
|
39
71
|
}
|
|
40
72
|
|
|
41
73
|
async getGymCheckInStats(
|
|
42
74
|
params: GetCheckInStatsParams,
|
|
43
|
-
options?: RequestOptions
|
|
75
|
+
options?: RequestOptions,
|
|
44
76
|
): Promise<CheckInStats> {
|
|
45
77
|
return this.client.get<CheckInStats>(
|
|
46
78
|
`${this.basePath}/stats/${params.period}`,
|
|
47
79
|
undefined,
|
|
48
|
-
options
|
|
80
|
+
options,
|
|
49
81
|
);
|
|
50
82
|
}
|
|
51
83
|
|
|
52
84
|
async getClientCheckInHistory(
|
|
53
85
|
clientId: string,
|
|
54
86
|
params?: GetClientCheckInHistoryParams,
|
|
55
|
-
options?: RequestOptions
|
|
87
|
+
options?: RequestOptions,
|
|
56
88
|
): Promise<ClientCheckInHistory> {
|
|
57
89
|
return this.client.get<ClientCheckInHistory>(
|
|
58
90
|
`${this.basePath}/client/${clientId}/history`,
|
|
59
91
|
params,
|
|
60
|
-
options
|
|
92
|
+
options,
|
|
61
93
|
);
|
|
62
94
|
}
|
|
63
|
-
}
|
|
95
|
+
}
|
|
@@ -4,7 +4,13 @@ import {
|
|
|
4
4
|
CreateContractDto,
|
|
5
5
|
RenewContractDto,
|
|
6
6
|
FreezeContractDto,
|
|
7
|
+
CancelContractDto,
|
|
8
|
+
SuspendContractDto,
|
|
9
|
+
ResumeContractDto,
|
|
10
|
+
ReactivateContractDto,
|
|
7
11
|
GetContractsParams,
|
|
12
|
+
ContractLifecycleEvent,
|
|
13
|
+
CancellationAnalytics,
|
|
8
14
|
} from '../models/contracts';
|
|
9
15
|
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
10
16
|
|
|
@@ -48,12 +54,58 @@ export class ContractsResource extends BaseResource {
|
|
|
48
54
|
|
|
49
55
|
async cancelContract(
|
|
50
56
|
id: string,
|
|
51
|
-
data:
|
|
57
|
+
data: CancelContractDto,
|
|
52
58
|
options?: RequestOptions,
|
|
53
59
|
): Promise<Contract> {
|
|
54
60
|
return this.client.put<Contract>(`${this.basePath}/${id}/cancel`, data, options);
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
async suspendContract(
|
|
64
|
+
id: string,
|
|
65
|
+
data: SuspendContractDto,
|
|
66
|
+
options?: RequestOptions,
|
|
67
|
+
): Promise<Contract> {
|
|
68
|
+
return this.client.post<Contract>(`${this.basePath}/${id}/suspend`, data, options);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async resumeContract(
|
|
72
|
+
id: string,
|
|
73
|
+
data: ResumeContractDto,
|
|
74
|
+
options?: RequestOptions,
|
|
75
|
+
): Promise<Contract> {
|
|
76
|
+
return this.client.post<Contract>(`${this.basePath}/${id}/resume`, data, options);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async reactivateContract(
|
|
80
|
+
id: string,
|
|
81
|
+
data: ReactivateContractDto,
|
|
82
|
+
options?: RequestOptions,
|
|
83
|
+
): Promise<Contract> {
|
|
84
|
+
return this.client.post<Contract>(`${this.basePath}/${id}/reactivate`, data, options);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async getLifecycleHistory(
|
|
88
|
+
id: string,
|
|
89
|
+
options?: RequestOptions,
|
|
90
|
+
): Promise<ContractLifecycleEvent[]> {
|
|
91
|
+
return this.client.get<ContractLifecycleEvent[]>(
|
|
92
|
+
`${this.basePath}/${id}/lifecycle-history`,
|
|
93
|
+
undefined,
|
|
94
|
+
options,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async getCancellationAnalytics(
|
|
99
|
+
params?: { startDate?: string; endDate?: string },
|
|
100
|
+
options?: RequestOptions,
|
|
101
|
+
): Promise<CancellationAnalytics> {
|
|
102
|
+
return this.client.get<CancellationAnalytics>(
|
|
103
|
+
`${this.basePath}/analytics/cancellation-reasons`,
|
|
104
|
+
params,
|
|
105
|
+
options,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
57
109
|
async resendWhatsAppNotification(
|
|
58
110
|
contractId: string,
|
|
59
111
|
options?: RequestOptions,
|
package/src/resources/index.ts
CHANGED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import {
|
|
3
|
+
Tag,
|
|
4
|
+
CreateTagDto,
|
|
5
|
+
UpdateTagDto,
|
|
6
|
+
AssignTagsDto,
|
|
7
|
+
SearchTagsParams,
|
|
8
|
+
GetTagClientsParams,
|
|
9
|
+
AssignTagsResponse,
|
|
10
|
+
RemoveTagsResponse,
|
|
11
|
+
DeleteTagResponse,
|
|
12
|
+
ClientTagsResponse,
|
|
13
|
+
TagClientsResponse,
|
|
14
|
+
TagStatsResponse,
|
|
15
|
+
} from '../models/tags';
|
|
16
|
+
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
17
|
+
|
|
18
|
+
export class TagsResource extends BaseResource {
|
|
19
|
+
private basePath = 'tags';
|
|
20
|
+
|
|
21
|
+
// ==================== Tag Management ====================
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a new tag
|
|
25
|
+
* POST /api/v1/tags
|
|
26
|
+
*/
|
|
27
|
+
async createTag(data: CreateTagDto, options?: RequestOptions): Promise<Tag> {
|
|
28
|
+
return this.client.post<Tag>(this.basePath, data, options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* List all tags with optional filters and pagination
|
|
33
|
+
* GET /api/v1/tags
|
|
34
|
+
*/
|
|
35
|
+
async searchTags(
|
|
36
|
+
params?: SearchTagsParams,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): Promise<PaginatedResponseDto<Tag>> {
|
|
39
|
+
return this.client.get<PaginatedResponseDto<Tag>>(this.basePath, params, options);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get a specific tag by ID
|
|
44
|
+
* GET /api/v1/tags/:id
|
|
45
|
+
*/
|
|
46
|
+
async getTag(id: string, options?: RequestOptions): Promise<Tag> {
|
|
47
|
+
return this.client.get<Tag>(`${this.basePath}/${id}`, undefined, options);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Update an existing tag
|
|
52
|
+
* PUT /api/v1/tags/:id
|
|
53
|
+
*/
|
|
54
|
+
async updateTag(id: string, data: UpdateTagDto, options?: RequestOptions): Promise<Tag> {
|
|
55
|
+
return this.client.put<Tag>(`${this.basePath}/${id}`, data, options);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Delete a tag (soft delete)
|
|
60
|
+
* DELETE /api/v1/tags/:id
|
|
61
|
+
* @param id - Tag ID
|
|
62
|
+
* @param force - Force deletion even if tag has assigned clients
|
|
63
|
+
*/
|
|
64
|
+
async deleteTag(
|
|
65
|
+
id: string,
|
|
66
|
+
force?: boolean,
|
|
67
|
+
options?: RequestOptions,
|
|
68
|
+
): Promise<DeleteTagResponse> {
|
|
69
|
+
const path = force ? `${this.basePath}/${id}?force=true` : `${this.basePath}/${id}`;
|
|
70
|
+
return this.client.delete<DeleteTagResponse>(path, options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get clients with a specific tag
|
|
75
|
+
* GET /api/v1/tags/:id/clients
|
|
76
|
+
*/
|
|
77
|
+
async getTagClients(
|
|
78
|
+
id: string,
|
|
79
|
+
params?: GetTagClientsParams,
|
|
80
|
+
options?: RequestOptions,
|
|
81
|
+
): Promise<TagClientsResponse> {
|
|
82
|
+
return this.client.get<TagClientsResponse>(`${this.basePath}/${id}/clients`, params, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get tag statistics
|
|
87
|
+
* GET /api/v1/tags/stats
|
|
88
|
+
*/
|
|
89
|
+
async getTagStats(options?: RequestOptions): Promise<TagStatsResponse> {
|
|
90
|
+
return this.client.get<TagStatsResponse>(`${this.basePath}/stats`, undefined, options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ==================== Client Tag Assignment ====================
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Assign one or multiple tags to a client
|
|
97
|
+
* POST /api/v1/clients/:clientId/tags
|
|
98
|
+
*/
|
|
99
|
+
async assignTagsToClient(
|
|
100
|
+
clientId: string,
|
|
101
|
+
data: AssignTagsDto,
|
|
102
|
+
options?: RequestOptions,
|
|
103
|
+
): Promise<AssignTagsResponse> {
|
|
104
|
+
return this.client.post<AssignTagsResponse>(`clients/${clientId}/tags`, data, options);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Remove a specific tag from a client
|
|
109
|
+
* DELETE /api/v1/clients/:clientId/tags/:tagId
|
|
110
|
+
*/
|
|
111
|
+
async removeTagFromClient(
|
|
112
|
+
clientId: string,
|
|
113
|
+
tagId: string,
|
|
114
|
+
options?: RequestOptions,
|
|
115
|
+
): Promise<RemoveTagsResponse> {
|
|
116
|
+
return this.client.delete<RemoveTagsResponse>(`clients/${clientId}/tags/${tagId}`, options);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Remove multiple tags from a client
|
|
121
|
+
* DELETE /api/v1/clients/:clientId/tags
|
|
122
|
+
* Note: This endpoint requires sending tagIds in the request body
|
|
123
|
+
*/
|
|
124
|
+
async removeTagsFromClient(
|
|
125
|
+
clientId: string,
|
|
126
|
+
tagIds: string[],
|
|
127
|
+
options?: RequestOptions,
|
|
128
|
+
): Promise<RemoveTagsResponse> {
|
|
129
|
+
// DELETE with body requires special handling
|
|
130
|
+
return this.request<RemoveTagsResponse>(`clients/${clientId}/tags`, {
|
|
131
|
+
method: 'DELETE',
|
|
132
|
+
body: JSON.stringify({ tagIds }),
|
|
133
|
+
headers: {
|
|
134
|
+
'Content-Type': 'application/json',
|
|
135
|
+
...options?.headers,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get all tags assigned to a client
|
|
142
|
+
* GET /api/v1/clients/:clientId/tags
|
|
143
|
+
*/
|
|
144
|
+
async getClientTags(clientId: string, options?: RequestOptions): Promise<ClientTagsResponse> {
|
|
145
|
+
return this.client.get<ClientTagsResponse>(`clients/${clientId}/tags`, undefined, options);
|
|
146
|
+
}
|
|
147
|
+
}
|
package/src/sdk.ts
CHANGED
|
@@ -29,6 +29,8 @@ import {
|
|
|
29
29
|
WhatsAppResource,
|
|
30
30
|
WhatsAppTemplatesResource,
|
|
31
31
|
BulkMessagingResource,
|
|
32
|
+
ActivitiesResource,
|
|
33
|
+
TagsResource,
|
|
32
34
|
} from './resources';
|
|
33
35
|
|
|
34
36
|
export class GymSpaceSdk {
|
|
@@ -63,6 +65,8 @@ export class GymSpaceSdk {
|
|
|
63
65
|
public whatsapp: WhatsAppResource;
|
|
64
66
|
public whatsappTemplates: WhatsAppTemplatesResource;
|
|
65
67
|
public bulkMessaging: BulkMessagingResource;
|
|
68
|
+
public activities: ActivitiesResource;
|
|
69
|
+
public tags: TagsResource;
|
|
66
70
|
|
|
67
71
|
constructor(config: GymSpaceConfig) {
|
|
68
72
|
this.client = new ApiClient(config);
|
|
@@ -95,6 +99,8 @@ export class GymSpaceSdk {
|
|
|
95
99
|
this.whatsapp = new WhatsAppResource(this.client);
|
|
96
100
|
this.whatsappTemplates = new WhatsAppTemplatesResource(this.client);
|
|
97
101
|
this.bulkMessaging = new BulkMessagingResource(this.client);
|
|
102
|
+
this.activities = new ActivitiesResource(this.client);
|
|
103
|
+
this.tags = new TagsResource(this.client);
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
/**
|