@gymspace/sdk 1.2.5 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gymspace/sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.8",
4
4
  "description": "GymSpace TypeScript SDK for API integration",
5
5
  "author": "GymSpace Team",
6
6
  "license": "MIT",
@@ -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 extends PaginationQueryDto {
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
- }
@@ -1,84 +1,2 @@
1
- export interface Collaborator {
2
- id: string;
3
- userId: string;
4
- gymId: string;
5
- roleId: string;
6
- status: 'pending' | 'active' | 'inactive';
7
- hiredDate?: string;
8
- profilePhotoId?: string;
9
- coverPhotoId?: string;
10
- description?: string;
11
- specialties?: any;
12
- user?: {
13
- id: string;
14
- name: string;
15
- email: string;
16
- phone?: string;
17
- };
18
- role?: {
19
- id: string;
20
- name: string;
21
- permissions: string[];
22
- };
23
- }
24
-
25
- export interface ListCollaboratorsParams {
26
- page: number;
27
- limit: number;
28
- status?: 'pending' | 'active' | 'inactive';
29
- roleId?: string;
30
- search?: string;
31
- }
32
-
33
- export interface UpdateCollaboratorDto {
34
- hiredDate?: string;
35
- profilePhotoId?: string;
36
- coverPhotoId?: string;
37
- description?: string;
38
- specialties?: any;
39
- }
40
-
41
- export interface UpdateStatusDto {
42
- status: 'active' | 'inactive';
43
- }
44
-
45
- export interface UpdateRoleDto {
46
- roleId: string;
47
- }
48
-
49
- export interface ActivityQueryParams {
50
- startDate?: string;
51
- endDate?: string;
52
- limit?: number;
53
- type?: string;
54
- }
55
-
56
- export interface StatsQueryParams {
57
- startDate?: string;
58
- endDate?: string;
59
- }
60
-
61
- export interface CollaboratorStats {
62
- contracts: {
63
- total: number;
64
- totalAmount: number;
65
- averageAmount: number;
66
- };
67
- checkIns: {
68
- total: number;
69
- };
70
- sales: {
71
- total: number;
72
- totalAmount: number;
73
- };
74
- clients: {
75
- created: number;
76
- };
77
- }
78
-
79
- export interface ActivityItem {
80
- type: string;
81
- timestamp: string;
82
- description: string;
83
- metadata: any;
84
- }
1
+ // All types are exported from @gymspace/shared via types.ts
2
+ // No need to duplicate them here
@@ -2,14 +2,14 @@
2
2
  export * from './auth';
3
3
  export * from './organizations';
4
4
  export * from './gyms';
5
- export * from './collaborators';
5
+ // collaborators types are in @gymspace/shared
6
6
  export * from './clients';
7
7
  export * from './membership-plans';
8
8
  export * from './contracts';
9
9
  export * from './dashboard';
10
10
  export * from './evaluations';
11
11
  export * from './check-ins';
12
- export * from './invitations';
12
+ // invitations types are in @gymspace/shared
13
13
  export * from './leads';
14
14
  export * from './assets';
15
15
  export * from './files';
@@ -23,8 +23,9 @@ export * from './subscription-plans';
23
23
  export * from './admin-subscription-management';
24
24
  export * from './payment-methods';
25
25
  export * from './roles';
26
+ export * from './whatsapp';
26
27
 
27
28
  export interface ApiResponse<T> {
28
29
  data: T;
29
30
  meta?: any;
30
- }
31
+ }
@@ -1,46 +1,2 @@
1
- import { InvitationStatus } from '@gymspace/shared';
2
-
3
- export interface CreateInvitationDto {
4
- email: string;
5
- roleId: string;
6
- }
7
-
8
- export interface AcceptInvitationDto {
9
- token?: string;
10
- code?: string;
11
- name: string;
12
- phone: string;
13
- password: string;
14
- }
15
-
16
- export interface ValidateByCodeDto {
17
- code: string;
18
- }
19
-
20
- export interface Invitation {
21
- id: string;
22
- email: string;
23
- gymId: string;
24
- roleId: string;
25
- token: string;
26
- code: string;
27
- status: InvitationStatus;
28
- invitedByUserId: string;
29
- acceptedAt?: string;
30
- expiresAt: string;
31
- createdAt: string;
32
- updatedAt: string;
33
- role?: {
34
- id: string;
35
- name: string;
36
- };
37
- invitedBy?: {
38
- id: string;
39
- name: string | null;
40
- email: string;
41
- };
42
- }
43
-
44
- export interface GetGymInvitationsParams {
45
- gymId: string;
46
- }
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
- gymId: string;
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
+ }
@@ -1,26 +1,4 @@
1
- export interface Role {
2
- id: string;
3
- name: string;
4
- description: string | null;
5
- permissions: string[];
6
- canManageEvaluations: boolean;
7
- organizationId: string;
8
- createdByUserId: string | null;
9
- updatedByUserId: string | null;
10
- createdAt: string;
11
- updatedAt: string;
12
- deletedAt: string | null;
13
- createdBy?: {
14
- id: string;
15
- name: string;
16
- email: string;
17
- };
18
- updatedBy?: {
19
- id: string;
20
- name: string;
21
- email: string;
22
- };
23
- }
1
+ // Role type is exported from @gymspace/shared via types.ts
24
2
 
