@gymspace/sdk 1.2.0 → 1.2.1

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.0",
3
+ "version": "1.2.1",
4
4
  "description": "GymSpace TypeScript SDK for API integration",
5
5
  "author": "GymSpace Team",
6
6
  "license": "MIT",
@@ -0,0 +1,8 @@
1
+ // Re-export from resources to maintain consistency
2
+ export type {
3
+ AdminSubscriptionStatusDto,
4
+ ActivateRenewalDto,
5
+ CancelSubscriptionDto,
6
+ UpgradeSubscriptionDto,
7
+ SubscriptionHistoryDto,
8
+ } from '../resources/admin-subscription-management';
@@ -18,6 +18,8 @@ export * from './sales';
18
18
  export * from './suppliers';
19
19
  export * from './users';
20
20
  export * from './subscriptions';
21
+ export * from './subscription-plans';
22
+ export * from './admin-subscription-management';
21
23
  export * from './payment-methods';
22
24
 
23
25
  export interface ApiResponse<T> {
@@ -34,5 +34,51 @@ export interface OrganizationWithDetails {
34
34
  name: string;
35
35
  address: string;
36
36
  }>;
37
+ subscription?: {
38
+ planName: string;
39
+ status: string; // Should match SubscriptionStatus enum
40
+ startDate: Date;
41
+ endDate: Date;
42
+ isExpired: boolean;
43
+ };
44
+ createdAt: Date;
45
+ }
46
+
47
+ export interface OrganizationAdminDetails {
48
+ id: string;
49
+ name: string;
50
+ country?: string;
51
+ currency?: string;
52
+ timezone?: string;
53
+ settings?: Record<string, any>;
54
+ owner: {
55
+ id: string;
56
+ email: string;
57
+ fullName: string;
58
+ };
59
+ gyms: Array<{
60
+ id: string;
61
+ name: string;
62
+ address: string;
63
+ }>;
64
+ subscription?: {
65
+ id: string;
66
+ planName: string;
67
+ status: string; // Should match SubscriptionStatus enum
68
+ startDate: Date;
69
+ endDate: Date;
70
+ isActive: boolean;
71
+ isExpired: boolean;
72
+ daysRemaining: number;
73
+ metadata?: Record<string, any>;
74
+ };
75
+ stats: {
76
+ totalGyms: number;
77
+ totalClients: number;
78
+ totalContracts: number;
79
+ activeContracts: number;
80
+ totalRevenue: number;
81
+ };
37
82
  createdAt: Date;
83
+ updatedAt: Date;
38
84
  }
