@applica-software-guru/persona-sdk 0.1.1 → 0.1.3
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 +248 -0
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +152 -55
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +138 -0
- package/package.json +1 -1
- package/src/billing/billing-client.ts +142 -0
- package/src/billing/types.ts +104 -0
- package/src/index.ts +15 -0
- package/src/persona-sdk.ts +10 -0
package/dist/index.d.ts
CHANGED
|
@@ -143,6 +143,46 @@ export declare class BearerTokenAuthenticationProvider implements Authentication
|
|
|
143
143
|
getCredentials(): string;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
export declare class BillingClient {
|
|
147
|
+
private readonly baseUrl;
|
|
148
|
+
private readonly authProvider;
|
|
149
|
+
constructor(baseUrl?: string, auth?: string | AuthenticationProvider | null);
|
|
150
|
+
private buildHeaders;
|
|
151
|
+
private request;
|
|
152
|
+
createCustomer(request: CreateCustomerRequest): Promise<Customer>;
|
|
153
|
+
updateCustomer(owner: string, request: UpdateCustomerRequest): Promise<Customer>;
|
|
154
|
+
getCustomer(owner: string): Promise<Customer>;
|
|
155
|
+
saveCustomer(customer: Customer): Promise<Customer>;
|
|
156
|
+
deleteCustomer(owner: string): Promise<void>;
|
|
157
|
+
createSubscription(request: CreateSubscriptionRequest): Promise<Subscription>;
|
|
158
|
+
getSubscription(owner: string): Promise<Subscription>;
|
|
159
|
+
getProjectSubscription(projectId: string): Promise<Subscription>;
|
|
160
|
+
changeProjectSubscriptionPlan(projectId: string, request: {
|
|
161
|
+
toPlanType: string;
|
|
162
|
+
}): Promise<Subscription>;
|
|
163
|
+
addProjectSubscriptionCredits(projectId: string, request: {
|
|
164
|
+
credits: number;
|
|
165
|
+
}): Promise<Subscription>;
|
|
166
|
+
beginUpgrade(owner: string, request: UpgradeSubscriptionRequest): Promise<Subscription>;
|
|
167
|
+
downgrade(owner: string, request: DowngradeSubscriptionRequest): Promise<Subscription>;
|
|
168
|
+
mentorize(owner: string, request: MentorizeSubscriptionRequest): Promise<Subscription>;
|
|
169
|
+
addCredits(owner: string, credits: number): Promise<Subscription>;
|
|
170
|
+
useCredits(owner: string, credits: number, services: string[], referenceId?: string): Promise<Subscription>;
|
|
171
|
+
getCredits(owner: string): Promise<number>;
|
|
172
|
+
isValid(owner: string): Promise<boolean>;
|
|
173
|
+
listInvoices(owner: string, dateFrom?: string, dateTo?: string): Promise<Invoice[]>;
|
|
174
|
+
cancelSubscription(owner: string): Promise<Subscription>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare interface BillingUsage {
|
|
178
|
+
id?: string;
|
|
179
|
+
subscriptionId?: string;
|
|
180
|
+
creditsUsed?: number;
|
|
181
|
+
services?: string[];
|
|
182
|
+
referenceId?: string;
|
|
183
|
+
createdAt?: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
146
186
|
export declare interface ChangeProjectSubscriptionPlanRequest {
|
|
147
187
|
toPlanType: string;
|
|
148
188
|
}
|
|
@@ -204,6 +244,17 @@ export declare interface ContentValue {
|
|
|
204
244
|
content?: ContentItem[];
|
|
205
245
|
}
|
|
206
246
|
|
|
247
|
+
export declare interface CreateCustomerRequest {
|
|
248
|
+
owner?: string;
|
|
249
|
+
name?: string;
|
|
250
|
+
email?: string;
|
|
251
|
+
phone?: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export declare interface CreateSubscriptionRequest {
|
|
255
|
+
owner: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
207
258
|
export declare interface Credentials {
|
|
208
259
|
id?: string;
|
|
209
260
|
name?: string;
|
|
@@ -236,8 +287,22 @@ export declare class CredentialsApi extends HttpApi {
|
|
|
236
287
|
remove(credentialsId: string): Promise<void>;
|
|
237
288
|
}
|
|
238
289
|
|
|
290
|
+
export declare interface Customer {
|
|
291
|
+
id?: string;
|
|
292
|
+
owner?: string;
|
|
293
|
+
name?: string;
|
|
294
|
+
email?: string;
|
|
295
|
+
phone?: string;
|
|
296
|
+
address?: string;
|
|
297
|
+
stripeCustomerId?: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
239
300
|
export declare type DocumentExtractorName = 'fitz' | 'document-ai' | 'gemini' | 'markdown';
|
|
240
301
|
|
|
302
|
+
export declare interface DowngradeSubscriptionRequest {
|
|
303
|
+
toPlanType: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
241
306
|
export declare type EmbeddingModelName = 'text-multilingual-embedding-002' | 'gemini-embedding-001';
|
|
242
307
|
|
|
243
308
|
export declare interface ExecuteRequest {
|
|
@@ -387,6 +452,23 @@ export declare interface ImapTriggerSourceConfiguration {
|
|
|
387
452
|
allowedMimeTypes?: string[];
|
|
388
453
|
}
|
|
389
454
|
|
|
455
|
+
export declare interface Invoice {
|
|
456
|
+
id?: string;
|
|
457
|
+
subscriptionId?: string;
|
|
458
|
+
status?: string;
|
|
459
|
+
amountDue?: number;
|
|
460
|
+
amountPaid?: number;
|
|
461
|
+
currency?: string;
|
|
462
|
+
customerEmail?: string;
|
|
463
|
+
customerName?: string;
|
|
464
|
+
hostedInvoiceUrl?: string;
|
|
465
|
+
invoicePdf?: string;
|
|
466
|
+
dueDate?: string;
|
|
467
|
+
createdAt?: string;
|
|
468
|
+
updatedAt?: string;
|
|
469
|
+
lines?: LineItem[];
|
|
470
|
+
}
|
|
471
|
+
|
|
390
472
|
export declare interface KnowledgeBase {
|
|
391
473
|
id?: string;
|
|
392
474
|
projectId?: string;
|
|
@@ -475,6 +557,15 @@ export declare type KnowledgeType = 'multi_hop' | 'simple';
|
|
|
475
557
|
|
|
476
558
|
export declare type LanguageCode = 'en-US' | 'it-IT' | 'es-ES' | 'fr-FR' | 'de-DE' | 'pt-BR';
|
|
477
559
|
|
|
560
|
+
export declare interface LineItem {
|
|
561
|
+
description?: string;
|
|
562
|
+
amount?: number;
|
|
563
|
+
currency?: string;
|
|
564
|
+
quantity?: number;
|
|
565
|
+
periodStart?: string;
|
|
566
|
+
periodEnd?: string;
|
|
567
|
+
}
|
|
568
|
+
|
|
478
569
|
export declare interface McpServerConfiguration {
|
|
479
570
|
type?: string;
|
|
480
571
|
name?: string;
|
|
@@ -488,6 +579,10 @@ export declare interface McpToolsResponse {
|
|
|
488
579
|
error?: string;
|
|
489
580
|
}
|
|
490
581
|
|
|
582
|
+
export declare interface MentorizeSubscriptionRequest {
|
|
583
|
+
endDate?: string;
|
|
584
|
+
}
|
|
585
|
+
|
|
491
586
|
export declare interface Message {
|
|
492
587
|
id?: string;
|
|
493
588
|
sessionId?: string;
|
|
@@ -625,6 +720,20 @@ export declare interface Paginated<T> {
|
|
|
625
720
|
size: number;
|
|
626
721
|
}
|
|
627
722
|
|
|
723
|
+
export declare interface Payment {
|
|
724
|
+
id?: string;
|
|
725
|
+
subscriptionId?: string;
|
|
726
|
+
status?: string;
|
|
727
|
+
product?: string;
|
|
728
|
+
quantity?: number;
|
|
729
|
+
createdAt?: string;
|
|
730
|
+
updatedAt?: string;
|
|
731
|
+
checkoutUrl?: string;
|
|
732
|
+
stripeCheckoutSessionId?: string;
|
|
733
|
+
stripeCustomerId?: string;
|
|
734
|
+
stripeSubscriptionId?: string;
|
|
735
|
+
}
|
|
736
|
+
|
|
628
737
|
export declare class PersonaSdk {
|
|
629
738
|
private readonly baseUrl;
|
|
630
739
|
private readonly workflowsBaseUrl;
|
|
@@ -649,6 +758,8 @@ export declare class PersonaSdk {
|
|
|
649
758
|
sessions(authProvider: AuthenticationProvider): SessionsApi;
|
|
650
759
|
missions(apiKey: string): MissionsApi;
|
|
651
760
|
missions(authProvider: AuthenticationProvider): MissionsApi;
|
|
761
|
+
billing(baseUrl?: string): BillingClient;
|
|
762
|
+
billing(auth: string | AuthenticationProvider): BillingClient;
|
|
652
763
|
}
|
|
653
764
|
|
|
654
765
|
export declare interface Position {
|
|
@@ -860,6 +971,23 @@ export declare interface StmConfiguration {
|
|
|
860
971
|
|
|
861
972
|
export declare type StmType = 'simple' | 'summary';
|
|
862
973
|
|
|
974
|
+
export declare interface Subscription {
|
|
975
|
+
id?: string;
|
|
976
|
+
projectId?: string;
|
|
977
|
+
owner?: string;
|
|
978
|
+
planType?: string;
|
|
979
|
+
status?: string;
|
|
980
|
+
startDate?: string;
|
|
981
|
+
planCredits?: number;
|
|
982
|
+
extraCredits?: number;
|
|
983
|
+
keepCreditsOnRenew?: boolean;
|
|
984
|
+
endDate?: string;
|
|
985
|
+
createdAt?: string;
|
|
986
|
+
updatedAt?: string;
|
|
987
|
+
stripeCustomerId?: string;
|
|
988
|
+
stripeSubscriptionId?: string;
|
|
989
|
+
}
|
|
990
|
+
|
|
863
991
|
export declare interface SynthesizerConfiguration {
|
|
864
992
|
enabled?: boolean;
|
|
865
993
|
synthesizerName?: SynthesizerName;
|
|
@@ -996,6 +1124,16 @@ export declare interface TwilioConfiguration {
|
|
|
996
1124
|
phoneNumber?: string;
|
|
997
1125
|
}
|
|
998
1126
|
|
|
1127
|
+
export declare interface UpdateCustomerRequest {
|
|
1128
|
+
name?: string;
|
|
1129
|
+
email?: string;
|
|
1130
|
+
phone?: string;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
export declare interface UpgradeSubscriptionRequest {
|
|
1134
|
+
toPlanType: string;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
999
1137
|
export declare interface UsageCost {
|
|
1000
1138
|
service?: string;
|
|
1001
1139
|
value?: number;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@applica-software-guru/persona-sdk",
|
|
3
3
|
"description": "Official TypeScript SDK for the Persona API — manage agents, sessions, projects, knowledge bases, workflows, triggers and more.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite",
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
2
|
+
import { ApiException } from '../exceptions';
|
|
3
|
+
import {
|
|
4
|
+
Customer,
|
|
5
|
+
Subscription,
|
|
6
|
+
Invoice,
|
|
7
|
+
CreateCustomerRequest,
|
|
8
|
+
UpdateCustomerRequest,
|
|
9
|
+
CreateSubscriptionRequest,
|
|
10
|
+
UpgradeSubscriptionRequest,
|
|
11
|
+
DowngradeSubscriptionRequest,
|
|
12
|
+
MentorizeSubscriptionRequest,
|
|
13
|
+
} from './types';
|
|
14
|
+
|
|
15
|
+
export class BillingClient {
|
|
16
|
+
private readonly baseUrl: string;
|
|
17
|
+
private readonly authProvider: AuthenticationProvider | string | null;
|
|
18
|
+
|
|
19
|
+
constructor(baseUrl?: string, auth?: string | AuthenticationProvider | null) {
|
|
20
|
+
this.baseUrl = (baseUrl || 'https://persona.applica.guru/billing').replace(/\/$/, '');
|
|
21
|
+
this.authProvider = auth ?? null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private buildHeaders(): Headers {
|
|
25
|
+
const headers = new Headers();
|
|
26
|
+
headers.set('Content-Type', 'application/json');
|
|
27
|
+
if (this.authProvider) {
|
|
28
|
+
if (typeof this.authProvider === 'string') {
|
|
29
|
+
headers.set('x-persona-apikey', this.authProvider);
|
|
30
|
+
} else {
|
|
31
|
+
this.authProvider.applyHeaders(headers);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return headers;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private async request<T>(path: string, method: string, body?: unknown): Promise<T> {
|
|
38
|
+
const response = await fetch(this.baseUrl + path, {
|
|
39
|
+
method,
|
|
40
|
+
headers: this.buildHeaders(),
|
|
41
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const text = await response.text();
|
|
45
|
+
throw new ApiException(response.status, text);
|
|
46
|
+
}
|
|
47
|
+
const text = await response.text();
|
|
48
|
+
return text ? JSON.parse(text) : (undefined as T);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async createCustomer(request: CreateCustomerRequest): Promise<Customer> {
|
|
52
|
+
return this.request<Customer>('/customers', 'POST', request);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async updateCustomer(owner: string, request: UpdateCustomerRequest): Promise<Customer> {
|
|
56
|
+
return this.request<Customer>('/customers/' + owner, 'PUT', request);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async getCustomer(owner: string): Promise<Customer> {
|
|
60
|
+
return this.request<Customer>('/customers/' + owner, 'GET');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async saveCustomer(customer: Customer): Promise<Customer> {
|
|
64
|
+
return this.request<Customer>('/customers', 'POST', customer);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async deleteCustomer(owner: string): Promise<void> {
|
|
68
|
+
await this.request<void>('/customers/' + owner, 'DELETE');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async createSubscription(request: CreateSubscriptionRequest): Promise<Subscription> {
|
|
72
|
+
return this.request<Subscription>('/customers/' + request.owner + '/subscription', 'POST', request);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async getSubscription(owner: string): Promise<Subscription> {
|
|
76
|
+
return this.request<Subscription>('/customers/' + owner + '/subscription', 'GET');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getProjectSubscription(projectId: string): Promise<Subscription> {
|
|
80
|
+
return this.request<Subscription>('/projects/' + projectId + '/subscription', 'GET');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async changeProjectSubscriptionPlan(projectId: string, request: { toPlanType: string }): Promise<Subscription> {
|
|
84
|
+
return this.request<Subscription>('/projects/' + projectId + '/subscription/actions/change-plan', 'POST', request);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async addProjectSubscriptionCredits(projectId: string, request: { credits: number }): Promise<Subscription> {
|
|
88
|
+
return this.request<Subscription>('/projects/' + projectId + '/subscription/actions/add-credits', 'POST', request);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async beginUpgrade(owner: string, request: UpgradeSubscriptionRequest): Promise<Subscription> {
|
|
92
|
+
return this.request<Subscription>('/customers/' + owner + '/subscription/actions/upgrade', 'POST', request);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async downgrade(owner: string, request: DowngradeSubscriptionRequest): Promise<Subscription> {
|
|
96
|
+
return this.request<Subscription>('/customers/' + owner + '/subscription/actions/downgrade', 'POST', request);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async mentorize(owner: string, request: MentorizeSubscriptionRequest): Promise<Subscription> {
|
|
100
|
+
return this.request<Subscription>('/customers/' + owner + '/subscription/actions/mentorize', 'POST', request);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async addCredits(owner: string, credits: number): Promise<Subscription> {
|
|
104
|
+
return this.request<Subscription>('/customers/' + owner + '/subscription/credits', 'POST', { credits });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async useCredits(owner: string, credits: number, services: string[], referenceId?: string): Promise<Subscription> {
|
|
108
|
+
const body: Record<string, unknown> = { credits, services };
|
|
109
|
+
if (referenceId) body.referenceId = referenceId;
|
|
110
|
+
return this.request<Subscription>('/customers/' + owner + '/subscription/credits', 'DELETE', body);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async getCredits(owner: string): Promise<number> {
|
|
114
|
+
try {
|
|
115
|
+
const result = await this.request<{ credits?: number }>('/customers/' + owner + '/subscription/credits', 'GET');
|
|
116
|
+
return result.credits ?? 0;
|
|
117
|
+
} catch {
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async isValid(owner: string): Promise<boolean> {
|
|
123
|
+
try {
|
|
124
|
+
const result = await this.request<{ valid?: boolean }>('/customers/' + owner + '/subscription/valid', 'GET');
|
|
125
|
+
return result.valid ?? false;
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async listInvoices(owner: string, dateFrom?: string, dateTo?: string): Promise<Invoice[]> {
|
|
132
|
+
const params: string[] = [];
|
|
133
|
+
if (dateFrom) params.push('date_from=' + dateFrom);
|
|
134
|
+
if (dateTo) params.push('date_to=' + dateTo);
|
|
135
|
+
const query = params.length > 0 ? '?' + params.join('&') : '';
|
|
136
|
+
return this.request<Invoice[]>('/customers/' + owner + '/invoices' + query, 'GET');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async cancelSubscription(owner: string): Promise<Subscription> {
|
|
140
|
+
return this.request<Subscription>('/customers/' + owner + '/subscription/actions/cancel', 'POST', {});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export interface Customer {
|
|
2
|
+
id?: string;
|
|
3
|
+
owner?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
phone?: string;
|
|
7
|
+
address?: string;
|
|
8
|
+
stripeCustomerId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Subscription {
|
|
12
|
+
id?: string;
|
|
13
|
+
projectId?: string;
|
|
14
|
+
owner?: string;
|
|
15
|
+
planType?: string;
|
|
16
|
+
status?: string;
|
|
17
|
+
startDate?: string;
|
|
18
|
+
planCredits?: number;
|
|
19
|
+
extraCredits?: number;
|
|
20
|
+
keepCreditsOnRenew?: boolean;
|
|
21
|
+
endDate?: string;
|
|
22
|
+
createdAt?: string;
|
|
23
|
+
updatedAt?: string;
|
|
24
|
+
stripeCustomerId?: string;
|
|
25
|
+
stripeSubscriptionId?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Invoice {
|
|
29
|
+
id?: string;
|
|
30
|
+
subscriptionId?: string;
|
|
31
|
+
status?: string;
|
|
32
|
+
amountDue?: number;
|
|
33
|
+
amountPaid?: number;
|
|
34
|
+
currency?: string;
|
|
35
|
+
customerEmail?: string;
|
|
36
|
+
customerName?: string;
|
|
37
|
+
hostedInvoiceUrl?: string;
|
|
38
|
+
invoicePdf?: string;
|
|
39
|
+
dueDate?: string;
|
|
40
|
+
createdAt?: string;
|
|
41
|
+
updatedAt?: string;
|
|
42
|
+
lines?: LineItem[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface LineItem {
|
|
46
|
+
description?: string;
|
|
47
|
+
amount?: number;
|
|
48
|
+
currency?: string;
|
|
49
|
+
quantity?: number;
|
|
50
|
+
periodStart?: string;
|
|
51
|
+
periodEnd?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface Usage {
|
|
55
|
+
id?: string;
|
|
56
|
+
subscriptionId?: string;
|
|
57
|
+
creditsUsed?: number;
|
|
58
|
+
services?: string[];
|
|
59
|
+
referenceId?: string;
|
|
60
|
+
createdAt?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface Payment {
|
|
64
|
+
id?: string;
|
|
65
|
+
subscriptionId?: string;
|
|
66
|
+
status?: string;
|
|
67
|
+
product?: string;
|
|
68
|
+
quantity?: number;
|
|
69
|
+
createdAt?: string;
|
|
70
|
+
updatedAt?: string;
|
|
71
|
+
checkoutUrl?: string;
|
|
72
|
+
stripeCheckoutSessionId?: string;
|
|
73
|
+
stripeCustomerId?: string;
|
|
74
|
+
stripeSubscriptionId?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface CreateCustomerRequest {
|
|
78
|
+
owner?: string;
|
|
79
|
+
name?: string;
|
|
80
|
+
email?: string;
|
|
81
|
+
phone?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface UpdateCustomerRequest {
|
|
85
|
+
name?: string;
|
|
86
|
+
email?: string;
|
|
87
|
+
phone?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface CreateSubscriptionRequest {
|
|
91
|
+
owner: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface UpgradeSubscriptionRequest {
|
|
95
|
+
toPlanType: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface DowngradeSubscriptionRequest {
|
|
99
|
+
toPlanType: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface MentorizeSubscriptionRequest {
|
|
103
|
+
endDate?: string;
|
|
104
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -151,3 +151,18 @@ export type { Mission, MissionStatus } from './missions/types';
|
|
|
151
151
|
export { ServicePricesApi } from './service-prices/service-prices-api';
|
|
152
152
|
export type { ServicePrice } from './service-prices/types';
|
|
153
153
|
export type { Revision as RevisionType } from './revisions/types';
|
|
154
|
+
export { BillingClient } from './billing/billing-client';
|
|
155
|
+
export type {
|
|
156
|
+
Customer,
|
|
157
|
+
Subscription,
|
|
158
|
+
Invoice,
|
|
159
|
+
LineItem,
|
|
160
|
+
Usage as BillingUsage,
|
|
161
|
+
Payment,
|
|
162
|
+
CreateCustomerRequest,
|
|
163
|
+
UpdateCustomerRequest,
|
|
164
|
+
CreateSubscriptionRequest,
|
|
165
|
+
UpgradeSubscriptionRequest,
|
|
166
|
+
DowngradeSubscriptionRequest,
|
|
167
|
+
MentorizeSubscriptionRequest,
|
|
168
|
+
} from './billing/types';
|
package/src/persona-sdk.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { TriggersApi } from './triggers/triggers-api';
|
|
|
9
9
|
import { ServicePricesApi } from './service-prices/service-prices-api';
|
|
10
10
|
import { SessionsApi } from './sessions/sessions-api';
|
|
11
11
|
import { MissionsApi } from './missions/missions-api';
|
|
12
|
+
import { BillingClient } from './billing/billing-client';
|
|
12
13
|
|
|
13
14
|
export class PersonaSdk {
|
|
14
15
|
private readonly baseUrl: string;
|
|
@@ -78,4 +79,13 @@ export class PersonaSdk {
|
|
|
78
79
|
missions(auth: string | AuthenticationProvider): MissionsApi {
|
|
79
80
|
return new MissionsApi(this.baseUrl, auth);
|
|
80
81
|
}
|
|
82
|
+
|
|
83
|
+
billing(baseUrl?: string): BillingClient;
|
|
84
|
+
billing(auth: string | AuthenticationProvider): BillingClient;
|
|
85
|
+
billing(baseUrlOrAuth?: string | AuthenticationProvider): BillingClient {
|
|
86
|
+
if (!baseUrlOrAuth || typeof baseUrlOrAuth !== 'string') {
|
|
87
|
+
return new BillingClient(undefined, baseUrlOrAuth);
|
|
88
|
+
}
|
|
89
|
+
return new BillingClient(baseUrlOrAuth);
|
|
90
|
+
}
|
|
81
91
|
}
|