From 3726d9e6d8a0572e0a2c5d284724000ea5b9cff1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 29 Jun 2018 13:58:01 -0400 Subject: [PATCH] add cancel and reinstate premium --- src/abstractions/api.service.ts | 2 ++ src/models/response/billingResponse.ts | 18 +++++++++++++++++- src/services/api.service.ts | 10 +++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index 5b45bd3a33..2755d0db2b 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -65,6 +65,8 @@ export abstract class ApiService { postPasswordHint: (request: PasswordHintRequest) => Promise; postRegister: (request: RegisterRequest) => Promise; postPremium: (data: FormData) => Promise; + postReinstatePremium: () => Promise; + postCancelPremium: () => Promise; postFolder: (request: FolderRequest) => Promise; putFolder: (id: string, request: FolderRequest) => Promise; deleteFolder: (id: string) => Promise; diff --git a/src/models/response/billingResponse.ts b/src/models/response/billingResponse.ts index 2bd97a9ba6..12ca0a47f7 100644 --- a/src/models/response/billingResponse.ts +++ b/src/models/response/billingResponse.ts @@ -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)); } } } diff --git a/src/services/api.service.ts b/src/services/api.service.ts index 01a08e7802..570ae4ddff 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -191,7 +191,15 @@ export class ApiService implements ApiServiceAbstraction { } postPremium(data: FormData): Promise { - return this.send('POST', '/accounts/premium', data, true, true); + return this.send('POST', '/accounts/premium', data, true, false); + } + + postReinstatePremium(): Promise { + return this.send('POST', '/accounts/reinstate-premium', null, true, false); + } + + postCancelPremium(): Promise { + return this.send('POST', '/accounts/cancel-premium', null, true, false); } // Folder APIs