@@ -0,0 +1,8 @@
1
+ // Re-export from resources to maintain consistency
2
+ export type {
3
+ SubscriptionPlanDto,
4
+ PriceDto,
5
+ PricingDto,
6
+ CreateSubscriptionPlanDto,
7
+ UpdateSubscriptionPlanDto,
8
+ } from '../resources/subscription-plans';
@@ -0,0 +1,116 @@
1
+ import { BaseResource } from './base';
2
+ import { RequestOptions } from '../types';
3
+
4
+ // Import types from existing subscriptions model and add new ones
5
+ export interface AdminSubscriptionStatusDto {
6
+ id: string;
7
+ organizationId: string;
8
+ subscriptionPlanId: string;
9
+ planName: string;
10
+ status: string; // Should match SubscriptionStatus enum
11
+ startDate: Date;
12
+ endDate: Date;
13
+ isActive: boolean;
14
+ isExpired: boolean;
15
+ daysRemaining: number;
16
+ metadata?: Record<string, any>;
17
+ createdAt: Date;
18
+ updatedAt: Date;
19
+ }
20
+
21
+ export interface ActivateRenewalDto {
22
+ subscriptionPlanId?: string;
23
+ durationMonths?: number;
24
+ notes?: string;
25
+ }
26
+
27
+ export interface CancelSubscriptionDto {
28
+ reason: string;
29
+ immediateTermination?: boolean;
30
+ notes?: string;
31
+ }
32
+
33
+ export interface UpgradeSubscriptionDto {
34
+ newSubscriptionPlanId: string;
35
+ immediateUpgrade?: boolean;
36
+ notes?: string;
37
+ }
38
+
39
+ export interface SubscriptionHistoryDto {
40
+ id: string;
41
+ planName: string;
42
+ status: string; // Should match SubscriptionStatus enum
43
+ startDate: Date;
44
+ endDate: Date;
45
+ isActive: boolean;
46
+ metadata?: Record<string, any>;
47
+ createdBy: {
48
+ id: string;
49
+ name: string;
50
+ email: string;
51
+ };
52
+ createdAt: Date;
53
+ }
54
+
55
+ export class AdminSubscriptionManagementResource extends BaseResource {
56
+ private basePath = 'admin/organizations';
57
+
58
+ /**
59
+ * Activate subscription renewal for an organization (Super Admin only)
60
+ */
61
+ async activateRenewal(
62
+ organizationId: string,
63
+ data: ActivateRenewalDto,
64
+ options?: RequestOptions,
65
+ ): Promise<AdminSubscriptionStatusDto> {
66
+ return this.client.post<AdminSubscriptionStatusDto>(
67
+ `${this.basePath}/${organizationId}/subscriptions/activate-renewal`,
68
+ data,
69
+ options,
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Cancel subscription for an organization (Super Admin only)
75
+ */
76
+ async cancelSubscription(
77
+ organizationId: string,
78
+ data: CancelSubscriptionDto,
79
+ options?: RequestOptions,
80
+ ): Promise<AdminSubscriptionStatusDto> {
81
+ return this.client.post<AdminSubscriptionStatusDto>(
82
+ `${this.basePath}/${organizationId}/subscriptions/cancel`,
83
+ data,
84
+ options,
85
+ );
86
+ }
87
+
88
+ /**
89
+ * Upgrade subscription plan for an organization (Super Admin only)
90
+ */
91
+ async upgradeSubscription(
92
+ organizationId: string,
93
+ data: UpgradeSubscriptionDto,
94
+ options?: RequestOptions,
95
+ ): Promise<AdminSubscriptionStatusDto> {
96
+ return this.client.post<AdminSubscriptionStatusDto>(
97
+ `${this.basePath}/${organizationId}/subscriptions/upgrade`,
98
+ data,
99
+ options,
100
+ );
101
+ }
102
+
103
+ /**
104
+ * Get subscription history for an organization (Super Admin only)
105
+ */
106
+ async getSubscriptionHistory(
107
+ organizationId: string,
108
+ options?: RequestOptions,
109
+ ): Promise<SubscriptionHistoryDto[]> {
110
+ return this.client.get<SubscriptionHistoryDto[]>(
111
+ `${this.basePath}/${organizationId}/subscriptions/history`,
112
+ undefined,
113
+ options,
114
+ );
115
+ }
116
+ }
@@ -19,4 +19,6 @@ export * from './sales';
19
19
  export * from './suppliers';
20
20
  export * from './users';
21
21
  export * from './subscriptions';
22
+ export * from './subscription-plans';
23
+ export * from './admin-subscription-management';
22
24
  export * from './payment-methods';
@@ -1,5 +1,5 @@
1
1
  import { BaseResource } from './base';
2
- import { Organization, UpdateOrganizationDto, OrganizationStats, OrganizationWithDetails } from '../models/organizations';
2
+ import { Organization, UpdateOrganizationDto, OrganizationStats, OrganizationWithDetails, OrganizationAdminDetails } from '../models/organizations';
3
3
  import { RequestOptions } from '../types';
4
4
 
5
5
  export class OrganizationsResource extends BaseResource {
@@ -24,4 +24,8 @@ export class OrganizationsResource extends BaseResource {
24
24
  async listOrganizations(options?: RequestOptions): Promise<OrganizationWithDetails[]> {
25
25
  return this.client.get<OrganizationWithDetails[]>(`${this.basePath}/list`, undefined, options);
26
26
  }
27
+
28
+ async getOrganizationForAdmin(id: string, options?: RequestOptions): Promise<OrganizationAdminDetails> {
29
+ return this.client.get<OrganizationAdminDetails>(`${this.basePath}/admin/${id}`, undefined, options);
30
+ }
27
31
  }
@@ -0,0 +1,110 @@
1
+ import { BaseResource } from './base';
2
+ import { RequestOptions } from '../types';
3
+
4
+ // Import the types we'll define
5
+ export interface SubscriptionPlanDto {
6
+ id: string;
7
+ name: string;
8
+ price: {
9
+ PEN?: { currency: 'PEN'; value: number };
10
+ USD?: { currency: 'USD'; value: number };
11
+ COP?: { currency: 'COP'; value: number };
12
+ MXN?: { currency: 'MXN'; value: number };
13
+ };
14
+ billingFrequency: string;
15
+ duration?: number;
16
+ durationPeriod?: string;
17
+ maxGyms: number;
18
+ maxClientsPerGym: number;
19
+ maxUsersPerGym: number;
20
+ features: Record<string, any>;
21
+ description?: string;
22
+ isActive: boolean;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ activeSubscriptions?: number;
26
+ totalOrganizations?: number;
27
+ }
28
+
29
+ export interface PriceDto {
30
+ currency: string;
31
+ value: number;
32
+ }
33
+
34
+ export interface PricingDto {
35
+ PEN: PriceDto;
36
+ }
37
+
38
+ export interface CreateSubscriptionPlanDto {
39
+ name: string;
40
+ price: PricingDto;
41
+ billingFrequency: string;
42
+ duration?: number;
43
+ durationPeriod?: 'DAY' | 'MONTH';
44
+ maxGyms: number;
45
+ maxClientsPerGym: number;
46
+ maxUsersPerGym: number;
47
+ features: Record<string, any>;
48
+ description?: string;
49
+ isActive?: boolean;
50
+ }
51
+
52
+ export interface UpdateSubscriptionPlanDto {
53
+ name?: string;
54
+ price?: PricingDto;
55
+ billingFrequency?: string;
56
+ duration?: number;
57
+ durationPeriod?: 'DAY' | 'MONTH';
58
+ maxGyms?: number;
59
+ maxClientsPerGym?: number;
60
+ maxUsersPerGym?: number;
61
+ features?: Record<string, any>;
62
+ description?: string;
63
+ isActive?: boolean;
64
+ }
65
+
66
+ export class SubscriptionPlansResource extends BaseResource {
67
+ private basePath = 'admin/subscription-plans';
68
+
69
+ /**
70
+ * List all subscription plans (Super Admin only)
71
+ */
72
+ async listPlans(options?: RequestOptions): Promise<SubscriptionPlanDto[]> {
73
+ return this.client.get<SubscriptionPlanDto[]>(`${this.basePath}`, undefined, options);
74
+ }
75
+
76
+ /**
77
+ * Create new subscription plan (Super Admin only)
78
+ */
79
+ async createPlan(
80
+ data: CreateSubscriptionPlanDto,
81
+ options?: RequestOptions,
82
+ ): Promise<SubscriptionPlanDto> {
83
+ return this.client.post<SubscriptionPlanDto>(`${this.basePath}`, data, options);
84
+ }
85
+
86
+ /**
87
+ * Get subscription plan details (Super Admin only)
88
+ */
89
+ async getPlan(id: string, options?: RequestOptions): Promise<SubscriptionPlanDto> {
90
+ return this.client.get<SubscriptionPlanDto>(`${this.basePath}/${id}`, undefined, options);
91
+ }
92
+
93
+ /**
94
+ * Update subscription plan (Super Admin only)
95
+ */
96
+ async updatePlan(
97
+ id: string,
98
+ data: UpdateSubscriptionPlanDto,
99
+ options?: RequestOptions,
100
+ ): Promise<SubscriptionPlanDto> {
101
+ return this.client.put<SubscriptionPlanDto>(`${this.basePath}/${id}`, data, options);
102
+ }
103
+
104
+ /**
105
+ * Soft delete subscription plan (Super Admin only)
106
+ */
107
+ async deletePlan(id: string, options?: RequestOptions): Promise<{ success: boolean }> {
108
+ return this.client.delete<{ success: boolean }>(`${this.basePath}/${id}`, options);
109
+ }
110
+ }
package/src/sdk.ts CHANGED
@@ -22,6 +22,8 @@ import {
22
22
  SuppliersResource,
23
23
  UsersResource,
24
24
  SubscriptionsResource,
25
+ SubscriptionPlansResource,
26
+ AdminSubscriptionManagementResource,
25
27
  PaymentMethodsResource,
26
28
  } from './resources';
27
29
 
@@ -50,6 +52,8 @@ export class GymSpaceSdk {
50
52
  public suppliers: SuppliersResource;
51
53
  public users: UsersResource;
52
54
  public subscriptions: SubscriptionsResource;
55
+ public subscriptionPlans: SubscriptionPlansResource;
56
+ public adminSubscriptionManagement: AdminSubscriptionManagementResource;
53
57
  public paymentMethods: PaymentMethodsResource;
54
58
 
55
59
  constructor(config: GymSpaceConfig) {
@@ -77,6 +81,8 @@ export class GymSpaceSdk {
77
81
  this.suppliers = new SuppliersResource(this.client);
78
82
  this.users = new UsersResource(this.client);
79
83
  this.subscriptions = new SubscriptionsResource(this.client);
84
+ this.subscriptionPlans = new SubscriptionPlansResource(this.client);
85
+ this.adminSubscriptionManagement = new AdminSubscriptionManagementResource(this.client);
80
86
  this.paymentMethods = new PaymentMethodsResource(this.client);
81
87
  }
82
88