@gymspace/sdk 1.0.0 → 1.0.2

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.
@@ -0,0 +1,74 @@
1
+ export interface SubscriptionPlan {
2
+ id: string;
3
+ name: string;
4
+ price: any;
5
+ billingFrequency: string;
6
+ maxGyms: number;
7
+ maxClientsPerGym: number;
8
+ maxUsersPerGym: number;
9
+ features: any;
10
+ description?: string;
11
+ }
12
+
13
+ export interface Subscription {
14
+ id: string;
15
+ organizationId: string;
16
+ subscriptionPlanId: string;
17
+ subscriptionPlan?: SubscriptionPlan;
18
+ status: string;
19
+ startDate: Date;
20
+ endDate: Date;
21
+ isActive: boolean;
22
+ }
23
+
24
+ export interface AvailablePlanDto {
25
+ id: string;
26
+ name: string;
27
+ description?: string;
28
+ price: any;
29
+ billingFrequency: string;
30
+ maxGyms: number;
31
+ maxClientsPerGym: number;
32
+ maxUsersPerGym: number;
33
+ features: any;
34
+ isFreePlan: boolean;
35
+ }
36
+
37
+ export interface SubscriptionStatusDto {
38
+ organizationId: string;
39
+ currentPlan: SubscriptionPlan | null;
40
+ status: string;
41
+ startDate: Date | null;
42
+ endDate: Date | null;
43
+ usage: {
44
+ gyms: {
45
+ current: number;
46
+ limit: number;
47
+ };
48
+ clientsPerGym: {
49
+ [gymId: string]: {
50
+ current: number;
51
+ limit: number;
52
+ };
53
+ };
54
+ usersPerGym: {
55
+ [gymId: string]: {
56
+ current: number;
57
+ limit: number;
58
+ };
59
+ };
60
+ };
61
+ canUpgrade: boolean;
62
+ canDowngrade: boolean;
63
+ }
64
+
65
+ export interface AffiliateOrganizationDto {
66
+ subscriptionPlanId: string;
67
+ }
68
+
69
+ export interface CheckLimitResponse {
70
+ canPerform: boolean;
71
+ currentUsage: number;
72
+ limit: number;
73
+ message?: string;
74
+ }
@@ -33,8 +33,8 @@ export class AuthResource extends BaseResource {
33
33
  return this.client.post<LoginResponseDto>(`${this.basePath}/login`, data, options);
34
34
  }
35
35
 
