1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

add cancel and reinstate premium

This commit is contained in:
Kyle Spearrin 2018-06-29 13:58:01 -04:00
parent 1565140024
commit 3726d9e6d8
3 changed files with 28 additions and 2 deletions

View File

@ -65,6 +65,8 @@ export abstract class ApiService {
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
postRegister: (request: RegisterRequest) => Promise<any>;
postPremium: (data: FormData) => Promise<any>;
postReinstatePremium: () => Promise<any>;
postCancelPremium: () => Promise<any>;
postFolder: (request: FolderRequest) => Promise<FolderResponse>;
putFolder: (id: string, request: FolderRequest) => Promise<FolderResponse>;
deleteFolder: (id: string) => Promise<any>;

View File

@ -4,11 +4,27 @@ export class BillingResponse {
storageName: string;
storageGb: number;
maxStorageGb: number;
paymentSource: BillingSourceResponse;
subscription: BillingSubscriptionResponse;
upcomingInvoice: BillingInvoiceResponse;
charges: BillingChargeResponse[] = [];
license: any;
expiration: Date;
constructor(response: any) {
this.storageName = response.StorageName;
this.storageGb = response.StorageGb;
this.maxStorageGb = response.MaxStorageGb;
this.paymentSource = response.PaymentSource == null ? null : new BillingSourceResponse(response.PaymentSource);
this.subscription = response.Subscription == null ?
null : new BillingSubscriptionResponse(response.Subscription);
this.upcomingInvoice = response.UpcomingInvoice == null ?
null : new BillingInvoiceResponse(response.UpcomingInvoice);
if (response.Charges != null) {
this.charges = response.Charges.map((c: any) => new BillingChargeResponse(c));
}
this.license = response.License;
this.expiration = response.Expiration;
}
}
@ -47,7 +63,7 @@ export class BillingSubscriptionResponse {
this.status = response.Status;
this.cancelled = response.Cancelled;
if (response.Items != null) {
this.items = response.Items.map((i) => new BillingSubscriptionItemResponse(i));
this.items = response.Items.map((i: any) => new BillingSubscriptionItemResponse(i));
}
}
}

View File

@ -191,7 +191,15 @@ export class ApiService implements ApiServiceAbstraction {
}
postPremium(data: FormData): Promise<any> {
return this.send('POST', '/accounts/premium', data, true, true);
return this.send('POST', '/accounts/premium', data, true, false);
}
postReinstatePremium(): Promise<any> {
return this.send('POST', '/accounts/reinstate-premium', null, true, false);
}
postCancelPremium(): Promise<any> {
return this.send('POST', '/accounts/cancel-premium', null, true, false);
}
// Folder APIs