From 5d84c3b52c8dfcb8640565dbde614fa1256483ae Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 12 Jan 2025 07:28:45 +0000 Subject: [PATCH] fix types --- .../components/billing/estimatedTotal.svelte | 16 ++++ src/lib/sdk/billing.ts | 80 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/lib/components/billing/estimatedTotal.svelte diff --git a/src/lib/components/billing/estimatedTotal.svelte b/src/lib/components/billing/estimatedTotal.svelte new file mode 100644 index 000000000..40cac8a00 --- /dev/null +++ b/src/lib/components/billing/estimatedTotal.svelte @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 85673c615..04cbbaef6 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -65,6 +65,28 @@ export type InvoiceList = { total: number; }; +export type Estimation = { + amount: number; + grossAmount: number; + credits: number; + discount: number; + items: EstimationItem[]; +} + +export type EstimationItem = { + label: string; + value: number; +} + +export type EstimationDeleteOrganization = { + amount: number; + grossAmount: number; + credits: number; + discount: number; + items: EstimationItem[], + unpaidInvoices: Invoice[]; +} + export type Coupon = { $id: string; code: string; @@ -396,6 +418,28 @@ export class Billing { ); } + async estimationCreateOrganization( + billingPlan: string, + couponId: string = null, + invites: Array = [], + ): Promise { + const path = `/organizations`; + const params = { + billingPlan, + couponId, + invites, + }; + const uri = new URL(this.client.config.endpoint + path); + return await this.client.call( + 'POST', + uri, + { + 'content-type': 'application/json' + }, + params + ); + } + async deleteOrganization(organizationId: string): Promise { const path = `/organizations/${organizationId}`; const params = { @@ -412,6 +456,18 @@ export class Billing { ); } + async estimationDeleteOrganization(organizationId: string): Promise { + const path = `/organizations/${organizationId}/predictions/delete-organization`; + const uri = new URL(this.client.config.endpoint + path); + return await this.client.call( + 'patch', + uri, + { + 'content-type': 'application/json' + } + ); + } + async getOrganizationPlan(organizationId: string): Promise { const path = `/organizations/${organizationId}/plan`; const uri = new URL(this.client.config.endpoint + path); @@ -475,6 +531,30 @@ export class Billing { params ); } + + async estimationUpdatePlan( + organizationId: string, + billingPlan: string, + couponId: string = null, + invites: Array = [], + ): Promise { + const path = `/organizations/${organizationId}/predictions/update-plan`; + const params = { + billingPlan, + couponId, + invites, + }; + const uri = new URL(this.client.config.endpoint + path); + return await this.client.call( + 'patch', + uri, + { + 'content-type': 'application/json' + }, + params + ); + } + async cancelDowngrade( organizationId: string ): Promise {