mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[AC-2568] Split billing history calls to separately call for invoices and transactions. Added paging buttons (#10697)
* Split billing history calls to separately call for invoices and transactions. Added paging button * Added missing button types
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import {
|
||||
BillingInvoiceResponse,
|
||||
BillingTransactionResponse,
|
||||
} from "@bitwarden/common/billing/models/response/billing.response";
|
||||
|
||||
export class AccountBillingApiServiceAbstraction {
|
||||
getBillingInvoices: (id: string, startAfter?: string) => Promise<BillingInvoiceResponse[]>;
|
||||
getBillingTransactions: (
|
||||
id: string,
|
||||
startAfter?: string,
|
||||
) => Promise<BillingTransactionResponse[]>;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import {
|
||||
BillingInvoiceResponse,
|
||||
BillingTransactionResponse,
|
||||
} from "@bitwarden/common/billing/models/response/billing.response";
|
||||
|
||||
export class OrganizationBillingApiServiceAbstraction {
|
||||
getBillingInvoices: (id: string, startAfter?: string) => Promise<BillingInvoiceResponse[]>;
|
||||
getBillingTransactions: (
|
||||
id: string,
|
||||
startAfter?: string,
|
||||
) => Promise<BillingTransactionResponse[]>;
|
||||
}
|
||||
@@ -29,6 +29,7 @@ export class BillingSourceResponse extends BaseResponse {
|
||||
}
|
||||
|
||||
export class BillingInvoiceResponse extends BaseResponse {
|
||||
id: string;
|
||||
url: string;
|
||||
pdfUrl: string;
|
||||
number: string;
|
||||
@@ -38,6 +39,7 @@ export class BillingInvoiceResponse extends BaseResponse {
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.id = this.getResponseProperty("Id");
|
||||
this.url = this.getResponseProperty("Url");
|
||||
this.pdfUrl = this.getResponseProperty("PdfUrl");
|
||||
this.number = this.getResponseProperty("Number");
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { ApiService } from "../../../abstractions/api.service";
|
||||
import { AccountBillingApiServiceAbstraction } from "../../abstractions/account/account-billing-api.service.abstraction";
|
||||
import {
|
||||
BillingInvoiceResponse,
|
||||
BillingTransactionResponse,
|
||||
} from "../../models/response/billing.response";
|
||||
|
||||
export class AccountBillingApiService implements AccountBillingApiServiceAbstraction {
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
async getBillingInvoices(startAfter?: string): Promise<BillingInvoiceResponse[]> {
|
||||
const queryParams = startAfter ? `?startAfter=${startAfter}` : "";
|
||||
const r = await this.apiService.send(
|
||||
"GET",
|
||||
`/accounts/billing/invoices${queryParams}`,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
return r?.map((i: any) => new BillingInvoiceResponse(i)) || [];
|
||||
}
|
||||
|
||||
async getBillingTransactions(startAfter?: string): Promise<BillingTransactionResponse[]> {
|
||||
const queryParams = startAfter ? `?startAfter=${startAfter}` : "";
|
||||
const r = await this.apiService.send(
|
||||
"GET",
|
||||
`/accounts/billing/transactions${queryParams}`,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
return r?.map((i: any) => new BillingTransactionResponse(i)) || [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { ApiService } from "../../../abstractions/api.service";
|
||||
import { OrganizationBillingApiServiceAbstraction } from "../../abstractions/organizations/organization-billing-api.service.abstraction";
|
||||
import {
|
||||
BillingInvoiceResponse,
|
||||
BillingTransactionResponse,
|
||||
} from "../../models/response/billing.response";
|
||||
|
||||
export class OrganizationBillingApiService implements OrganizationBillingApiServiceAbstraction {
|
||||
constructor(private apiService: ApiService) {}
|
||||
|
||||
async getBillingInvoices(id: string, startAfter?: string): Promise<BillingInvoiceResponse[]> {
|
||||
const queryParams = startAfter ? `?startAfter=${startAfter}` : "";
|
||||
const r = await this.apiService.send(
|
||||
"GET",
|
||||
`/organizations/${id}/billing/invoices${queryParams}`,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
return r?.map((i: any) => new BillingInvoiceResponse(i)) || [];
|
||||
}
|
||||
|
||||
async getBillingTransactions(
|
||||
id: string,
|
||||
startAfter?: string,
|
||||
): Promise<BillingTransactionResponse[]> {
|
||||
const queryParams = startAfter ? `?startAfter=${startAfter}` : "";
|
||||
const r = await this.apiService.send(
|
||||
"GET",
|
||||
`/organizations/${id}/billing/transactions${queryParams}`,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
return r?.map((i: any) => new BillingTransactionResponse(i)) || [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user