@codeguide/core 0.0.7 → 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/codeguide.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
TaskService,
|
|
15
15
|
ApiKeyEnhancedService,
|
|
16
16
|
SubscriptionService,
|
|
17
|
+
CancellationFunnelService,
|
|
17
18
|
} from './services'
|
|
18
19
|
import { APIServiceConfig, CodeGuideOptions } from './types'
|
|
19
20
|
|
|
@@ -25,6 +26,7 @@ export class CodeGuide {
|
|
|
25
26
|
public tasks: TaskService
|
|
26
27
|
public apiKeyEnhanced: ApiKeyEnhancedService
|
|
27
28
|
public subscription: SubscriptionService
|
|
29
|
+
public cancellationFunnel: CancellationFunnelService
|
|
28
30
|
private options: CodeGuideOptions
|
|
29
31
|
|
|
30
32
|
constructor(config: APIServiceConfig, options: CodeGuideOptions = {}) {
|
|
@@ -38,6 +40,7 @@ export class CodeGuide {
|
|
|
38
40
|
this.tasks = new TaskService(config)
|
|
39
41
|
this.apiKeyEnhanced = new ApiKeyEnhancedService(config)
|
|
40
42
|
this.subscription = new SubscriptionService(config)
|
|
43
|
+
this.cancellationFunnel = new CancellationFunnelService(config)
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// Convenience method for backward compatibility
|
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
|
@@ -15,6 +15,7 @@ export { RepositoryAnalysisService } from './repository-analysis'
|
|
|
15
15
|
export { TaskService } from './tasks'
|
|
16
16
|
export { ApiKeyEnhancedService } from './api-key-enhanced'
|
|
17
17
|
export { SubscriptionService } from './subscriptions'
|
|
18
|
+
export { CancellationFunnelService } from './cancellation-funnel'
|
|
18
19
|
|
|
19
20
|
// Re-export all types for convenience
|
|
20
21
|
export * from './generation'
|
|
@@ -24,3 +25,4 @@ export * from './repository-analysis'
|
|
|
24
25
|
export * from './tasks'
|
|
25
26
|
export * from './api-key-enhanced'
|
|
26
27
|
export * from './subscriptions'
|
|
28
|
+
export * from './cancellation-funnel'
|
package/types.ts
CHANGED
|
@@ -176,3 +176,65 @@ export interface CancelSubscriptionResponse {
|
|
|
176
176
|
message: string
|
|
177
177
|
data: Subscription
|
|
178
178
|
}
|
|
179
|
+
|
|
180
|
+
// Cancellation Funnel Types
|
|
181
|
+
export interface CancellationFunnelInitiateRequest {
|
|
182
|
+
subscription_id: string
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface CancellationFunnelInitiateResponse {
|
|
186
|
+
status: string
|
|
187
|
+
message: string
|
|
188
|
+
data: {
|
|
189
|
+
funnel_id: string
|
|
190
|
+
subscription_id: string
|
|
191
|
+
current_step: 'initiated'
|
|
192
|
+
created_at: string
|
|
193
|
+
available_offers: string[]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface CancellationFunnelPauseOfferRequest {
|
|
198
|
+
subscription_id: string
|
|
199
|
+
action: 'accepted' | 'declined'
|
|
200
|
+
pause_duration_months?: number
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface CancellationFunnelPauseOfferResponse {
|
|
204
|
+
status: string
|
|
205
|
+
message: string
|
|
206
|
+
data: {
|
|
207
|
+
funnel_id: string
|
|
208
|
+
subscription_id: string
|
|
209
|
+
pause_offer: {
|
|
210
|
+
action: 'accepted' | 'declined'
|
|
211
|
+
pause_duration_months?: number
|
|
212
|
+
pause_start_date?: string
|
|
213
|
+
pause_end_date?: string
|
|
214
|
+
}
|
|
215
|
+
next_step: string
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface CancellationFunnelSurveyRequest {
|
|
220
|
+
subscription_id: string
|
|
221
|
+
reason: string
|
|
222
|
+
feedback?: string
|
|
223
|
+
competitor_name?: string
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface CancellationFunnelSurveyResponse {
|
|
227
|
+
status: string
|
|
228
|
+
message: string
|
|
229
|
+
data: {
|
|
230
|
+
funnel_id: string
|
|
231
|
+
subscription_id: string
|
|
232
|
+
survey_response: {
|
|
233
|
+
reason: string
|
|
234
|
+
feedback?: string
|
|
235
|
+
competitor_name?: string
|
|
236
|
+
submitted_at: string
|
|
237
|
+
}
|
|
238
|
+
next_step: string
|
|
239
|
+
}
|
|
240
|
+
}
|