25
3
  export interface PermissionsGroup {
26
4
  [category: string]: string[];
@@ -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
+ }
@@ -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, PaginatedResponseDto } from '../types';
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?: SearchClientsParams,
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>(`${this.basePath}/${id}/stats/${statKey}`, undefined, options);
40
+ return this.client.get<ClientStat>(
41
+ `${this.basePath}/${id}/stats/${statKey}`,
42
+ undefined,
43
+ options,
44
+ );
50
45
  }
51
46
 
52
- async getClientStatsByCategory(id: string, category: string, options?: RequestOptions): Promise<ClientStat[]> {
53
- return this.client.get<ClientStat[]>(`${this.basePath}/${id}/stats/category/${category}`, undefined, options);
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<ClientSearchForCheckInResponse> {
65
+ options?: RequestOptions,
66
+ ): Promise<Client[]> {
64
67
  // This endpoint automatically includes contract status and only active clients
65
- return this.client.get<ClientSearchForCheckInResponse>(
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
+ }
@@ -1,15 +1,15 @@
1
1
  import { BaseResource } from './base';
2
- import {
2
+ import type {
3
3
  Collaborator,
4
4
  ListCollaboratorsParams,
5
5
  UpdateCollaboratorDto,
6
- UpdateStatusDto,
7
- UpdateRoleDto,
6
+ UpdateCollaboratorStatusDto,
7
+ UpdateCollaboratorRoleDto,
8
8
  ActivityQueryParams,
9
9
  StatsQueryParams,
10
10
  CollaboratorStats,
11
11
  ActivityItem,
12
- } from '../models/collaborators';
12
+ } from '@gymspace/shared';
13
13
  import { RequestOptions, PaginatedResponseDto } from '../types';
14
14
 
15
15
  export class CollaboratorsResource extends BaseResource {
@@ -17,7 +17,7 @@ export class CollaboratorsResource extends BaseResource {
17
17
 
18
18
  async list(
19
19
  params?: ListCollaboratorsParams,
20
- options?: RequestOptions
20
+ options?: RequestOptions,
21
21
  ): Promise<PaginatedResponseDto<Collaborator>> {
22
22
  return this.paginate<Collaborator>(this.basePath, params, options);
23
23
  }
@@ -29,31 +29,31 @@ export class CollaboratorsResource extends BaseResource {
29
29
  async update(
30
30
  id: string,
31
31
  data: UpdateCollaboratorDto,
32
- options?: RequestOptions
32
+ options?: RequestOptions,
33
33
  ): Promise<Collaborator> {
34
34
  return this.client.patch<Collaborator>(`${this.basePath}/${id}`, data, options);
35
35
  }
36
36
 
37
37
  async updateRole(
38
38
  id: string,
39
- roleId: string,
40
- options?: RequestOptions
39
+ data: UpdateCollaboratorRoleDto,
40
+ options?: RequestOptions,
41
41
  ): Promise<Collaborator> {
42
- return this.client.patch<Collaborator>(`${this.basePath}/${id}/role`, { roleId }, options);
42
+ return this.client.patch<Collaborator>(`${this.basePath}/${id}/role`, data, options);
43
43
  }
44
44
 
45
45
  async updateStatus(
46
46
  id: string,
47
- status: 'active' | 'inactive',
48
- options?: RequestOptions
47
+ data: UpdateCollaboratorStatusDto,
48
+ options?: RequestOptions,
49
49
  ): Promise<Collaborator> {
50
- return this.client.patch<Collaborator>(`${this.basePath}/${id}/status`, { status }, options);
50
+ return this.client.patch<Collaborator>(`${this.basePath}/${id}/status`, data, options);
51
51
  }
52
52
 
53
53
  async getActivity(
54
54
  id: string,
55
55
  params?: ActivityQueryParams,
56
- options?: RequestOptions
56
+ options?: RequestOptions,
57
57
  ): Promise<ActivityItem[]> {
58
58
  return this.client.get<ActivityItem[]>(`${this.basePath}/${id}/activity`, params, options);
59
59
  }
@@ -61,7 +61,7 @@ export class CollaboratorsResource extends BaseResource {
61
61
  async getStats(
62
62
  id: string,
63
63
  params?: StatsQueryParams,
64
- options?: RequestOptions
64
+ options?: RequestOptions,
65
65
  ): Promise<CollaboratorStats> {
66
66
  return this.client.get<CollaboratorStats>(`${this.basePath}/${id}/stats`, params, options);
67
67
  }
@@ -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: string,
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(id: string, data: { reason: string }, options?: RequestOptions): Promise<Contract> {
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
+ }
@@ -23,4 +23,6 @@ export * from './users';
23
23
  export * from './subscriptions';
24
24
  export * from './subscription-plans';
25
25
  export * from './admin-subscription-management';
26
- export * from './payment-methods';
26
+ export * from './payment-methods';
27
+ export * from './whatsapp';
28
+ export * from './whatsapp-templates';