@gymspace/sdk 1.5.2 → 1.6.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/dist/.tsbuildinfo +1 -1
- package/dist/index.d.mts +136 -5
- package/dist/index.d.ts +136 -5
- package/dist/index.js +53 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/models/index.ts +1 -0
- package/src/models/membership-plans.ts +63 -5
- package/src/models/messages.ts +40 -0
- package/src/resources/gyms.ts +17 -0
- package/src/resources/index.ts +1 -0
- package/src/resources/invitations.ts +11 -0
- package/src/resources/messages.ts +28 -0
- package/src/sdk.ts +3 -0
package/package.json
CHANGED
package/src/models/index.ts
CHANGED
|
@@ -60,12 +60,70 @@ export interface MembershipPlan {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export interface MembershipPlanStats {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
plan: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
basePrice: string;
|
|
67
|
+
durationMonths: number | null;
|
|
68
|
+
durationDays: number | null;
|
|
69
|
+
status: string;
|
|
70
|
+
};
|
|
71
|
+
contracts: {
|
|
72
|
+
total: number;
|
|
73
|
+
active: number;
|
|
74
|
+
cancelled: number;
|
|
75
|
+
retentionRate: string;
|
|
76
|
+
};
|
|
77
|
+
revenue: {
|
|
78
|
+
monthly: number;
|
|
79
|
+
projected: number;
|
|
80
|
+
};
|
|
81
|
+
metrics: {
|
|
82
|
+
averageRetentionDays: number;
|
|
83
|
+
};
|
|
84
|
+
recentContracts: Array<{
|
|
85
|
+
id: string;
|
|
86
|
+
gymClientId: string;
|
|
87
|
+
gymMembershipPlanId: string;
|
|
88
|
+
paymentMethodId: string;
|
|
89
|
+
parentId: string | null;
|
|
90
|
+
startDate: string;
|
|
91
|
+
endDate: string;
|
|
92
|
+
basePrice: string;
|
|
93
|
+
customPrice: string | null;
|
|
94
|
+
finalAmount: string;
|
|
95
|
+
currency: string;
|
|
96
|
+
discountPercentage: string | null;
|
|
97
|
+
discountAmount: string | null;
|
|
98
|
+
status: string;
|
|
99
|
+
paymentFrequency: string;
|
|
100
|
+
notes: string | null;
|
|
101
|
+
termsAndConditions: string | null;
|
|
102
|
+
freezeStartDate: string | null;
|
|
103
|
+
freezeEndDate: string | null;
|
|
104
|
+
contractDocumentId: string | null;
|
|
105
|
+
paymentReceiptIds: string[] | null;
|
|
106
|
+
receiptIds: string[];
|
|
107
|
+
metadata: Record<string, unknown>;
|
|
108
|
+
createdByUserId: string;
|
|
109
|
+
updatedByUserId: string | null;
|
|
110
|
+
approvedByUserId: string | null;
|
|
111
|
+
approvedAt: string | null;
|
|
112
|
+
cancelledByUserId: string | null;
|
|
113
|
+
cancelledAt: string | null;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
updatedAt: string;
|
|
116
|
+
deletedAt: string | null;
|
|
117
|
+
gymId: string | null;
|
|
118
|
+
contractNumber: string;
|
|
119
|
+
gymClient: {
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
email: string;
|
|
123
|
+
};
|
|
124
|
+
}>;
|
|
67
125
|
}
|
|
68
126
|
|
|
69
127
|
export interface GetMembershipPlansParams {
|
|
70
128
|
activeOnly?: boolean;
|
|
71
|
-
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
id: string;
|
|
3
|
+
gymId: string;
|
|
4
|
+
clientId?: string;
|
|
5
|
+
recipientPhone: string;
|
|
6
|
+
recipientName?: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
templateId?: string;
|
|
9
|
+
status: string;
|
|
10
|
+
scheduledFor?: string;
|
|
11
|
+
queuedAt?: string;
|
|
12
|
+
sentAt?: string;
|
|
13
|
+
failedAt?: string;
|
|
14
|
+
cancelledAt?: string;
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
errorCode?: string;
|
|
17
|
+
retryCount: number;
|
|
18
|
+
maxRetries: number;
|
|
19
|
+
externalMessageId?: string;
|
|
20
|
+
metadata?: Record<string, any>;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface GetMessagesParams {
|
|
26
|
+
status?: string;
|
|
27
|
+
clientId?: string;
|
|
28
|
+
startDate?: string;
|
|
29
|
+
endDate?: string;
|
|
30
|
+
search?: string;
|
|
31
|
+
page?: number;
|
|
32
|
+
limit?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MessageStatusUpdate {
|
|
36
|
+
status: string;
|
|
37
|
+
externalMessageId?: string;
|
|
38
|
+
errorMessage?: string;
|
|
39
|
+
errorCode?: string;
|
|
40
|
+
}
|
package/src/resources/gyms.ts
CHANGED
|
@@ -112,4 +112,21 @@ export class GymsResource extends BaseResource {
|
|
|
112
112
|
): Promise<Gym> {
|
|
113
113
|
return this.client.patch<Gym>(`${this.basePath}/current/contract-settings`, data, options);
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Soft delete a gym
|
|
118
|
+
* Cannot delete gym with active contracts or collaborators
|
|
119
|
+
* @param id Gym ID
|
|
120
|
+
* @param options Request options
|
|
121
|
+
* @returns Success response
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const result = await sdk.gyms.deleteGym('gym-id');
|
|
126
|
+
* console.log(result.success); // true
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
async deleteGym(id: string, options?: RequestOptions): Promise<{ success: boolean }> {
|
|
130
|
+
return this.client.delete<{ success: boolean }>(`${this.basePath}/${id}`, options);
|
|
131
|
+
}
|
|
115
132
|
}
|
package/src/resources/index.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface GetGymInvitationsParams {
|
|
|
11
11
|
gymId: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export interface ValidateByTokenDto {
|
|
15
|
+
token: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
export class InvitationsResource extends BaseResource {
|
|
15
19
|
private basePath = 'invitations';
|
|
16
20
|
|
|
@@ -32,6 +36,13 @@ export class InvitationsResource extends BaseResource {
|
|
|
32
36
|
return this.client.post(`${this.basePath}/validate-by-code`, data, options);
|
|
33
37
|
}
|
|
34
38
|
|
|
39
|
+
async validateByToken(
|
|
40
|
+
data: ValidateByTokenDto,
|
|
41
|
+
options?: RequestOptions,
|
|
42
|
+
): Promise<{ email: string; gymName: string; roleName: string; token: string }> {
|
|
43
|
+
return this.client.post(`${this.basePath}/validate-by-token`, data, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
async acceptInvitation(data: AcceptInvitationDto, options?: RequestOptions): Promise<void> {
|
|
36
47
|
return this.client.post<void>(`${this.basePath}/accept`, data, options);
|
|
37
48
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import { Message, GetMessagesParams } from '../models/messages';
|
|
3
|
+
import { RequestOptions } from '../types';
|
|
4
|
+
|
|
5
|
+
interface MessagesResponse {
|
|
6
|
+
data: Message[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class MessagesResource extends BaseResource {
|
|
10
|
+
private basePath = 'messages';
|
|
11
|
+
|
|
12
|
+
async getMessages(params?: GetMessagesParams, options?: RequestOptions): Promise<Message[]> {
|
|
13
|
+
const response = await this.client.get<MessagesResponse>(this.basePath, params, options);
|
|
14
|
+
return response.data;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async getMessage(id: string, options?: RequestOptions): Promise<Message> {
|
|
18
|
+
return this.client.get<Message>(`${this.basePath}/${id}`, undefined, options);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async retryMessage(id: string, options?: RequestOptions): Promise<Message> {
|
|
22
|
+
return this.client.post<Message>(`${this.basePath}/${id}/retry`, undefined, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async cancelMessage(id: string, options?: RequestOptions): Promise<Message> {
|
|
26
|
+
return this.client.post<Message>(`${this.basePath}/${id}/cancel`, undefined, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/sdk.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
CommissionCalculationsResource,
|
|
38
38
|
CommissionReportsResource,
|
|
39
39
|
CommissionPromotionsResource,
|
|
40
|
+
MessagesResource,
|
|
40
41
|
} from './resources';
|
|
41
42
|
|
|
42
43
|
export class GymSpaceSdk {
|
|
@@ -79,6 +80,7 @@ export class GymSpaceSdk {
|
|
|
79
80
|
public commissionCalculations: CommissionCalculationsResource;
|
|
80
81
|
public commissionReports: CommissionReportsResource;
|
|
81
82
|
public commissionPromotions: CommissionPromotionsResource;
|
|
83
|
+
public messages: MessagesResource;
|
|
82
84
|
|
|
83
85
|
constructor(config: GymSpaceConfig) {
|
|
84
86
|
this.client = new ApiClient(config);
|
|
@@ -119,6 +121,7 @@ export class GymSpaceSdk {
|
|
|
119
121
|
this.commissionCalculations = new CommissionCalculationsResource(this.client);
|
|
120
122
|
this.commissionReports = new CommissionReportsResource(this.client);
|
|
121
123
|
this.commissionPromotions = new CommissionPromotionsResource(this.client);
|
|
124
|
+
this.messages = new MessagesResource(this.client);
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
/**
|