fix types

This commit is contained in:
Damodar Lohani
2025-01-12 07:28:45 +00:00
parent 81e5d0d47f
commit 5d84c3b52c
2 changed files with 96 additions and 0 deletions
@@ -0,0 +1,16 @@
<script lang="ts">
export let organizationId: string| undefined;
export let type: string = "createOrganization";
export let billingPlan: string;
export let collaborators: string[];
export let couponId: string;
export let fixedCoupon = false;
let getEstimage = () => {
return {}
}
$: estimate = getEstimage();
</script>
+80
View File
@@ -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<string> = [],
): Promise<Estimation> {
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<Organization> {
const path = `/organizations/${organizationId}`;
const params = {
@@ -412,6 +456,18 @@ export class Billing {
);
}
async estimationDeleteOrganization(organizationId: string): Promise<EstimationDeleteOrganization> {
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<Plan> {
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<string> = [],
): Promise<Estimation> {
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<Organization | OrganizationError> {