mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
Updated certain billing callsites to get billing history instead (#9443)
This commit is contained in:
@@ -44,7 +44,7 @@ export class OrgBillingHistoryViewComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.billing = await this.organizationApiService.getBilling(this.organizationId);
|
this.billing = await this.organizationApiService.getBillingHistory(this.organizationId);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { BillingHistoryResponse } from "@bitwarden/common/billing/models/response/billing-history.response";
|
||||||
|
|
||||||
import { OrganizationApiKeyRequest } from "../../../admin-console/models/request/organization-api-key.request";
|
import { OrganizationApiKeyRequest } from "../../../admin-console/models/request/organization-api-key.request";
|
||||||
import { OrganizationSsoRequest } from "../../../auth/models/request/organization-sso.request";
|
import { OrganizationSsoRequest } from "../../../auth/models/request/organization-sso.request";
|
||||||
import { SecretVerificationRequest } from "../../../auth/models/request/secret-verification.request";
|
import { SecretVerificationRequest } from "../../../auth/models/request/secret-verification.request";
|
||||||
@@ -33,6 +35,7 @@ import { ProfileOrganizationResponse } from "../../models/response/profile-organ
|
|||||||
export class OrganizationApiServiceAbstraction {
|
export class OrganizationApiServiceAbstraction {
|
||||||
get: (id: string) => Promise<OrganizationResponse>;
|
get: (id: string) => Promise<OrganizationResponse>;
|
||||||
getBilling: (id: string) => Promise<BillingResponse>;
|
getBilling: (id: string) => Promise<BillingResponse>;
|
||||||
|
getBillingHistory: (id: string) => Promise<BillingHistoryResponse>;
|
||||||
getSubscription: (id: string) => Promise<OrganizationSubscriptionResponse>;
|
getSubscription: (id: string) => Promise<OrganizationSubscriptionResponse>;
|
||||||
getLicense: (id: string, installationId: string) => Promise<unknown>;
|
getLicense: (id: string, installationId: string) => Promise<unknown>;
|
||||||
getAutoEnrollStatus: (identifier: string) => Promise<OrganizationAutoEnrollStatusResponse>;
|
getAutoEnrollStatus: (identifier: string) => Promise<OrganizationAutoEnrollStatusResponse>;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { BillingHistoryResponse } from "@bitwarden/common/billing/models/response/billing-history.response";
|
||||||
|
|
||||||
import { ApiService } from "../../../abstractions/api.service";
|
import { ApiService } from "../../../abstractions/api.service";
|
||||||
import { OrganizationApiKeyRequest } from "../../../admin-console/models/request/organization-api-key.request";
|
import { OrganizationApiKeyRequest } from "../../../admin-console/models/request/organization-api-key.request";
|
||||||
import { OrganizationSsoRequest } from "../../../auth/models/request/organization-sso.request";
|
import { OrganizationSsoRequest } from "../../../auth/models/request/organization-sso.request";
|
||||||
@@ -55,6 +57,17 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
|||||||
return new BillingResponse(r);
|
return new BillingResponse(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getBillingHistory(id: string): Promise<BillingHistoryResponse> {
|
||||||
|
const r = await this.apiService.send(
|
||||||
|
"GET",
|
||||||
|
"/organizations/" + id + "/billing/history",
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return new BillingHistoryResponse(r);
|
||||||
|
}
|
||||||
|
|
||||||
async getSubscription(id: string): Promise<OrganizationSubscriptionResponse> {
|
async getSubscription(id: string): Promise<OrganizationSubscriptionResponse> {
|
||||||
const r = await this.apiService.send(
|
const r = await this.apiService.send(
|
||||||
"GET",
|
"GET",
|
||||||
|
|||||||
@@ -4,26 +4,12 @@ import { PaymentMethodType, TransactionType } from "../../enums";
|
|||||||
export class BillingResponse extends BaseResponse {
|
export class BillingResponse extends BaseResponse {
|
||||||
balance: number;
|
balance: number;
|
||||||
paymentSource: BillingSourceResponse;
|
paymentSource: BillingSourceResponse;
|
||||||
invoices: BillingInvoiceResponse[] = [];
|
|
||||||
transactions: BillingTransactionResponse[] = [];
|
|
||||||
|
|
||||||
constructor(response: any) {
|
constructor(response: any) {
|
||||||
super(response);
|
super(response);
|
||||||
this.balance = this.getResponseProperty("Balance");
|
this.balance = this.getResponseProperty("Balance");
|
||||||
const paymentSource = this.getResponseProperty("PaymentSource");
|
const paymentSource = this.getResponseProperty("PaymentSource");
|
||||||
const transactions = this.getResponseProperty("Transactions");
|
|
||||||
const invoices = this.getResponseProperty("Invoices");
|
|
||||||
this.paymentSource = paymentSource == null ? null : new BillingSourceResponse(paymentSource);
|
this.paymentSource = paymentSource == null ? null : new BillingSourceResponse(paymentSource);
|
||||||
if (transactions != null) {
|
|
||||||
this.transactions = transactions.map((t: any) => new BillingTransactionResponse(t));
|
|
||||||
}
|
|
||||||
if (invoices != null) {
|
|
||||||
this.invoices = invoices.map((i: any) => new BillingInvoiceResponse(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get hasNoHistory() {
|
|
||||||
return this.invoices.length == 0 && this.transactions.length == 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user