mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +00:00
* Eliminate in-app purchase logic * Remove more in-app logic found, for payment and subscription management --------- Co-authored-by: Lotus Scott <148992878+lscottbw@users.noreply.github.com>
87 lines
3.1 KiB
TypeScript
87 lines
3.1 KiB
TypeScript
import { BaseResponse } from "../../../models/response/base.response";
|
|
|
|
export class SubscriptionResponse extends BaseResponse {
|
|
storageName: string;
|
|
storageGb: number;
|
|
maxStorageGb: number;
|
|
subscription: BillingSubscriptionResponse;
|
|
upcomingInvoice: BillingSubscriptionUpcomingInvoiceResponse;
|
|
license: any;
|
|
expiration: string;
|
|
|
|
constructor(response: any) {
|
|
super(response);
|
|
this.storageName = this.getResponseProperty("StorageName");
|
|
this.storageGb = this.getResponseProperty("StorageGb");
|
|
this.maxStorageGb = this.getResponseProperty("MaxStorageGb");
|
|
this.license = this.getResponseProperty("License");
|
|
this.expiration = this.getResponseProperty("Expiration");
|
|
const subscription = this.getResponseProperty("Subscription");
|
|
const upcomingInvoice = this.getResponseProperty("UpcomingInvoice");
|
|
this.subscription = subscription == null ? null : new BillingSubscriptionResponse(subscription);
|
|
this.upcomingInvoice =
|
|
upcomingInvoice == null
|
|
? null
|
|
: new BillingSubscriptionUpcomingInvoiceResponse(upcomingInvoice);
|
|
}
|
|
}
|
|
|
|
export class BillingSubscriptionResponse extends BaseResponse {
|
|
trialStartDate: string;
|
|
trialEndDate: string;
|
|
periodStartDate: string;
|
|
periodEndDate: string;
|
|
cancelledDate: string;
|
|
cancelAtEndDate: boolean;
|
|
status: string;
|
|
cancelled: boolean;
|
|
items: BillingSubscriptionItemResponse[] = [];
|
|
|
|
constructor(response: any) {
|
|
super(response);
|
|
this.trialEndDate = this.getResponseProperty("TrialStartDate");
|
|
this.trialEndDate = this.getResponseProperty("TrialEndDate");
|
|
this.periodStartDate = this.getResponseProperty("PeriodStartDate");
|
|
this.periodEndDate = this.getResponseProperty("PeriodEndDate");
|
|
this.cancelledDate = this.getResponseProperty("CancelledDate");
|
|
this.cancelAtEndDate = this.getResponseProperty("CancelAtEndDate");
|
|
this.status = this.getResponseProperty("Status");
|
|
this.cancelled = this.getResponseProperty("Cancelled");
|
|
const items = this.getResponseProperty("Items");
|
|
if (items != null) {
|
|
this.items = items.map((i: any) => new BillingSubscriptionItemResponse(i));
|
|
}
|
|
}
|
|
}
|
|
|
|
export class BillingSubscriptionItemResponse extends BaseResponse {
|
|
name: string;
|
|
amount: number;
|
|
quantity: number;
|
|
interval: string;
|
|
sponsoredSubscriptionItem: boolean;
|
|
addonSubscriptionItem: boolean;
|
|
productName: string;
|
|
|
|
constructor(response: any) {
|
|
super(response);
|
|
this.name = this.getResponseProperty("Name");
|
|
this.amount = this.getResponseProperty("Amount");
|
|
this.quantity = this.getResponseProperty("Quantity");
|
|
this.interval = this.getResponseProperty("Interval");
|
|
this.sponsoredSubscriptionItem = this.getResponseProperty("SponsoredSubscriptionItem");
|
|
this.addonSubscriptionItem = this.getResponseProperty("AddonSubscriptionItem");
|
|
}
|
|
}
|
|
|
|
export class BillingSubscriptionUpcomingInvoiceResponse extends BaseResponse {
|
|
date: string;
|
|
amount?: number;
|
|
|
|
constructor(response: any) {
|
|
super(response);
|
|
this.date = this.getResponseProperty("Date");
|
|
this.amount = this.getResponseProperty("Amount");
|
|
}
|
|
}
|