@codeguide/core 0.0.6 → 0.0.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/README.md +503 -0
- package/codeguide.ts +6 -0
- package/dist/codeguide.d.ts +2 -1
- package/dist/codeguide.js +1 -0
- package/dist/services/api-key-enhanced/api-key-enhanced-service.d.ts +15 -12
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +4 -1
- package/dist/services/subscriptions/index.d.ts +1 -0
- package/dist/services/subscriptions/index.js +5 -0
- package/dist/services/subscriptions/subscription-service.d.ts +103 -0
- package/dist/services/subscriptions/subscription-service.js +73 -0
- package/dist/types.d.ts +94 -14
- package/package.json +1 -1
- package/services/cancellation-funnel/cancellation-funnel-service.ts +239 -0
- package/services/cancellation-funnel/index.ts +1 -0
- package/services/index.ts +4 -0
- package/services/subscriptions/index.ts +1 -0
- package/services/subscriptions/subscription-service.ts +147 -0
- package/types.ts +132 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service';
|
|
2
|
+
import { CurrentSubscriptionResponse, UserSubscriptionsResponse, CancelSubscriptionRequest, CancelSubscriptionResponse } from '../../types';
|
|
3
|
+
export declare class SubscriptionService extends BaseService {
|
|
4
|
+
constructor(config: any);
|
|
5
|
+
/**
|
|
6
|
+
* Get the currently active subscription for the authenticated user
|
|
7
|
+
* GET /subscriptions/current
|
|
8
|
+
*/
|
|
9
|
+
getCurrentSubscription(): Promise<CurrentSubscriptionResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Get all subscriptions (active and historical) for the authenticated user
|
|
12
|
+
* GET /subscriptions/
|
|
13
|
+
*/
|
|
14
|
+
getAllSubscriptions(): Promise<UserSubscriptionsResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Cancel subscription but keep it active until the end of the current billing period
|
|
17
|
+
* POST /subscriptions/{subscription_id}/cancel
|
|
18
|
+
*/
|
|
19
|
+
cancelSubscription(subscriptionId: string, request: CancelSubscriptionRequest): Promise<CancelSubscriptionResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Get subscription details by ID
|
|
22
|
+
* GET /subscriptions/{subscription_id}
|
|
23
|
+
*/
|
|
24
|
+
getSubscriptionById(subscriptionId: string): Promise<{
|
|
25
|
+
status: string;
|
|
26
|
+
data: {
|
|
27
|
+
subscription: any;
|
|
28
|
+
product: any;
|
|
29
|
+
price: any;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Reactivate a canceled subscription (if supported by API)
|
|
34
|
+
* POST /subscriptions/{subscription_id}/reactivate
|
|
35
|
+
*/
|
|
36
|
+
reactivateSubscription(subscriptionId: string): Promise<{
|
|
37
|
+
status: string;
|
|
38
|
+
message: string;
|
|
39
|
+
data: any;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Update subscription quantity or other parameters
|
|
43
|
+
* PUT /subscriptions/{subscription_id}
|
|
44
|
+
*/
|
|
45
|
+
updateSubscription(subscriptionId: string, updates: {
|
|
46
|
+
quantity?: number;
|
|
47
|
+
metadata?: Record<string, any>;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
status: string;
|
|
50
|
+
data: any;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Get subscription usage statistics (if supported by API)
|
|
54
|
+
* GET /subscriptions/{subscription_id}/usage
|
|
55
|
+
*/
|
|
56
|
+
getSubscriptionUsage(subscriptionId: string): Promise<{
|
|
57
|
+
status: string;
|
|
58
|
+
data: {
|
|
59
|
+
current_usage: number;
|
|
60
|
+
limit: number;
|
|
61
|
+
period_start: string;
|
|
62
|
+
period_end: string;
|
|
63
|
+
usage_breakdown?: Array<{
|
|
64
|
+
feature: string;
|
|
65
|
+
used: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
}>;
|
|
68
|
+
};
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Get upcoming invoice for subscription
|
|
72
|
+
* GET /subscriptions/{subscription_id}/upcoming-invoice
|
|
73
|
+
*/
|
|
74
|
+
getUpcomingInvoice(subscriptionId: string): Promise<{
|
|
75
|
+
status: string;
|
|
76
|
+
data: {
|
|
77
|
+
amount: number;
|
|
78
|
+
currency: string;
|
|
79
|
+
date: string;
|
|
80
|
+
line_items: Array<{
|
|
81
|
+
description: string;
|
|
82
|
+
amount: number;
|
|
83
|
+
currency: string;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Get subscription history and payments
|
|
89
|
+
* GET /subscriptions/{subscription_id}/history
|
|
90
|
+
*/
|
|
91
|
+
getSubscriptionHistory(subscriptionId: string): Promise<{
|
|
92
|
+
status: string;
|
|
93
|
+
data: Array<{
|
|
94
|
+
id: string;
|
|
95
|
+
type: 'payment' | 'invoice' | 'refund';
|
|
96
|
+
amount: number;
|
|
97
|
+
currency: string;
|
|
98
|
+
status: string;
|
|
99
|
+
created: string;
|
|
100
|
+
description?: string;
|
|
101
|
+
}>;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionService = void 0;
|
|
4
|
+
const base_service_1 = require("../base/base-service");
|
|
5
|
+
class SubscriptionService extends base_service_1.BaseService {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
super(config);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get the currently active subscription for the authenticated user
|
|
11
|
+
* GET /subscriptions/current
|
|
12
|
+
*/
|
|
13
|
+
async getCurrentSubscription() {
|
|
14
|
+
return this.get('/subscriptions/current');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get all subscriptions (active and historical) for the authenticated user
|
|
18
|
+
* GET /subscriptions/
|
|
19
|
+
*/
|
|
20
|
+
async getAllSubscriptions() {
|
|
21
|
+
return this.get('/subscriptions/');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Cancel subscription but keep it active until the end of the current billing period
|
|
25
|
+
* POST /subscriptions/{subscription_id}/cancel
|
|
26
|
+
*/
|
|
27
|
+
async cancelSubscription(subscriptionId, request) {
|
|
28
|
+
return this.post(`/subscriptions/${subscriptionId}/cancel`, request);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get subscription details by ID
|
|
32
|
+
* GET /subscriptions/{subscription_id}
|
|
33
|
+
*/
|
|
34
|
+
async getSubscriptionById(subscriptionId) {
|
|
35
|
+
return this.get(`/subscriptions/${subscriptionId}`);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reactivate a canceled subscription (if supported by API)
|
|
39
|
+
* POST /subscriptions/{subscription_id}/reactivate
|
|
40
|
+
*/
|
|
41
|
+
async reactivateSubscription(subscriptionId) {
|
|
42
|
+
return this.post(`/subscriptions/${subscriptionId}/reactivate`, {});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Update subscription quantity or other parameters
|
|
46
|
+
* PUT /subscriptions/{subscription_id}
|
|
47
|
+
*/
|
|
48
|
+
async updateSubscription(subscriptionId, updates) {
|
|
49
|
+
return this.put(`/subscriptions/${subscriptionId}`, updates);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get subscription usage statistics (if supported by API)
|
|
53
|
+
* GET /subscriptions/{subscription_id}/usage
|
|
54
|
+
*/
|
|
55
|
+
async getSubscriptionUsage(subscriptionId) {
|
|
56
|
+
return this.get(`/subscriptions/${subscriptionId}/usage`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get upcoming invoice for subscription
|
|
60
|
+
* GET /subscriptions/{subscription_id}/upcoming-invoice
|
|
61
|
+
*/
|
|
62
|
+
async getUpcomingInvoice(subscriptionId) {
|
|
63
|
+
return this.get(`/subscriptions/${subscriptionId}/upcoming-invoice`);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get subscription history and payments
|
|
67
|
+
* GET /subscriptions/{subscription_id}/history
|
|
68
|
+
*/
|
|
69
|
+
async getSubscriptionHistory(subscriptionId) {
|
|
70
|
+
return this.get(`/subscriptions/${subscriptionId}/history`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.SubscriptionService = SubscriptionService;
|
package/dist/types.d.ts
CHANGED
|
@@ -42,31 +42,111 @@ export interface CodeGuideOptions {
|
|
|
42
42
|
}
|
|
43
43
|
export interface ApiKey {
|
|
44
44
|
id: string;
|
|
45
|
+
key: string;
|
|
46
|
+
user_id: string;
|
|
45
47
|
name: string;
|
|
46
|
-
prefix: string;
|
|
47
48
|
created_at: string;
|
|
48
|
-
|
|
49
|
+
expires_at?: string;
|
|
49
50
|
is_active: boolean;
|
|
50
|
-
|
|
51
|
+
metadata?: Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
export interface ApiKeyListResponse {
|
|
54
|
+
status: string;
|
|
55
|
+
data: ApiKey[];
|
|
51
56
|
}
|
|
52
57
|
export interface CreateApiKeyRequest {
|
|
53
58
|
name: string;
|
|
54
59
|
}
|
|
55
60
|
export interface CreateApiKeyResponse {
|
|
56
|
-
|
|
61
|
+
status: string;
|
|
62
|
+
data: {
|
|
63
|
+
api_key: string;
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
created_at: string;
|
|
67
|
+
expires_at?: string;
|
|
68
|
+
is_active: boolean;
|
|
69
|
+
metadata?: Record<string, any>;
|
|
70
|
+
};
|
|
71
|
+
message?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ApiKeyPermissionResponse {
|
|
74
|
+
status: string;
|
|
75
|
+
data: {
|
|
76
|
+
can_create: boolean;
|
|
77
|
+
reason?: string;
|
|
78
|
+
current_keys_count?: number;
|
|
79
|
+
max_keys_allowed?: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface ApiKeyResponse {
|
|
83
|
+
status: string;
|
|
84
|
+
data: ApiKey;
|
|
85
|
+
}
|
|
86
|
+
export interface RevokeApiKeyResponse {
|
|
87
|
+
status: string;
|
|
88
|
+
message: string;
|
|
89
|
+
revoked_key_id?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface Subscription {
|
|
57
92
|
id: string;
|
|
93
|
+
user_id: string;
|
|
94
|
+
status: 'active' | 'canceled' | 'past_due' | 'unpaid' | 'trialing' | 'incomplete' | 'incomplete_expired';
|
|
95
|
+
metadata: Record<string, any>;
|
|
96
|
+
price_id: string;
|
|
97
|
+
quantity: number;
|
|
98
|
+
cancel_at_period_end: boolean;
|
|
99
|
+
created: string;
|
|
100
|
+
current_period_start: string;
|
|
101
|
+
current_period_end: string;
|
|
102
|
+
ended_at?: string | null;
|
|
103
|
+
cancel_at?: string | null;
|
|
104
|
+
canceled_at?: string | null;
|
|
105
|
+
trial_start?: string | null;
|
|
106
|
+
trial_end?: string | null;
|
|
107
|
+
org_id?: string | null;
|
|
108
|
+
}
|
|
109
|
+
export interface Product {
|
|
110
|
+
id: string;
|
|
111
|
+
active: boolean;
|
|
58
112
|
name: string;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
113
|
+
description: string;
|
|
114
|
+
image: string;
|
|
115
|
+
metadata: Record<string, any>;
|
|
116
|
+
marketing_features: string[];
|
|
117
|
+
live_mode: boolean;
|
|
118
|
+
is_team_plan: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface Price {
|
|
121
|
+
id: string;
|
|
122
|
+
product_id: string;
|
|
123
|
+
active: boolean;
|
|
124
|
+
description: string;
|
|
125
|
+
unit_amount: number;
|
|
126
|
+
currency: string;
|
|
127
|
+
type: 'recurring' | 'one_time';
|
|
128
|
+
interval: 'day' | 'week' | 'month' | 'year';
|
|
129
|
+
interval_count: number;
|
|
130
|
+
trial_period_days?: number | null;
|
|
131
|
+
metadata?: Record<string, any> | null;
|
|
62
132
|
}
|
|
63
|
-
export interface
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
133
|
+
export interface CurrentSubscriptionResponse {
|
|
134
|
+
status: string;
|
|
135
|
+
data: {
|
|
136
|
+
subscription: Subscription;
|
|
137
|
+
product: Product;
|
|
138
|
+
price: Price;
|
|
139
|
+
};
|
|
68
140
|
}
|
|
69
|
-
export interface
|
|
141
|
+
export interface UserSubscriptionsResponse {
|
|
142
|
+
status: string;
|
|
143
|
+
data: Subscription[];
|
|
144
|
+
}
|
|
145
|
+
export interface CancelSubscriptionRequest {
|
|
146
|
+
cancel_at_period_end: boolean;
|
|
147
|
+
}
|
|
148
|
+
export interface CancelSubscriptionResponse {
|
|
149
|
+
status: string;
|
|
70
150
|
message: string;
|
|
71
|
-
|
|
151
|
+
data: Subscription;
|
|
72
152
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { BaseService } from '../base/base-service'
|
|
2
|
+
import {
|
|
3
|
+
CancellationFunnelInitiateRequest,
|
|
4
|
+
CancellationFunnelInitiateResponse,
|
|
5
|
+
CancellationFunnelPauseOfferRequest,
|
|
6
|
+
CancellationFunnelPauseOfferResponse,
|
|
7
|
+
CancellationFunnelSurveyRequest,
|
|
8
|
+
CancellationFunnelSurveyResponse,
|
|
9
|
+
} from '../../types'
|
|
10
|
+
|
|
11
|
+
export class CancellationFunnelService extends BaseService {
|
|
12
|
+
constructor(config: any) {
|
|
13
|
+
super(config)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initiate Cancellation Flow
|
|
18
|
+
* POST /cancellation-funnel/initiate
|
|
19
|
+
*/
|
|
20
|
+
async initiateCancellation(
|
|
21
|
+
request: CancellationFunnelInitiateRequest
|
|
22
|
+
): Promise<CancellationFunnelInitiateResponse> {
|
|
23
|
+
return this.post<CancellationFunnelInitiateResponse>(
|
|
24
|
+
'/cancellation-funnel/initiate',
|
|
25
|
+
request
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Log Pause Offer Response
|
|
31
|
+
* POST /cancellation-funnel/pause-offer
|
|
32
|
+
*/
|
|
33
|
+
async logPauseOfferResponse(
|
|
34
|
+
request: CancellationFunnelPauseOfferRequest
|
|
35
|
+
): Promise<CancellationFunnelPauseOfferResponse> {
|
|
36
|
+
return this.post<CancellationFunnelPauseOfferResponse>(
|
|
37
|
+
'/cancellation-funnel/pause-offer',
|
|
38
|
+
request
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Log Survey Response
|
|
44
|
+
* POST /cancellation-funnel/survey
|
|
45
|
+
*/
|
|
46
|
+
async logSurveyResponse(
|
|
47
|
+
request: CancellationFunnelSurveyRequest
|
|
48
|
+
): Promise<CancellationFunnelSurveyResponse> {
|
|
49
|
+
return this.post<CancellationFunnelSurveyResponse>(
|
|
50
|
+
'/cancellation-funnel/survey',
|
|
51
|
+
request
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get Cancellation Funnel Status
|
|
57
|
+
* GET /cancellation-funnel/{subscription_id}/status
|
|
58
|
+
*/
|
|
59
|
+
async getCancellationFunnelStatus(
|
|
60
|
+
subscriptionId: string
|
|
61
|
+
): Promise<{
|
|
62
|
+
status: string
|
|
63
|
+
data: {
|
|
64
|
+
funnel_id: string
|
|
65
|
+
subscription_id: string
|
|
66
|
+
current_step: string
|
|
67
|
+
initiated_at: string
|
|
68
|
+
pause_offer_response?: {
|
|
69
|
+
action: 'accepted' | 'declined'
|
|
70
|
+
pause_duration_months?: number
|
|
71
|
+
responded_at: string
|
|
72
|
+
}
|
|
73
|
+
survey_response?: {
|
|
74
|
+
reason: string
|
|
75
|
+
feedback?: string
|
|
76
|
+
competitor_name?: string
|
|
77
|
+
submitted_at: string
|
|
78
|
+
}
|
|
79
|
+
is_completed: boolean
|
|
80
|
+
completed_at?: string
|
|
81
|
+
}
|
|
82
|
+
}> {
|
|
83
|
+
return this.get(`/cancellation-funnel/${subscriptionId}/status`)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get Available Cancellation Offers
|
|
88
|
+
* GET /cancellation-funnel/{subscription_id}/offers
|
|
89
|
+
*/
|
|
90
|
+
async getAvailableOffers(
|
|
91
|
+
subscriptionId: string
|
|
92
|
+
): Promise<{
|
|
93
|
+
status: string
|
|
94
|
+
data: {
|
|
95
|
+
subscription_id: string
|
|
96
|
+
available_offers: Array<{
|
|
97
|
+
type: 'pause' | 'discount' | 'downgrade' | 'feature_change'
|
|
98
|
+
title: string
|
|
99
|
+
description: string
|
|
100
|
+
details?: Record<string, any>
|
|
101
|
+
valid_until?: string
|
|
102
|
+
}>
|
|
103
|
+
eligibility_check: {
|
|
104
|
+
is_eligible: boolean
|
|
105
|
+
reasons?: string[]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}> {
|
|
109
|
+
return this.get(`/cancellation-funnel/${subscriptionId}/offers`)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Complete Cancellation Funnel
|
|
114
|
+
* POST /cancellation-funnel/{subscription_id}/complete
|
|
115
|
+
*/
|
|
116
|
+
async completeCancellationFunnel(
|
|
117
|
+
subscriptionId: string,
|
|
118
|
+
finalAction: 'cancel' | 'retain'
|
|
119
|
+
): Promise<{
|
|
120
|
+
status: string
|
|
121
|
+
message: string
|
|
122
|
+
data: {
|
|
123
|
+
funnel_id: string
|
|
124
|
+
subscription_id: string
|
|
125
|
+
final_action: 'cancel' | 'retain'
|
|
126
|
+
completed_at: string
|
|
127
|
+
outcome: {
|
|
128
|
+
subscription_cancelled: boolean
|
|
129
|
+
effective_date?: string
|
|
130
|
+
retention_action?: string
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}> {
|
|
134
|
+
return this.post(`/cancellation-funnel/${subscriptionId}/complete`, {
|
|
135
|
+
final_action,
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Get Cancellation Reasons (for survey dropdown)
|
|
141
|
+
* GET /cancellation-funnel/reasons
|
|
142
|
+
*/
|
|
143
|
+
async getCancellationReasons(): Promise<{
|
|
144
|
+
status: string
|
|
145
|
+
data: Array<{
|
|
146
|
+
id: string
|
|
147
|
+
label: string
|
|
148
|
+
description: string
|
|
149
|
+
requires_feedback: boolean
|
|
150
|
+
requires_competitor: boolean
|
|
151
|
+
category: 'pricing' | 'features' | 'usability' | 'support' | 'other'
|
|
152
|
+
}>
|
|
153
|
+
}> {
|
|
154
|
+
return this.get('/cancellation-funnel/reasons')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Save Funnel Progress (for multi-step funnels)
|
|
159
|
+
* PUT /cancellation-funnel/{subscription_id}/progress
|
|
160
|
+
*/
|
|
161
|
+
async saveFunnelProgress(
|
|
162
|
+
subscriptionId: string,
|
|
163
|
+
progress: {
|
|
164
|
+
current_step: string
|
|
165
|
+
step_data?: Record<string, any>
|
|
166
|
+
completed_steps: string[]
|
|
167
|
+
}
|
|
168
|
+
): Promise<{
|
|
169
|
+
status: string
|
|
170
|
+
message: string
|
|
171
|
+
data: {
|
|
172
|
+
funnel_id: string
|
|
173
|
+
subscription_id: string
|
|
174
|
+
progress: {
|
|
175
|
+
current_step: string
|
|
176
|
+
step_data?: Record<string, any>
|
|
177
|
+
completed_steps: string[]
|
|
178
|
+
last_updated: string
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}> {
|
|
182
|
+
return this.put(`/cancellation-funnel/${subscriptionId}/progress`, progress)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Skip Funnel Step (for optional steps)
|
|
187
|
+
* POST /cancellation-funnel/{subscription_id}/skip-step
|
|
188
|
+
*/
|
|
189
|
+
async skipFunnelStep(
|
|
190
|
+
subscriptionId: string,
|
|
191
|
+
stepToSkip: string
|
|
192
|
+
): Promise<{
|
|
193
|
+
status: string
|
|
194
|
+
message: string
|
|
195
|
+
data: {
|
|
196
|
+
funnel_id: string
|
|
197
|
+
subscription_id: string
|
|
198
|
+
skipped_step: string
|
|
199
|
+
next_step: string
|
|
200
|
+
progress_updated_at: string
|
|
201
|
+
}
|
|
202
|
+
}> {
|
|
203
|
+
return this.post(`/cancellation-funnel/${subscriptionId}/skip-step`, {
|
|
204
|
+
step_to_skip: stepToSkip,
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get Retention Offers (based on cancellation reason)
|
|
210
|
+
* GET /cancellation-funnel/{subscription_id}/retention-offers
|
|
211
|
+
*/
|
|
212
|
+
async getRetentionOffers(
|
|
213
|
+
subscriptionId: string,
|
|
214
|
+
reason?: string
|
|
215
|
+
): Promise<{
|
|
216
|
+
status: string
|
|
217
|
+
data: {
|
|
218
|
+
subscription_id: string
|
|
219
|
+
cancellation_reason?: string
|
|
220
|
+
retention_offers: Array<{
|
|
221
|
+
id: string
|
|
222
|
+
type: 'discount' | 'upgrade' | 'extension' | 'feature_unlock'
|
|
223
|
+
title: string
|
|
224
|
+
description: string
|
|
225
|
+
value: {
|
|
226
|
+
amount?: number
|
|
227
|
+
percentage?: number
|
|
228
|
+
duration?: string
|
|
229
|
+
features?: string[]
|
|
230
|
+
}
|
|
231
|
+
expiration_date?: string
|
|
232
|
+
auto_apply: boolean
|
|
233
|
+
}>
|
|
234
|
+
}
|
|
235
|
+
}> {
|
|
236
|
+
const params = reason ? `?reason=${encodeURIComponent(reason)}` : ''
|
|
237
|
+
return this.get(`/cancellation-funnel/${subscriptionId}/retention-offers${params}`)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CancellationFunnelService } from './cancellation-funnel-service'
|
package/services/index.ts
CHANGED
|
@@ -14,6 +14,8 @@ export { UsageService } from './usage'
|
|
|
14
14
|
export { RepositoryAnalysisService } from './repository-analysis'
|
|
15
15
|
export { TaskService } from './tasks'
|
|
16
16
|
export { ApiKeyEnhancedService } from './api-key-enhanced'
|
|
17
|
+
export { SubscriptionService } from './subscriptions'
|
|
18
|
+
export { CancellationFunnelService } from './cancellation-funnel'
|
|
17
19
|
|
|
18
20
|
// Re-export all types for convenience
|
|
19
21
|
export * from './generation'
|
|
@@ -22,3 +24,5 @@ export * from './usage'
|
|
|
22
24
|
export * from './repository-analysis'
|
|
23
25
|
export * from './tasks'
|
|
24
26
|
export * from './api-key-enhanced'
|
|
27
|
+
export * from './subscriptions'
|
|
28
|
+
export * from './cancellation-funnel'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SubscriptionService } from './subscription-service'
|