From b32b016f823300699971287e59fc85c57d2c1842 Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Tue, 11 Aug 2020 14:20:39 -0400 Subject: [PATCH] Merge plan and price updates (#145) * Created a PlanResponse model & relevant API request for getting plan data from the server --- src/abstractions/api.service.ts | 2 + src/enums/planType.ts | 15 ++-- src/enums/productType.ts | 6 ++ src/models/response/organizationResponse.ts | 3 +- src/models/response/planResponse.ts | 93 +++++++++++++++++++++ src/services/api.service.ts | 8 ++ 6 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 src/enums/productType.ts create mode 100644 src/models/response/planResponse.ts diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index 838d12e434..266c1c68ae 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -87,6 +87,7 @@ import { OrganizationUserUserDetailsResponse, } from '../models/response/organizationUserResponse'; import { PaymentResponse } from '../models/response/paymentResponse'; +import { PlanResponse } from '../models/response/planResponse'; import { PolicyResponse } from '../models/response/policyResponse'; import { PreloginResponse } from '../models/response/preloginResponse'; import { ProfileResponse } from '../models/response/profileResponse'; @@ -282,6 +283,7 @@ export abstract class ApiService { postOrganizationCancel: (id: string) => Promise; postOrganizationReinstate: (id: string) => Promise; deleteOrganization: (id: string, request: PasswordVerificationRequest) => Promise; + getPlans: () => Promise>; getEvents: (start: string, end: string, token: string) => Promise>; getEventsCipher: (id: string, start: string, end: string, token: string) => Promise>; diff --git a/src/enums/planType.ts b/src/enums/planType.ts index eadd188415..1b07c723aa 100644 --- a/src/enums/planType.ts +++ b/src/enums/planType.ts @@ -1,9 +1,14 @@ export enum PlanType { Free = 0, - FamiliesAnnually = 1, - TeamsMonthly = 2, - TeamsAnnually = 3, - EnterpriseMonthly = 4, - EnterpriseAnnually = 5, + FamiliesAnnually2019 = 1, + TeamsMonthly2019 = 2, + TeamsAnnually2019 = 3, + EnterpriseMonthly2019 = 4, + EnterpriseAnnually2019 = 5, Custom = 6, + FamiliesAnnually = 7, + TeamsMonthly = 8, + TeamsAnnually = 9, + EnterpriseMonthly = 10, + EnterpriseAnnually = 11, } diff --git a/src/enums/productType.ts b/src/enums/productType.ts new file mode 100644 index 0000000000..d8e2e0ae2e --- /dev/null +++ b/src/enums/productType.ts @@ -0,0 +1,6 @@ +export enum ProductType { + Free = 0, + Families = 1, + Teams = 2, + Enterprise = 3, +} diff --git a/src/models/response/organizationResponse.ts b/src/models/response/organizationResponse.ts index 436e09e3fa..0859dca74c 100644 --- a/src/models/response/organizationResponse.ts +++ b/src/models/response/organizationResponse.ts @@ -1,4 +1,5 @@ import { BaseResponse } from './baseResponse'; +import { PlanResponse } from './planResponse'; import { PlanType } from '../../enums/planType'; @@ -12,7 +13,7 @@ export class OrganizationResponse extends BaseResponse { businessCountry: string; businessTaxNumber: string; billingEmail: string; - plan: string; + plan: PlanResponse; planType: PlanType; seats: number; maxCollections: number; diff --git a/src/models/response/planResponse.ts b/src/models/response/planResponse.ts new file mode 100644 index 0000000000..96b385da07 --- /dev/null +++ b/src/models/response/planResponse.ts @@ -0,0 +1,93 @@ +import { PlanType } from '../../enums/planType'; +import { ProductType } from '../../enums/productType'; + +import { BaseResponse } from './baseResponse'; + +export class PlanResponse extends BaseResponse { + type: PlanType; + product: ProductType; + name: string; + isAnnual: boolean; + nameLocalizationKey: string; + descriptionLocalizationKey: string; + canBeUsedByBusiness: boolean; + baseSeats: number; + baseStorageGb: number; + maxCollections: number; + maxUsers: number; + + hasAdditionalSeatsOption: boolean; + maxAdditionalSeats: number; + hasAdditionalStorageOption: boolean; + maxAdditionalStorage: number; + hasPremiumAccessOption: boolean; + trialPeriodDays: number; + + hasSelfHost: boolean; + hasPolicies: boolean; + hasGroups: boolean; + hasDirectory: boolean; + hasEvents: boolean; + hasTotp: boolean; + has2fa: boolean; + hasApi: boolean; + hasSso: boolean; + usersGetPremium: boolean; + + upgradeSortOrder: number; + displaySortOrder: number; + legacyYear: number; + disabled: boolean; + + stripePlanId: string; + stripeSeatPlanId: string; + stripeStoragePlanId: string; + stripePremiumAccessPlanId: string; + basePrice: number; + seatPrice: number; + additionalStoragePricePerGb: number; + premiumAccessOptionPrice: number; + + constructor(response: any) { + super(response); + this.type = this.getResponseProperty('type'); + this.product = this.getResponseProperty('product'); + this.name = this.getResponseProperty('name'); + this.isAnnual = this.getResponseProperty('isAnnual'); + this.nameLocalizationKey = this.getResponseProperty('nameLocalizationKey'); + this.descriptionLocalizationKey = this.getResponseProperty('descriptionLocalizationKey'); + this.canBeUsedByBusiness = this.getResponseProperty('canBeUsedByBusiness'); + this.baseSeats = this.getResponseProperty('baseSeats'); + this.baseStorageGb = this.getResponseProperty('baseStorageGb'); + this.maxCollections = this.getResponseProperty('maxCollections'); + this.maxUsers = this.getResponseProperty('maxUsers'); + this.hasAdditionalSeatsOption = this.getResponseProperty('hasAdditionalSeatsOption'); + this.maxAdditionalSeats = this.getResponseProperty('maxAdditionalSeats'); + this.hasAdditionalStorageOption = this.getResponseProperty('hasAdditionalStorageOption'); + this.maxAdditionalStorage = this.getResponseProperty('maxAdditionalStorage'); + this.hasPremiumAccessOption = this.getResponseProperty('hasPremiumAccessOption'); + this.trialPeriodDays = this.getResponseProperty('trialPeriodDays'); + this.hasSelfHost = this.getResponseProperty('hasSelfHost'); + this.hasPolicies = this.getResponseProperty('hasPolicies'); + this.hasGroups = this.getResponseProperty('hasGroups'); + this.hasDirectory = this.getResponseProperty('hasDirectory'); + this.hasEvents = this.getResponseProperty('hasEvents'); + this.hasTotp = this.getResponseProperty('hasTotp'); + this.has2fa = this.getResponseProperty('has2fa'); + this.hasApi = this.getResponseProperty('hasApi'); + this.hasSso = this.getResponseProperty('hasSso'); + this.usersGetPremium = this.getResponseProperty('usersGetPremium'); + this.upgradeSortOrder = this.getResponseProperty('upgradeSortOrder'); + this.displaySortOrder = this.getResponseProperty('sortOrder'); + this.legacyYear = this.getResponseProperty('legacyYear'); + this.disabled = this.getResponseProperty('disabled'); + this.stripePlanId = this.getResponseProperty('stripePlanId'); + this.stripeSeatPlanId = this.getResponseProperty('stripeSeatPlanId'); + this.stripeStoragePlanId = this.getResponseProperty('stripeStoragePlanId'); + this.stripePremiumAccessPlanId = this.getResponseProperty('stripePremiumAccessPlanId'); + this.basePrice = this.getResponseProperty('basePrice'); + this.seatPrice = this.getResponseProperty('seatPrice'); + this.additionalStoragePricePerGb = this.getResponseProperty('additionalStoragePricePerGb'); + this.premiumAccessOptionPrice = this.getResponseProperty('premiumAccessOptionPrice'); + } +} diff --git a/src/services/api.service.ts b/src/services/api.service.ts index 9f7397f355..f79178e2a7 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -92,6 +92,7 @@ import { OrganizationUserUserDetailsResponse, } from '../models/response/organizationUserResponse'; import { PaymentResponse } from '../models/response/paymentResponse'; +import { PlanResponse } from '../models/response/planResponse'; import { PolicyResponse } from '../models/response/policyResponse'; import { PreloginResponse } from '../models/response/preloginResponse'; import { ProfileResponse } from '../models/response/profileResponse'; @@ -685,6 +686,13 @@ export class ApiService implements ApiServiceAbstraction { return this.send('DELETE', '/organizations/' + organizationId + '/users/' + id, null, true, false); } + // Plan APIs + + async getPlans(): Promise> { + const r = await this.send('GET', '/plans/', null, true, true); + return new ListResponse(r, PlanResponse); + } + // Sync APIs async getSync(): Promise {