36
- async refreshToken(options?: RequestOptions): Promise<LoginResponseDto> {
37
- return this.client.post<LoginResponseDto>(`${this.basePath}/refresh`, undefined, options);
36
+ async refreshToken(refreshToken: string, options?: RequestOptions): Promise<LoginResponseDto> {
37
+ return this.client.post<LoginResponseDto>(`${this.basePath}/refresh`, { refresh_token: refreshToken }, options);
38
38
  }
39
39
 
40
40
  async verifyEmail(
@@ -4,6 +4,7 @@ import {
4
4
  CreateClientDto,
5
5
  UpdateClientDto,
6
6
  ClientStats,
7
+ ClientStat,
7
8
  SearchClientsParams,
8
9
  ClientSearchForCheckInResponse
9
10
  } from '../models/clients';
@@ -20,6 +21,7 @@ export class ClientsResource extends BaseResource {
20
21
  params?: SearchClientsParams,
21
22
  options?: RequestOptions
22
23
  ): Promise<PaginatedResponseDto<Client>> {
24
+
23
25
  return this.paginate<Client>(this.basePath, params, options);
24
26
  }
25
27
 
@@ -43,6 +45,18 @@ export class ClientsResource extends BaseResource {
43
45
  return this.client.get<ClientStats>(`${this.basePath}/${id}/stats`, undefined, options);
44
46
  }
45
47
 
48
+ async getClientStat(id: string, statKey: string, options?: RequestOptions): Promise<ClientStat> {
49
+ return this.client.get<ClientStat>(`${this.basePath}/${id}/stats/${statKey}`, undefined, options);
50
+ }
51
+
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);
54
+ }
55
+
56
+ async getAvailableStats(options?: RequestOptions): Promise<ClientStat[]> {
57
+ return this.client.get<ClientStat[]>(`${this.basePath}/stats/available`, undefined, options);
58
+ }
59
+
46
60
  async searchClientsForCheckIn(
47
61
  params?: SearchClientsParams,
48
62
  options?: RequestOptions
@@ -1,30 +1,82 @@
1
1
  import { BaseResource } from './base';
2
- import { DashboardStats, RecentActivity, ExpiringContract } from '../models/dashboard';
2
+ import {
3
+ DashboardStats,
4
+ ExpiringContract,
5
+ ContractsRevenue,
6
+ SalesRevenue,
7
+ Debts,
8
+ CheckIns,
9
+ NewClients,
10
+ DateRangeParams,
11
+ } from '../models/dashboard';
3
12
 
4
13
  export class DashboardResource extends BaseResource {
5
14
  /**
6
- * Get dashboard statistics
7
- * @returns Dashboard statistics including clients, contracts, revenue, and check-ins
15
+ * Get dashboard statistics (lightweight counts only)
16
+ * @returns Dashboard statistics including client and contract counts
8
17
  */
9
18
  async getStats(): Promise<DashboardStats> {
10
19
  return this.client.get<DashboardStats>('/dashboard/stats');
11
20
  }
12
21
 
13
22
  /**
14
- * Get recent activity
15
- * @param limit Maximum number of activities to return (default: 10)
16
- * @returns List of recent activities in the gym
23
+ * Get contracts revenue within date range
24
+ * @param params Optional date range parameters
25
+ * @returns Contracts revenue data for the specified period
17
26
  */
18
- async getRecentActivity(limit: number = 10): Promise<RecentActivity[]> {
19
- return this.client.get<RecentActivity[]>('/dashboard/recent-activity', { limit });
27
+ async getContractsRevenue(params?: DateRangeParams): Promise<ContractsRevenue> {
28
+ return this.client.get<ContractsRevenue>('/dashboard/contracts-revenue', params);
20
29
  }
21
30
 
22
31
  /**
23
- * Get expiring contracts
32
+ * Get sales revenue within date range
33
+ * @param params Optional date range parameters
34
+ * @returns Sales revenue data for the specified period
35
+ */
36
+ async getSalesRevenue(params?: DateRangeParams): Promise<SalesRevenue> {
37
+ return this.client.get<SalesRevenue>('/dashboard/sales-revenue', params);
38
+ }
39
+
40
+ /**
41
+ * Get total debts within date range
42
+ * @param params Optional date range parameters
43
+ * @returns Outstanding debts data for the specified period
44
+ */
45
+ async getDebts(params?: DateRangeParams): Promise<Debts> {
46
+ return this.client.get<Debts>('/dashboard/debts', params);
47
+ }
48
+
49
+ /**
50
+ * Get check-ins count within date range
51
+ * @param params Optional date range parameters
52
+ * @returns Check-ins data for the specified period
53
+ */
54
+ async getCheckIns(params?: DateRangeParams): Promise<CheckIns> {
55
+ return this.client.get<CheckIns>('/dashboard/check-ins', params);
56
+ }
57
+
58
+ /**
59
+ * Get new clients count within date range
60
+ * @param params Optional date range parameters
61
+ * @returns New clients data for the specified period
62
+ */
63
+ async getNewClients(params?: DateRangeParams): Promise<NewClients> {
64
+ return this.client.get<NewClients>('/dashboard/new-clients', params);
65
+ }
66
+
67
+ /**
68
+ * Get expiring contracts within date range
24
69
  * @param limit Maximum number of contracts to return (default: 10)
25
- * @returns List of contracts expiring in the next 30 days
70
+ * @param params Optional date range parameters
71
+ * @returns List of contracts expiring in the specified period
26
72
  */
27
- async getExpiringContracts(limit: number = 10): Promise<ExpiringContract[]> {
28
- return this.client.get<ExpiringContract[]>('/dashboard/expiring-contracts', { limit });
73
+ async getExpiringContracts(
74
+ limit: number = 10,
75
+ params?: DateRangeParams,
76
+ ): Promise<ExpiringContract[]> {
77
+ return this.client.get<ExpiringContract[]>('/dashboard/expiring-contracts', {
78
+ limit,
79
+ ...params,
80
+ });
29
81
  }
30
82
  }
@@ -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
  }
@@ -17,4 +17,6 @@ export * from './onboarding';
17
17
  export * from './products';
18
18
  export * from './sales';
19
19
  export * from './suppliers';
20
- export * from './users';
20
+ export * from './users';
21
+ export * from './subscriptions';
22
+ export * from './payment-methods';
@@ -0,0 +1,48 @@
1
+ import { BaseResource } from './base';
2
+ import {
3
+ PaymentMethod,
4
+ CreatePaymentMethodDto,
5
+ UpdatePaymentMethodDto,
6
+ SearchPaymentMethodsParams,
7
+ PaymentMethodStats
8
+ } from '../models/payment-methods';
9
+ import { RequestOptions, PaginatedResponseDto } from '../types';
10
+
11
+ export class PaymentMethodsResource extends BaseResource {
12
+ private basePath = 'payment-methods';
13
+
14
+ async createPaymentMethod(data: CreatePaymentMethodDto, options?: RequestOptions): Promise<PaymentMethod> {
15
+ return this.client.post<PaymentMethod>(this.basePath, data, options);
16
+ }
17
+
18
+ async searchPaymentMethods(
19
+ params?: SearchPaymentMethodsParams,
20
+ options?: RequestOptions
21
+ ): Promise<PaginatedResponseDto<PaymentMethod>> {
22
+ return this.paginate<PaymentMethod>(this.basePath, params, options);
23
+ }
24
+
25
+ async getPaymentMethod(id: string, options?: RequestOptions): Promise<PaymentMethod> {
26
+ return this.client.get<PaymentMethod>(`${this.basePath}/${id}`, undefined, options);
27
+ }
28
+
29
+ async updatePaymentMethod(
30
+ id: string,
31
+ data: UpdatePaymentMethodDto,
32
+ options?: RequestOptions
33
+ ): Promise<PaymentMethod> {
34
+ return this.client.put<PaymentMethod>(`${this.basePath}/${id}`, data, options);
35
+ }
36
+
37
+ async deletePaymentMethod(id: string, options?: RequestOptions): Promise<void> {
38
+ return this.client.delete<void>(`${this.basePath}/${id}`, options);
39
+ }
40
+
41
+ async togglePaymentMethod(id: string, options?: RequestOptions): Promise<PaymentMethod> {
42
+ return this.client.put<PaymentMethod>(`${this.basePath}/${id}/toggle`, undefined, options);
43
+ }
44
+
45
+ async getPaymentMethodStats(options?: RequestOptions): Promise<PaymentMethodStats> {
46
+ return this.client.get<PaymentMethodStats>(`${this.basePath}/stats`, undefined, options);
47
+ }
48
+ }
@@ -2,7 +2,9 @@ import { BaseResource } from './base';
2
2
  import {
3
3
  Product,
4
4
  ProductCategory,
5
+ StockMovement,
5
6
  CreateProductDto,
7
+ CreateServiceDto,
6
8
  UpdateProductDto,
7
9
  UpdateStockDto,
8
10
  CreateProductCategoryDto,
@@ -43,6 +45,10 @@ export class ProductsResource extends BaseResource {
43
45
  return this.client.post<Product>(this.basePath, data, options);
44
46
  }
45
47
 
48
+ async createService(data: CreateServiceDto, options?: RequestOptions): Promise<Product> {
49
+ return this.client.post<Product>(`${this.basePath}/services`, data, options);
50
+ }
51
+
46
52
  async searchProducts(
47
53
  params?: SearchProductsParams,
48
54
  options?: RequestOptions
@@ -88,4 +94,11 @@ export class ProductsResource extends BaseResource {
88
94
  options
89
95
  );
90
96
  }
97
+
98
+ async getProductStockMovements(
99
+ id: string,
100
+ options?: RequestOptions
101
+ ): Promise<StockMovement[]> {
102
+ return this.client.get<StockMovement[]>(`${this.basePath}/${id}/stock-movements`, undefined, options);
103
+ }
91
104
  }
@@ -6,7 +6,8 @@ import {
6
6
  UpdatePaymentStatusDto,
7
7
  SearchSalesParams,
8
8
  SalesStats,
9
- TopSellingProduct
9
+ TopSellingProduct,
10
+ CustomerSalesReport
10
11
  } from '../models/sales';
11
12
  import { RequestOptions, PaginatedResponseDto } from '../types';
12
13
 
@@ -38,10 +39,10 @@ export class SalesResource extends BaseResource {
38
39
 
39
40
  async updatePaymentStatus(
40
41
  id: string,
41
- data: UpdatePaymentStatusDto,
42
+ paymentStatus: 'paid' | 'unpaid',
42
43
  options?: RequestOptions
43
44
  ): Promise<Sale> {
44
- return this.client.put<Sale>(`${this.basePath}/${id}/payment-status`, data, options);
45
+ return this.client.put<Sale>(`${this.basePath}/${id}/payment-status`, { paymentStatus }, options);
45
46
  }
46
47
 
47
48
  async deleteSale(id: string, options?: RequestOptions): Promise<void> {
@@ -80,4 +81,20 @@ export class SalesResource extends BaseResource {
80
81
  options
81
82
  );
82
83
  }
84
+
85
+ async getSalesByCustomer(
86
+ startDate?: string,
87
+ endDate?: string,
88
+ options?: RequestOptions
89
+ ): Promise<CustomerSalesReport> {
90
+ const params: Record<string, string> = {};
91
+ if (startDate) params.startDate = startDate;
92
+ if (endDate) params.endDate = endDate;
93
+
94
+ return this.client.get<CustomerSalesReport>(
95
+ `${this.basePath}/reports/by-customer`,
96
+ Object.keys(params).length > 0 ? params : undefined,
97
+ options
98
+ );
99
+ }
83
100
  }
@@ -0,0 +1,65 @@
1
+ import {
2
+ AvailablePlanDto,
3
+ SubscriptionStatusDto,
4
+ AffiliateOrganizationDto,
5
+ CheckLimitResponse,
6
+ } from '../models/subscriptions';
7
+ import { RequestOptions } from '../types';
8
+ import { BaseResource } from './base';
9
+
10
+ export class SubscriptionsResource extends BaseResource {
11
+ private basePath = 'subscriptions';
12
+
13
+ /**
14
+ * Get available subscription plans (currently only free plans)
15
+ */
16
+ async getAvailablePlans(options?: RequestOptions): Promise<AvailablePlanDto[]> {
17
+ return this.client.get<AvailablePlanDto[]>(`${this.basePath}/plans`, undefined, options);
18
+ }
19
+
20
+ /**
21
+ * Get subscription status for an organization
22
+ */
23
+ async getSubscriptionStatus(
24
+ organizationId: string,
25
+ options?: RequestOptions,
26
+ ): Promise<SubscriptionStatusDto> {
27
+ return this.client.get<SubscriptionStatusDto>(
28
+ `${this.basePath}/organizations/${organizationId}/status`,
29
+ undefined,
30
+ options,
31
+ );
32
+ }
33
+
34
+ /**
35
+ * Affiliate organization to a subscription plan
36
+ */
37
+ async affiliateOrganization(
38
+ organizationId: string,
39
+ data: AffiliateOrganizationDto,
40
+ options?: RequestOptions,
41
+ ): Promise<SubscriptionStatusDto> {
42
+ return this.client.post<SubscriptionStatusDto>(
43
+ `${this.basePath}/organizations/${organizationId}/affiliate`,
44
+ data,
45
+ options,
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Check subscription limits
51
+ * @param organizationId Organization ID
52
+ * @param limitType Type of limit to check: 'gyms', 'clients', or 'users'
53
+ */
54
+ async checkSubscriptionLimit(
55
+ organizationId: string,
56
+ limitType: 'gyms' | 'clients' | 'users',
57
+ options?: RequestOptions,
58
+ ): Promise<CheckLimitResponse> {
59
+ return this.client.get<CheckLimitResponse>(
60
+ `${this.basePath}/organizations/${organizationId}/limits/${limitType}`,
61
+ undefined,
62
+ options,
63
+ );
64
+ }
65
+ }
package/src/sdk.ts CHANGED
@@ -21,6 +21,8 @@ import {
21
21
  SalesResource,
22
22
  SuppliersResource,
23
23
  UsersResource,
24
+ SubscriptionsResource,
25
+ PaymentMethodsResource,
24
26
  } from './resources';
25
27
 
26
28
  export class GymSpaceSdk {
@@ -47,6 +49,8 @@ export class GymSpaceSdk {
47
49
  public sales: SalesResource;
48
50
  public suppliers: SuppliersResource;
49
51
  public users: UsersResource;
52
+ public subscriptions: SubscriptionsResource;
53
+ public paymentMethods: PaymentMethodsResource;
50
54
 
51
55
  constructor(config: GymSpaceConfig) {
52
56
  this.client = new ApiClient(config);
@@ -72,6 +76,8 @@ export class GymSpaceSdk {
72
76
  this.sales = new SalesResource(this.client);
73
77
  this.suppliers = new SuppliersResource(this.client);
74
78
  this.users = new UsersResource(this.client);
79
+ this.subscriptions = new SubscriptionsResource(this.client);
80
+ this.paymentMethods = new PaymentMethodsResource(this.client);
75
81
  }
76
82
 
77
83
  /**
@@ -81,6 +87,13 @@ export class GymSpaceSdk {
81
87
  this.client.setAuthToken(token);
82
88
  }
83
89
 
90
+ /**
91
+ * Set both access and refresh tokens
92
+ */
93
+ setTokens(accessToken: string, refreshToken: string): void {
94
+ this.client.setTokens(accessToken, refreshToken);
95
+ }
96
+
84
97
  /**
85
98
  * Set the current gym context
86
99
  */