mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
* implementing the clients changes * resolve pr comments on message.json * moved the method to billing-api.service * move the request and response files to billing folder * remove the adding existing orgs * resolve the routing issue * resolving the pr comments * code owner changes * fix the assignedseat * resolve the warning message * resolve the error on update * passing the right id * resolve the unassign value * removed unused logservice * Adding the loader on submit button
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import { ApiService } from "../../abstractions/api.service";
|
|
import { BillingApiServiceAbstraction } from "../../billing/abstractions/billilng-api.service.abstraction";
|
|
import { SubscriptionCancellationRequest } from "../../billing/models/request/subscription-cancellation.request";
|
|
import { OrganizationBillingStatusResponse } from "../../billing/models/response/organization-billing-status.response";
|
|
import { ProviderSubscriptionUpdateRequest } from "../models/request/provider-subscription-update.request";
|
|
import { ProviderSubscriptionResponse } from "../models/response/provider-subscription-response";
|
|
|
|
export class BillingApiService implements BillingApiServiceAbstraction {
|
|
constructor(private apiService: ApiService) {}
|
|
|
|
cancelOrganizationSubscription(
|
|
organizationId: string,
|
|
request: SubscriptionCancellationRequest,
|
|
): Promise<void> {
|
|
return this.apiService.send(
|
|
"POST",
|
|
"/organizations/" + organizationId + "/cancel",
|
|
request,
|
|
true,
|
|
false,
|
|
);
|
|
}
|
|
|
|
cancelPremiumUserSubscription(request: SubscriptionCancellationRequest): Promise<void> {
|
|
return this.apiService.send("POST", "/accounts/cancel", request, true, false);
|
|
}
|
|
|
|
async getBillingStatus(id: string): Promise<OrganizationBillingStatusResponse> {
|
|
const r = await this.apiService.send(
|
|
"GET",
|
|
"/organizations/" + id + "/billing-status",
|
|
null,
|
|
true,
|
|
true,
|
|
);
|
|
|
|
return new OrganizationBillingStatusResponse(r);
|
|
}
|
|
|
|
async getProviderClientSubscriptions(providerId: string): Promise<ProviderSubscriptionResponse> {
|
|
const r = await this.apiService.send(
|
|
"GET",
|
|
"/providers/" + providerId + "/billing/subscription",
|
|
null,
|
|
true,
|
|
true,
|
|
);
|
|
return new ProviderSubscriptionResponse(r);
|
|
}
|
|
|
|
async putProviderClientSubscriptions(
|
|
providerId: string,
|
|
organizationId: string,
|
|
request: ProviderSubscriptionUpdateRequest,
|
|
): Promise<any> {
|
|
return await this.apiService.send(
|
|
"PUT",
|
|
"/providers/" + providerId + "/organizations/" + organizationId,
|
|
request,
|
|
true,
|
|
false,
|
|
);
|
|
}
|
|
}
|