@gymspace/sdk 1.2.12 → 1.2.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gymspace/sdk",
3
- "version": "1.2.12",
3
+ "version": "1.2.13",
4
4
  "description": "GymSpace TypeScript SDK for API integration",
5
5
  "author": "GymSpace Team",
6
6
  "license": "MIT",
@@ -0,0 +1,119 @@
1
+ export interface BulkTemplate {
2
+ id: string;
3
+ gymId: string;
4
+ name: string;
5
+ message: string;
6
+ description?: string;
7
+ tags: string[];
8
+ isActive: boolean;
9
+ usageCount: number;
10
+ lastUsedAt?: Date;
11
+ createdByUserId: string;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
+ }
15
+
16
+ export interface CreateBulkTemplateDto {
17
+ name: string;
18
+ message: string;
19
+ description?: string;
20
+ tags?: string[];
21
+ isActive?: boolean;
22
+ }
23
+
24
+ export interface UpdateBulkTemplateDto {
25
+ name?: string;
26
+ message?: string;
27
+ description?: string;
28
+ tags?: string[];
29
+ isActive?: boolean;
30
+ }
31
+
32
+ export interface BulkMessageVariable {
33
+ name: string;
34
+ placeholder: string;
35
+ description: string;
36
+ example: string;
37
+ category: 'client' | 'gym' | 'membership' | 'datetime' | 'custom';
38
+ required: boolean;
39
+ formatter?: 'text' | 'currency' | 'date' | 'number';
40
+ }
41
+
42
+ // DTO for sending bulk messages
43
+ // Note: SDK sends clientIds, API fetches full client and gym data before sending to agent
44
+
45
+ export interface SendBulkMessagesDto {
46
+ templateId?: string;
47
+ message: string;
48
+ clientIds: string[];
49
+ }
50
+
51
+ export interface RejectedClientDto {
52
+ clientId: string;
53
+ reason: string;
54
+ }
55
+
56
+ export interface BulkMessageResultDto {
57
+ sendId: string;
58
+ totalRecipients: number;
59
+ accepted: number;
60
+ rejected: number;
61
+ rejectedReasons: RejectedClientDto[];
62
+ estimatedTime: number;
63
+ }
64
+
65
+ // Legacy aliases for backward compatibility
66
+ export type RejectedClient = RejectedClientDto;
67
+ export type BulkMessageResult = BulkMessageResultDto;
68
+
69
+ export interface BulkMessageLogDto {
70
+ sendId: string;
71
+ clientId: string;
72
+ clientName: string;
73
+ phoneNumber: string;
74
+ message: string;
75
+ status: 'pending' | 'queued' | 'sent' | 'delivered' | 'failed';
76
+ sentAt?: string;
77
+ deliveredAt?: string;
78
+ failedAt?: string;
79
+ failureReason?: string;
80
+ retryCount: number;
81
+ timestamp: string;
82
+ }
83
+
84
+ export interface GetBulkLogsQueryDto {
85
+ sendId: string;
86
+ }
87
+
88
+ export interface BulkLogsResponseDto {
89
+ sendId: string;
90
+ totalRecipients: number;
91
+ sent: number;
92
+ delivered: number;
93
+ failed: number;
94
+ pending: number;
95
+ logs: BulkMessageLogDto[];
96
+ isComplete: boolean;
97
+ }
98
+
99
+ // Legacy aliases for backward compatibility
100
+ export type BulkMessageLog = BulkMessageLogDto;
101
+ export type BulkLogsResponse = BulkLogsResponseDto;
102
+
103
+ export interface GenerateAIMessageDto {
104
+ prompt: string;
105
+ tone?: 'promotional' | 'informational' | 'reminder' | 'greeting' | 'custom' | 'friendly';
106
+ includeVariables?: string[];
107
+ additionalRequirements?: string;
108
+ }
109
+
110
+ export interface GenerateAIMessageResponseDto {
111
+ message: string;
112
+ variables: string[];
113
+ tone: string;
114
+ suggestions?: string[];
115
+ }
116
+
117
+ // Legacy aliases for backward compatibility
118
+ export type GenerateAIMessageParams = GenerateAIMessageDto;
119
+ export type GenerateAIMessageResponse = GenerateAIMessageResponseDto;
@@ -124,7 +124,6 @@ export interface ClientStats {
124
124
 
125
125
  export interface SearchClientsParams {
126
126
  search?: string;
127
- activeOnly?: boolean;
128
127
  clientNumber?: string;
129
128
  documentId?: string;
130
129
  includeContractStatus?: boolean;
@@ -36,11 +36,49 @@ export interface GymAmenities {
36
36
  }
37
37
 
38
38
  export interface GymSettings {
39
+ inventory?: InventorySettings;
40
+ contracts?: ContractSettings;
39
41
  logo?: string;
40
42
  primaryColor?: string;
41
43
  [key: string]: any;
42
44
  }
43
45
 
46
+ /**
47
+ * Inventory configuration settings
48
+ */
49
+ export interface InventorySettings {
50
+ defaultMinStock?: number;
51
+ defaultMaxStock?: number;
52
+ enableLowStockAlerts?: boolean;
53
+ }
54
+
55
+ /**
56
+ * Contract expiration configuration settings
57
+ */
58
+ export interface ContractSettings {
59
+ expiringSoonDays?: number;
60
+ gracePeriodDays?: number;
61
+ enableExpirationNotifications?: boolean;
62
+ }
63
+
64
+ /**
65
+ * Update gym inventory settings DTO
66
+ */
67
+ export interface UpdateGymInventorySettingsDto {
68
+ defaultMinStock?: number;
69
+ defaultMaxStock?: number;
70
+ enableLowStockAlerts?: boolean;
71
+ }
72
+
73
+ /**
74
+ * Update gym contract settings DTO
75
+ */
76
+ export interface UpdateGymContractSettingsDto {
77
+ expiringSoonDays?: number;
78
+ gracePeriodDays?: number;
79
+ enableExpirationNotifications?: boolean;
80
+ }
81
+
44
82
  export interface Gym {
45
83
  id: string;
46
84
  organizationId: string;
@@ -122,4 +160,4 @@ export interface GymStats {
122
160
  monthlyRevenue: number;
123
161
  checkInsToday: number;
124
162
  checkInsMonth: number;
125
- }
163
+ }
@@ -22,6 +22,7 @@ export * from './admin-subscription-management';
22
22
  export * from './payment-methods';
23
23
  export * from './roles';
24
24
  export * from './whatsapp';
25
+ export * from './bulk-messaging';
25
26
 
26
27
  export interface ApiResponse<T> {
27
28
  data: T;
@@ -10,7 +10,6 @@ export interface StartOnboardingData {
10
10
  }
11
11
 
12
12
  export interface StartOnboardingResponse {
13
- success: boolean;
14
13
  access_token: string;
15
14
  refresh_token: string;
16
15
  user: {
@@ -19,6 +18,9 @@ export interface StartOnboardingResponse {
19
18
  name: string;
20
19
  userType: string;
21
20
  };
21
+ lastActiveGymId: string;
22
+ lastActiveOrganizationId: string;
23
+ // Additional fields for mobile app compatibility
22
24
  organization: {
23
25
  id: string;
24
26
  name: string;
@@ -107,7 +109,6 @@ export interface CheckInSystemFeatures {
107
109
  allowMultiplePerDay: boolean;
108
110
  }
109
111
 
110
-
111
112
  export interface NotificationSettings {
112
113
  emailEnabled: boolean;
113
114
  smsEnabled: boolean;
@@ -151,4 +152,4 @@ export interface OnboardingResponse {
151
152
  gym?: any;
152
153
  onboardingStatus: OnboardingStatus;
153
154
  message?: string;
154
- }
155
+ }
@@ -87,6 +87,14 @@ export interface Product {
87
87
  createdAt: string;
88
88
  updatedAt: string;
89
89
  category?: ProductCategory;
90
+ image?: {
91
+ id: string;
92
+ filename: string;
93
+ originalName: string;
94
+ fileSize: number;
95
+ mimeType: string;
96
+ previewUrl?: string;
97
+ };
90
98
  createdBy?: {
91
99
  id: string;
92
100
  name: string;
@@ -0,0 +1,83 @@
1
+ import { BaseResource } from './base';
2
+ import { RequestOptions } from '../types';
3
+ import {
4
+ BulkTemplate,
5
+ CreateBulkTemplateDto,
6
+ UpdateBulkTemplateDto,
7
+ BulkMessageVariable,
8
+ SendBulkMessagesDto,
9
+ BulkMessageResultDto,
10
+ BulkLogsResponseDto,
11
+ GenerateAIMessageDto,
12
+ GenerateAIMessageResponseDto,
13
+ } from '../models/bulk-messaging';
14
+
15
+ export class BulkMessagingResource extends BaseResource {
16
+ private basePath = 'whatsapp/bulk-messaging';
17
+ private templatesPath = 'whatsapp/bulk-templates';
18
+
19
+ async createTemplate(
20
+ data: CreateBulkTemplateDto,
21
+ options?: RequestOptions,
22
+ ): Promise<BulkTemplate> {
23
+ return this.client.post<BulkTemplate>(this.templatesPath, data, options);
24
+ }
25
+
26
+ async getTemplates(options?: RequestOptions): Promise<BulkTemplate[]> {
27
+ return this.client.get<BulkTemplate[]>(this.templatesPath, undefined, options);
28
+ }
29
+
30
+ async getTemplate(id: string, options?: RequestOptions): Promise<BulkTemplate> {
31
+ return this.client.get<BulkTemplate>(`${this.templatesPath}/${id}`, undefined, options);
32
+ }
33
+
34
+ async updateTemplate(
35
+ id: string,
36
+ data: UpdateBulkTemplateDto,
37
+ options?: RequestOptions,
38
+ ): Promise<BulkTemplate> {
39
+ return this.client.put<BulkTemplate>(`${this.templatesPath}/${id}`, data, options);
40
+ }
41
+
42
+ async deleteTemplate(id: string, options?: RequestOptions): Promise<void> {
43
+ return this.client.delete<void>(`${this.templatesPath}/${id}`, options);
44
+ }
45
+
46
+ async getAvailableVariables(options?: RequestOptions): Promise<BulkMessageVariable[]> {
47
+ return this.client.get<BulkMessageVariable[]>(
48
+ `${this.basePath}/available-variables`,
49
+ undefined,
50
+ options,
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Generate AI message with streaming support
56
+ * Note: This proxies to the agent endpoint for streaming responses
57
+ */
58
+ async generateAIMessage(
59
+ data: GenerateAIMessageDto,
60
+ options?: RequestOptions,
61
+ ): Promise<GenerateAIMessageResponseDto> {
62
+ return this.client.post<GenerateAIMessageResponseDto>(
63
+ `${this.basePath}/generate-ai`,
64
+ data,
65
+ options,
66
+ );
67
+ }
68
+
69
+ /**
70
+ * Send bulk messages to multiple clients
71
+ * Note: SDK sends clientIds, API fetches full client and gym data before sending to agent
72
+ */
73
+ async send(data: SendBulkMessagesDto, options?: RequestOptions): Promise<BulkMessageResultDto> {
74
+ return this.client.post<BulkMessageResultDto>(`${this.basePath}/send`, data, options);
75
+ }
76
+
77
+ /**
78
+ * Get logs for a bulk message send operation
79
+ */
80
+ async getLogs(sendId: string, options?: RequestOptions): Promise<BulkLogsResponseDto> {
81
+ return this.client.get<BulkLogsResponseDto>(`${this.basePath}/logs`, { sendId }, options);
82
+ }
83
+ }
@@ -1,40 +1,32 @@
1
1
  import { BaseResource } from './base';
2
- import { Gym, CreateGymDto, UpdateGymDto, GymStats, UpdateGymScheduleDto, UpdateGymSocialMediaDto } from '../models/gyms';
2
+ import {
3
+ Gym,
4
+ CreateGymDto,
5
+ UpdateGymDto,
6
+ GymStats,
7
+ UpdateGymScheduleDto,
8
+ UpdateGymSocialMediaDto,
9
+ UpdateGymInventorySettingsDto,
10
+ UpdateGymContractSettingsDto,
11
+ } from '../models/gyms';
3
12
  import { RequestOptions } from '../types';
4
13
 
5
14
  export class GymsResource extends BaseResource {
6
15
  private basePath = 'gyms';
7
16
 
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
+ async createGym(data: CreateGymDto, options?: RequestOptions): Promise<Gym> {
18
+ return this.client.post<Gym>(this.basePath, data, options);
17
19
  }
18
20
 
19
- async getOrganizationGyms(
20
- options?: RequestOptions
21
- ): Promise<Gym[]> {
22
- return this.client.get<Gym[]>(
23
- this.basePath,
24
- undefined,
25
- options
26
- );
21
+ async getOrganizationGyms(options?: RequestOptions): Promise<Gym[]> {
22
+ return this.client.get<Gym[]>(this.basePath, undefined, options);
27
23
  }
28
24
 
29
25
  async getGym(id: string, options?: RequestOptions): Promise<Gym> {
30
26
  return this.client.get<Gym>(`${this.basePath}/${id}`, undefined, options);
31
27
  }
32
28
 
33
- async updateGym(
34
- id: string,
35
- data: UpdateGymDto,
36
- options?: RequestOptions
37
- ): Promise<Gym> {
29
+ async updateGym(id: string, data: UpdateGymDto, options?: RequestOptions): Promise<Gym> {
38
30
  return this.client.put<Gym>(`${this.basePath}/${id}`, data, options);
39
31
  }
40
32
 
@@ -54,7 +46,7 @@ export class GymsResource extends BaseResource {
54
46
  email?: string;
55
47
  assetId?: string;
56
48
  }>,
57
- options?: RequestOptions
49
+ options?: RequestOptions,
58
50
  ): Promise<Gym> {
59
51
  return this.client.put<Gym>(`${this.basePath}/current`, data, options);
60
52
  }
@@ -62,7 +54,7 @@ export class GymsResource extends BaseResource {
62
54
  async updateGymSchedule(
63
55
  id: string,
64
56
  data: UpdateGymScheduleDto,
65
- options?: RequestOptions
57
+ options?: RequestOptions,
66
58
  ): Promise<Gym> {
67
59
  return this.client.put<Gym>(`${this.basePath}/${id}/schedule`, data, options);
68
60
  }
@@ -70,8 +62,54 @@ export class GymsResource extends BaseResource {
70
62
  async updateGymSocialMedia(
71
63
  id: string,
72
64
  data: UpdateGymSocialMediaDto,
73
- options?: RequestOptions
65
+ options?: RequestOptions,
74
66
  ): Promise<Gym> {
75
67
  return this.client.put<Gym>(`${this.basePath}/${id}/social-media`, data, options);
76
68
  }
77
- }
69
+
70
+ /**
71
+ * Update current gym inventory settings (stock configuration)
72
+ * Uses gym from context (x-gym-id header)
73
+ * @param data Inventory settings data
74
+ * @param options Request options
75
+ * @returns Updated gym with new settings
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const gym = await sdk.gyms.updateInventorySettings({
80
+ * defaultMinStock: 15,
81
+ * defaultMaxStock: 1000,
82
+ * enableLowStockAlerts: true
83
+ * });
84
+ * ```
85
+ */
86
+ async updateInventorySettings(
87
+ data: UpdateGymInventorySettingsDto,
88
+ options?: RequestOptions,
89
+ ): Promise<Gym> {
90
+ return this.client.patch<Gym>(`${this.basePath}/current/inventory-settings`, data, options);
91
+ }
92
+
93
+ /**
94
+ * Update current gym contract expiration settings
95
+ * Uses gym from context (x-gym-id header)
96
+ * @param data Contract settings data
97
+ * @param options Request options
98
+ * @returns Updated gym with new settings
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const gym = await sdk.gyms.updateContractSettings({
103
+ * expiringSoonDays: 7,
104
+ * gracePeriodDays: 0,
105
+ * enableExpirationNotifications: true
106
+ * });
107
+ * ```
108
+ */
109
+ async updateContractSettings(
110
+ data: UpdateGymContractSettingsDto,
111
+ options?: RequestOptions,
112
+ ): Promise<Gym> {
113
+ return this.client.patch<Gym>(`${this.basePath}/current/contract-settings`, data, options);
114
+ }
115
+ }
@@ -23,4 +23,5 @@ export * from './subscription-plans';
23
23
  export * from './admin-subscription-management';
24
24
  export * from './payment-methods';
25
25
  export * from './whatsapp';
26
- export * from './whatsapp-templates';
26
+ export * from './whatsapp-templates';
27
+ export * from './bulk-messaging';
@@ -65,6 +65,14 @@ export interface UpdateSubscriptionPlanDto {
65
65
 
66
66
  export class SubscriptionPlansResource extends BaseResource {
67
67
  private basePath = 'admin/subscription-plans';
68
+ private publicBasePath = 'subscription-plans/public';
69
+
70
+ /**
71
+ * List all active subscription plans (Public - no authentication required)
72
+ */
73
+ async listPublicPlans(options?: RequestOptions): Promise<SubscriptionPlanDto[]> {
74
+ return this.client.get<SubscriptionPlanDto[]>(`${this.publicBasePath}`, undefined, options);
75
+ }
68
76
 
69
77
  /**
70
78
  * List all subscription plans (Super Admin only)
@@ -107,4 +115,4 @@ export class SubscriptionPlansResource extends BaseResource {
107
115
  async deletePlan(id: string, options?: RequestOptions): Promise<{ success: boolean }> {
108
116
  return this.client.delete<{ success: boolean }>(`${this.basePath}/${id}`, options);
109
117
  }
110
- }
118
+ }
package/src/sdk.ts CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  PaymentMethodsResource,
29
29
  WhatsAppResource,
30
30
  WhatsAppTemplatesResource,
31
+ BulkMessagingResource,
31
32
  } from './resources';
32
33
 
33
34
  export class GymSpaceSdk {
@@ -61,6 +62,7 @@ export class GymSpaceSdk {
61
62
  public paymentMethods: PaymentMethodsResource;
62
63
  public whatsapp: WhatsAppResource;
63
64
  public whatsappTemplates: WhatsAppTemplatesResource;
65
+ public bulkMessaging: BulkMessagingResource;
64
66
 
65
67
  constructor(config: GymSpaceConfig) {
66
68
  this.client = new ApiClient(config);
@@ -92,6 +94,7 @@ export class GymSpaceSdk {
92
94
  this.paymentMethods = new PaymentMethodsResource(this.client);
93
95
  this.whatsapp = new WhatsAppResource(this.client);
94
96
  this.whatsappTemplates = new WhatsAppTemplatesResource(this.client);
97
+ this.bulkMessaging = new BulkMessagingResource(this.client);
95
98
  }
96
99
 
97
100
  /**