mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
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:
@@ -87,6 +87,7 @@ import {
|
|||||||
OrganizationUserUserDetailsResponse,
|
OrganizationUserUserDetailsResponse,
|
||||||
} from '../models/response/organizationUserResponse';
|
} from '../models/response/organizationUserResponse';
|
||||||
import { PaymentResponse } from '../models/response/paymentResponse';
|
import { PaymentResponse } from '../models/response/paymentResponse';
|
||||||
|
import { PlanResponse } from '../models/response/planResponse';
|
||||||
import { PolicyResponse } from '../models/response/policyResponse';
|
import { PolicyResponse } from '../models/response/policyResponse';
|
||||||
import { PreloginResponse } from '../models/response/preloginResponse';
|
import { PreloginResponse } from '../models/response/preloginResponse';
|
||||||
import { ProfileResponse } from '../models/response/profileResponse';
|
import { ProfileResponse } from '../models/response/profileResponse';
|
||||||
@@ -282,6 +283,7 @@ export abstract class ApiService {
|
|||||||
postOrganizationCancel: (id: string) => Promise<any>;
|
postOrganizationCancel: (id: string) => Promise<any>;
|
||||||
postOrganizationReinstate: (id: string) => Promise<any>;
|
postOrganizationReinstate: (id: string) => Promise<any>;
|
||||||
deleteOrganization: (id: string, request: PasswordVerificationRequest) => Promise<any>;
|
deleteOrganization: (id: string, request: PasswordVerificationRequest) => Promise<any>;
|
||||||
|
getPlans: () => Promise<ListResponse<PlanResponse>>;
|
||||||
|
|
||||||
getEvents: (start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
|
getEvents: (start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
|
||||||
getEventsCipher: (id: string, start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
|
getEventsCipher: (id: string, start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
export enum PlanType {
|
export enum PlanType {
|
||||||
Free = 0,
|
Free = 0,
|
||||||
FamiliesAnnually = 1,
|
FamiliesAnnually2019 = 1,
|
||||||
TeamsMonthly = 2,
|
TeamsMonthly2019 = 2,
|
||||||
TeamsAnnually = 3,
|
TeamsAnnually2019 = 3,
|
||||||
EnterpriseMonthly = 4,
|
EnterpriseMonthly2019 = 4,
|
||||||
EnterpriseAnnually = 5,
|
EnterpriseAnnually2019 = 5,
|
||||||
Custom = 6,
|
Custom = 6,
|
||||||
|
FamiliesAnnually = 7,
|
||||||
|
TeamsMonthly = 8,
|
||||||
|
TeamsAnnually = 9,
|
||||||
|
EnterpriseMonthly = 10,
|
||||||
|
EnterpriseAnnually = 11,
|
||||||
}
|
}
|
||||||
|
|||||||
6
src/enums/productType.ts
Normal file
6
src/enums/productType.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export enum ProductType {
|
||||||
|
Free = 0,
|
||||||
|
Families = 1,
|
||||||
|
Teams = 2,
|
||||||
|
Enterprise = 3,
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { BaseResponse } from './baseResponse';
|
import { BaseResponse } from './baseResponse';
|
||||||
|
import { PlanResponse } from './planResponse';
|
||||||
|
|
||||||
import { PlanType } from '../../enums/planType';
|
import { PlanType } from '../../enums/planType';
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ export class OrganizationResponse extends BaseResponse {
|
|||||||
businessCountry: string;
|
businessCountry: string;
|
||||||
businessTaxNumber: string;
|
businessTaxNumber: string;
|
||||||
billingEmail: string;
|
billingEmail: string;
|
||||||
plan: string;
|
plan: PlanResponse;
|
||||||
planType: PlanType;
|
planType: PlanType;
|
||||||
seats: number;
|
seats: number;
|
||||||
maxCollections: number;
|
maxCollections: number;
|
||||||
|
|||||||
93
src/models/response/planResponse.ts
Normal file
93
src/models/response/planResponse.ts
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -92,6 +92,7 @@ import {
|
|||||||
OrganizationUserUserDetailsResponse,
|
OrganizationUserUserDetailsResponse,
|
||||||
} from '../models/response/organizationUserResponse';
|
} from '../models/response/organizationUserResponse';
|
||||||
import { PaymentResponse } from '../models/response/paymentResponse';
|
import { PaymentResponse } from '../models/response/paymentResponse';
|
||||||
|
import { PlanResponse } from '../models/response/planResponse';
|
||||||
import { PolicyResponse } from '../models/response/policyResponse';
|
import { PolicyResponse } from '../models/response/policyResponse';
|
||||||
import { PreloginResponse } from '../models/response/preloginResponse';
|
import { PreloginResponse } from '../models/response/preloginResponse';
|
||||||
import { ProfileResponse } from '../models/response/profileResponse';
|
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);
|
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
|
// Sync APIs
|
||||||
|
|
||||||
async getSync(): Promise<SyncResponse> {
|
async getSync(): Promise<SyncResponse> {
|
||||||
|
|||||||
Reference in New Issue
Block a user