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 {