@gymspace/sdk 1.2.14 → 1.2.16

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,69 @@
1
+ import { BaseResource } from './base';
2
+ import {
3
+ ReportFiltersDto,
4
+ CommissionSummaryReportDto,
5
+ RuleReportDto,
6
+ CollaboratorReportDto,
7
+ PromotionReportDto,
8
+ PromotionReportFiltersDto,
9
+ } from '../models/commissions';
10
+ import { RequestOptions } from '../types';
11
+
12
+ export class CommissionReportsResource extends BaseResource {
13
+ private basePath = 'commissions/reports';
14
+
15
+ async getSummary(
16
+ params?: ReportFiltersDto,
17
+ options?: RequestOptions,
18
+ ): Promise<CommissionSummaryReportDto> {
19
+ return this.client.get<CommissionSummaryReportDto>(`${this.basePath}/summary`, params, options);
20
+ }
21
+
22
+ async getByRule(params?: ReportFiltersDto, options?: RequestOptions): Promise<RuleReportDto[]> {
23
+ return this.client.get<RuleReportDto[]>(`${this.basePath}/by-rule`, params, options);
24
+ }
25
+
26
+ async getByCollaborator(
27
+ params?: ReportFiltersDto,
28
+ options?: RequestOptions,
29
+ ): Promise<CollaboratorReportDto[]> {
30
+ return this.client.get<CollaboratorReportDto[]>(
31
+ `${this.basePath}/by-collaborator`,
32
+ params,
33
+ options,
34
+ );
35
+ }
36
+
37
+ async getPromotionAnalytics(
38
+ params?: PromotionReportFiltersDto,
39
+ options?: RequestOptions,
40
+ ): Promise<PromotionReportDto[]> {
41
+ return this.client.get<PromotionReportDto[]>(`${this.basePath}/promotions`, params, options);
42
+ }
43
+
44
+ async exportToCSV(params?: ReportFiltersDto, options?: RequestOptions): Promise<Blob> {
45
+ return this.client.get<Blob>(`${this.basePath}/export/csv`, params, options);
46
+ }
47
+
48
+ async getTrends(
49
+ params?: ReportFiltersDto,
50
+ options?: RequestOptions,
51
+ ): Promise<{ date: string; commissions: number; contracts: number }[]> {
52
+ return this.client.get<{ date: string; commissions: number; contracts: number }[]>(
53
+ `${this.basePath}/trends`,
54
+ params,
55
+ options,
56
+ );
57
+ }
58
+
59
+ async getTopPerformers(
60
+ params?: ReportFiltersDto & { limit?: number },
61
+ options?: RequestOptions,
62
+ ): Promise<CollaboratorReportDto[]> {
63
+ return this.client.get<CollaboratorReportDto[]>(
64
+ `${this.basePath}/top-performers`,
65
+ params,
66
+ options,
67
+ );
68
+ }
69
+ }
@@ -0,0 +1,91 @@
1
+ import { BaseResource } from './base';
2
+ import {
3
+ CommissionRuleDto,
4
+ CreateCommissionRuleDto,
5
+ UpdateCommissionRuleDto,
6
+ CommissionRuleFiltersDto,
7
+ CommissionHistoryDto,
8
+ CommissionHistoryFiltersDto,
9
+ } from '../models/commissions';
10
+ import { RequestOptions, PaginatedResponseDto } from '../types';
11
+
12
+ export class CommissionRulesResource extends BaseResource {
13
+ private basePath = 'commissions/rules';
14
+
15
+ async createRule(
16
+ data: CreateCommissionRuleDto,
17
+ options?: RequestOptions,
18
+ ): Promise<CommissionRuleDto> {
19
+ return this.client.post<CommissionRuleDto>(this.basePath, data, options);
20
+ }
21
+
22
+ async getRule(id: string, options?: RequestOptions): Promise<CommissionRuleDto> {
23
+ return this.client.get<CommissionRuleDto>(`${this.basePath}/${id}`, undefined, options);
24
+ }
25
+
26
+ async listRules(
27
+ params?: CommissionRuleFiltersDto,
28
+ options?: RequestOptions,
29
+ ): Promise<PaginatedResponseDto<CommissionRuleDto>> {
30
+ return this.paginate<CommissionRuleDto>(this.basePath, params, options);
31
+ }
32
+
33
+ async updateRule(
34
+ id: string,
35
+ data: UpdateCommissionRuleDto,
36
+ options?: RequestOptions,
37
+ ): Promise<CommissionRuleDto> {
38
+ return this.client.put<CommissionRuleDto>(`${this.basePath}/${id}`, data, options);
39
+ }
40
+
41
+ async deleteRule(id: string, options?: RequestOptions): Promise<{ success: boolean }> {
42
+ return this.client.delete<{ success: boolean }>(`${this.basePath}/${id}`, options);
43
+ }
44
+
45
+ async activateRule(id: string, options?: RequestOptions): Promise<CommissionRuleDto> {
46
+ return this.client.put<CommissionRuleDto>(`${this.basePath}/${id}/activate`, {}, options);
47
+ }
48
+
49
+ async deactivateRule(id: string, options?: RequestOptions): Promise<CommissionRuleDto> {
50
+ return this.client.put<CommissionRuleDto>(`${this.basePath}/${id}/deactivate`, {}, options);
51
+ }
52
+
53
+ async getRuleHistory(
54
+ id: string,
55
+ params?: CommissionHistoryFiltersDto,
56
+ options?: RequestOptions,
57
+ ): Promise<PaginatedResponseDto<CommissionHistoryDto>> {
58
+ return this.paginate<CommissionHistoryDto>(`${this.basePath}/${id}/history`, params, options);
59
+ }
60
+
61
+ async validateRule(
62
+ data: CreateCommissionRuleDto,
63
+ options?: RequestOptions,
64
+ ): Promise<{ valid: boolean; errors?: string[]; conflicts?: CommissionRuleDto[] }> {
65
+ return this.client.post<{ valid: boolean; errors?: string[]; conflicts?: CommissionRuleDto[] }>(
66
+ `${this.basePath}/validate`,
67
+ data,
68
+ options,
69
+ );
70
+ }
71
+
72
+ async getMyRules(options?: RequestOptions): Promise<CommissionRuleDto[]> {
73
+ return this.client.get<CommissionRuleDto[]>(`${this.basePath}/me`, undefined, options);
74
+ }
75
+
76
+ async getApplicableRule(
77
+ params: {
78
+ collaboratorId: string;
79
+ planId?: string;
80
+ amount?: number;
81
+ promotionId?: string;
82
+ },
83
+ options?: RequestOptions,
84
+ ): Promise<CommissionRuleDto | null> {
85
+ return this.client.get<CommissionRuleDto | null>(
86
+ `${this.basePath}/applicable`,
87
+ params,
88
+ options,
89
+ );
90
+ }
91
+ }
@@ -27,3 +27,8 @@ export * from './whatsapp-templates';
27
27
  export * from './bulk-messaging';
