@gymspace/sdk 1.0.1 → 1.0.3
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/index.d.mts +2076 -0
- package/dist/index.d.ts +2076 -0
- package/dist/index.js +32 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +5 -2
- package/src/models/auth.ts +2 -14
- package/src/models/gyms.ts +52 -0
- package/src/models/organizations.ts +16 -0
- package/src/resources/auth.ts +1 -1
- package/src/resources/gyms.ts +17 -1
- package/src/resources/organizations.ts +5 -1
package/src/client.ts
CHANGED
|
@@ -3,6 +3,7 @@ import axios, {
|
|
|
3
3
|
AxiosRequestConfig,
|
|
4
4
|
AxiosError,
|
|
5
5
|
InternalAxiosRequestConfig,
|
|
6
|
+
AxiosRequestHeaders,
|
|
6
7
|
} from 'axios';
|
|
7
8
|
import { GymSpaceConfig, RequestOptions } from './types';
|
|
8
9
|
import {
|
|
@@ -92,9 +93,11 @@ export class ApiClient {
|
|
|
92
93
|
|
|
93
94
|
if (newTokens) {
|
|
94
95
|
// Update the original request with new token
|
|
95
|
-
|
|
96
|
+
if (!originalRequest.headers) {
|
|
97
|
+
originalRequest.headers = {} as AxiosRequestHeaders;
|
|
98
|
+
}
|
|
96
99
|
originalRequest.headers['Authorization'] = `Bearer ${newTokens.access_token}`;
|
|
97
|
-
|
|
100
|
+
|
|
98
101
|
// Retry the original request
|
|
99
102
|
return this.axiosInstance(originalRequest);
|
|
100
103
|
}
|
package/src/models/auth.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SubscriptionPlan } from './subscriptions';
|
|
2
|
+
|
|
1
3
|
export interface RegisterOwnerDto {
|
|
2
4
|
name: string;
|
|
3
5
|
email: string;
|
|
@@ -79,7 +81,6 @@ export interface ResendResetCodeResponseDto {
|
|
|
79
81
|
message: string;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
|
|
83
84
|
export interface RegisterCollaboratorDto {
|
|
84
85
|
invitationToken: string;
|
|
85
86
|
name: string;
|
|
@@ -87,19 +88,6 @@ export interface RegisterCollaboratorDto {
|
|
|
87
88
|
password: string;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
export interface SubscriptionPlan {
|
|
91
|
-
id: string;
|
|
92
|
-
name: string;
|
|
93
|
-
price: number;
|
|
94
|
-
billingFrequency: string;
|
|
95
|
-
maxGyms: number;
|
|
96
|
-
maxClientsPerGym: number;
|
|
97
|
-
maxUsersPerGym: number;
|
|
98
|
-
features: any;
|
|
99
|
-
description?: string;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
91
|
export interface InvitationValidationResponse {
|
|
104
92
|
valid: boolean;
|
|
105
93
|
invitation: {
|
package/src/models/gyms.ts
CHANGED
|
@@ -57,11 +57,63 @@ export interface Gym {
|
|
|
57
57
|
capacity?: number;
|
|
58
58
|
amenities?: GymAmenities;
|
|
59
59
|
settings?: GymSettings;
|
|
60
|
+
schedule?: GymSchedule;
|
|
61
|
+
socialMedia?: GymSocialMedia;
|
|
60
62
|
isActive: boolean;
|
|
61
63
|
createdAt: string;
|
|
62
64
|
updatedAt: string;
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
export interface TimeSlot {
|
|
68
|
+
open: string;
|
|
69
|
+
close: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface DaySchedule {
|
|
73
|
+
isOpen: boolean;
|
|
74
|
+
slots?: TimeSlot[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface GymSchedule {
|
|
78
|
+
monday?: DaySchedule;
|
|
79
|
+
tuesday?: DaySchedule;
|
|
80
|
+
wednesday?: DaySchedule;
|
|
81
|
+
thursday?: DaySchedule;
|
|
82
|
+
friday?: DaySchedule;
|
|
83
|
+
saturday?: DaySchedule;
|
|
84
|
+
sunday?: DaySchedule;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface GymSocialMedia {
|
|
88
|
+
facebook?: string;
|
|
89
|
+
instagram?: string;
|
|
90
|
+
whatsapp?: string;
|
|
91
|
+
twitter?: string;
|
|
92
|
+
linkedin?: string;
|
|
93
|
+
youtube?: string;
|
|
94
|
+
tiktok?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface UpdateGymScheduleDto {
|
|
98
|
+
monday?: DaySchedule;
|
|
99
|
+
tuesday?: DaySchedule;
|
|
100
|
+
wednesday?: DaySchedule;
|
|
101
|
+
thursday?: DaySchedule;
|
|
102
|
+
friday?: DaySchedule;
|
|
103
|
+
saturday?: DaySchedule;
|
|
104
|
+
sunday?: DaySchedule;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface UpdateGymSocialMediaDto {
|
|
108
|
+
facebook?: string;
|
|
109
|
+
instagram?: string;
|
|
110
|
+
whatsapp?: string;
|
|
111
|
+
twitter?: string;
|
|
112
|
+
linkedin?: string;
|
|
113
|
+
youtube?: string;
|
|
114
|
+
tiktok?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
65
117
|
export interface GymStats {
|
|
66
118
|
totalClients: number;
|
|
67
119
|
activeClients: number;
|
|
@@ -19,4 +19,20 @@ export interface OrganizationStats {
|
|
|
19
19
|
totalContracts: number;
|
|
20
20
|
activeContracts: number;
|
|
21
21
|
totalRevenue: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface OrganizationWithDetails {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
owner: {
|
|
28
|
+
id: string;
|
|
29
|
+
email: string;
|
|
30
|
+
fullName: string;
|
|
31
|
+
};
|
|
32
|
+
gyms: Array<{
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
address: string;
|
|
36
|
+
}>;
|
|
37
|
+
createdAt: Date;
|
|
22
38
|
}
|
package/src/resources/auth.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
RegisterCollaboratorDto,
|
|
7
7
|
RegisterOwnerDto,
|
|
8
8
|
ResendVerificationDto,
|
|
9
|
-
SubscriptionPlan,
|
|
10
9
|
VerifyEmailDto,
|
|
11
10
|
ChangePasswordDto,
|
|
12
11
|
ChangePasswordResponseDto,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
ResendResetCodeDto,
|
|
20
19
|
ResendResetCodeResponseDto,
|
|
21
20
|
} from '../models/auth';
|
|
21
|
+
import { SubscriptionPlan } from '../models/subscriptions';
|
|
22
22
|
import { RequestOptions } from '../types';
|
|
23
23
|
import { BaseResource } from './base';
|
|
24
24
|
|
package/src/resources/gyms.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import { Gym, CreateGymDto, UpdateGymDto, GymStats } from '../models/gyms';
|
|
2
|
+
import { Gym, CreateGymDto, UpdateGymDto, GymStats, UpdateGymScheduleDto, UpdateGymSocialMediaDto } from '../models/gyms';
|
|
3
3
|
import { RequestOptions } from '../types';
|
|
4
4
|
|
|
5
5
|
export class GymsResource extends BaseResource {
|
|
@@ -58,4 +58,20 @@ export class GymsResource extends BaseResource {
|
|
|
58
58
|
): Promise<Gym> {
|
|
59
59
|
return this.client.put<Gym>(`${this.basePath}/current`, data, options);
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
async updateGymSchedule(
|
|
63
|
+
id: string,
|
|
64
|
+
data: UpdateGymScheduleDto,
|
|
65
|
+
options?: RequestOptions
|
|
66
|
+
): Promise<Gym> {
|
|
67
|
+
return this.client.put<Gym>(`${this.basePath}/${id}/schedule`, data, options);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async updateGymSocialMedia(
|
|
71
|
+
id: string,
|
|
72
|
+
data: UpdateGymSocialMediaDto,
|
|
73
|
+
options?: RequestOptions
|
|
74
|
+
): Promise<Gym> {
|
|
75
|
+
return this.client.put<Gym>(`${this.basePath}/${id}/social-media`, data, options);
|
|
76
|
+
}
|
|
61
77
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import { Organization, UpdateOrganizationDto, OrganizationStats } from '../models/organizations';
|
|
2
|
+
import { Organization, UpdateOrganizationDto, OrganizationStats, OrganizationWithDetails } from '../models/organizations';
|
|
3
3
|
import { RequestOptions } from '../types';
|
|
4
4
|
|
|
5
5
|
export class OrganizationsResource extends BaseResource {
|
|
@@ -20,4 +20,8 @@ export class OrganizationsResource extends BaseResource {
|
|
|
20
20
|
async getOrganizationStats(id: string, options?: RequestOptions): Promise<OrganizationStats> {
|
|
21
21
|
return this.client.get<OrganizationStats>(`${this.basePath}/${id}/stats`, undefined, options);
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
async listOrganizations(options?: RequestOptions): Promise<OrganizationWithDetails[]> {
|
|
25
|
+
return this.client.get<OrganizationWithDetails[]>(`${this.basePath}/list`, undefined, options);
|
|
26
|
+
}
|
|
23
27
|
}
|