Merge plan and price updates (#145)

* Created a PlanResponse model & relevant API request for getting plan data from the server
This commit is contained in:
Addison Beck 2020-08-11 14:20:39 -04:00 committed by GitHub
parent 420393700b
commit b32b016f82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 121 additions and 6 deletions

View File

@ -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<any>;
postOrganizationReinstate: (id: string) => Promise<any>;
deleteOrganization: (id: string, request: PasswordVerificationRequest) => Promise<any>;
getPlans: () => Promise<ListResponse<PlanResponse>>;
getEvents: (start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
getEventsCipher: (id: string, start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;

View File

@ -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,
}

6
src/enums/productType.ts Normal file
View File

@ -0,0 +1,6 @@
export enum ProductType {
Free = 0,
Families = 1,
Teams = 2,
Enterprise = 3,
}

View File

@ -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;

View File

@ -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');
}
}

View File

@ -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<ListResponse<PlanResponse>> {
const r = await this.send('GET', '/plans/', null, true, true);
return new ListResponse(r, PlanResponse);
}
// Sync APIs
async getSync(): Promise<SyncResponse> {