28
28
  export * from './activities';
29
29
  export * from './tags';
30
+ export * from './commission-config';
31
+ export * from './commission-rules';
32
+ export * from './commission-calculations';
33
+ export * from './commission-reports';
34
+ export * from './commission-promotions';
package/src/sdk.ts CHANGED
@@ -31,6 +31,11 @@ import {
31
31
  BulkMessagingResource,
32
32
  ActivitiesResource,
33
33
  TagsResource,
34
+ CommissionConfigResource,
35
+ CommissionRulesResource,
36
+ CommissionCalculationsResource,
37
+ CommissionReportsResource,
38
+ CommissionPromotionsResource,
34
39
  } from './resources';
35
40
 
36
41
  export class GymSpaceSdk {
@@ -67,6 +72,11 @@ export class GymSpaceSdk {
67
72
  public bulkMessaging: BulkMessagingResource;
68
73
  public activities: ActivitiesResource;
69
74
  public tags: TagsResource;
75
+ public commissionConfig: CommissionConfigResource;
76
+ public commissionRules: CommissionRulesResource;
77
+ public commissionCalculations: CommissionCalculationsResource;
78
+ public commissionReports: CommissionReportsResource;
79
+ public commissionPromotions: CommissionPromotionsResource;
70
80
 
71
81
  constructor(config: GymSpaceConfig) {
72
82
  this.client = new ApiClient(config);
@@ -101,6 +111,11 @@ export class GymSpaceSdk {
101
111
  this.bulkMessaging = new BulkMessagingResource(this.client);
102
112
  this.activities = new ActivitiesResource(this.client);
103
113
  this.tags = new TagsResource(this.client);
114
+ this.commissionConfig = new CommissionConfigResource(this.client);
115
+ this.commissionRules = new CommissionRulesResource(this.client);
116
+ this.commissionCalculations = new CommissionCalculationsResource(this.client);
117
+ this.commissionReports = new CommissionReportsResource(this.client);
118
+ this.commissionPromotions = new CommissionPromotionsResource(this.client);
104
119
  }
105
120
 
106
121
  /**