1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

org create apis

This commit is contained in:
Kyle Spearrin 2018-07-02 15:36:32 -04:00
parent 7ba04c919e
commit 0033b92a2d
4 changed files with 77 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import { FolderRequest } from '../models/request/folderRequest';
import { ImportCiphersRequest } from '../models/request/importCiphersRequest';
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
import { ImportOrganizationCiphersRequest } from '../models/request/importOrganizationCiphersRequest';
import { OrganizationCreateRequest } from '../models/request/organizationCreateRequest';
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
import { PasswordRequest } from '../models/request/passwordRequest';
import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest';
@ -37,6 +38,7 @@ import { FolderResponse } from '../models/response/folderResponse';
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
import { ListResponse } from '../models/response/listResponse';
import { OrganizationResponse } from '../models/response/organizationResponse';
import { ProfileResponse } from '../models/response/profileResponse';
import { SyncResponse } from '../models/response/syncResponse';
import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse';
@ -111,4 +113,6 @@ export abstract class ApiService {
postTwoFactorRecover: (request: TwoFactorRecoveryRequest) => Promise<any>;
postTwoFactorEmailSetup: (request: TwoFactorEmailRequest) => Promise<any>;
postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise<any>;
postOrganization: (request: OrganizationCreateRequest) => Promise<OrganizationResponse>;
postOrganizationLicense: (data: FormData) => Promise<OrganizationResponse>;
}

View File

@ -0,0 +1,14 @@
import { PlanType } from '../../enums/planType';
export class OrganizationCreateRequest {
name: string;
businessName: string;
billingEmail: string;
planType: PlanType;
key: string;
paymentToken: string;
additionalSeats: number;
additionalStorageGb: number;
collectionName: string;
country: string;
}

View File

@ -0,0 +1,45 @@
import { PlanType } from '../../enums/planType';
export class OrganizationResponse {
id: string;
name: string;
businessName: string;
businessAddress1: string;
businessAddress2: string;
businessAddress3: string;
businessCountry: string;
businessTaxNumber: string;
billingEmail: string;
plan: string;
planType: PlanType;
seats: number;
maxCollections: number;
maxStorageGb: number;
useGroups: boolean;
useDirectory: boolean;
useEvents: boolean;
useTotp: boolean;
use2fa: boolean;
constructor(response: any) {
this.id = response.Id;
this.name = response.Name;
this.businessName = response.BusinessName;
this.businessAddress1 = response.BusinessAddress1;
this.businessAddress2 = response.BusinessAddress2;
this.businessAddress3 = response.BusinessAddress3;
this.businessCountry = response.BusinessCountry;
this.businessTaxNumber = response.BusinessTaxNumber;
this.billingEmail = response.BillingEmail;
this.plan = response.Plan;
this.planType = response.PlanType;
this.seats = response.Seats;
this.maxCollections = response.MaxCollections;
this.maxStorageGb = response.MaxStorageGb;
this.useGroups = response.UseGroups;
this.useDirectory = response.UseDirectory;
this.useEvents = response.UseEvents;
this.useTotp = response.UseTotp;
this.use2fa = response.Use2fa;
}
}

View File

@ -18,6 +18,7 @@ import { FolderRequest } from '../models/request/folderRequest';
import { ImportCiphersRequest } from '../models/request/importCiphersRequest';
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
import { ImportOrganizationCiphersRequest } from '../models/request/importOrganizationCiphersRequest';
import { OrganizationCreateRequest } from '../models/request/organizationCreateRequest';
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
import { PasswordRequest } from '../models/request/passwordRequest';
import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest';
@ -44,6 +45,7 @@ import { FolderResponse } from '../models/response/folderResponse';
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
import { ListResponse } from '../models/response/listResponse';
import { OrganizationResponse } from '../models/response/organizationResponse';
import { ProfileResponse } from '../models/response/profileResponse';
import { SyncResponse } from '../models/response/syncResponse';
import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse';
@ -401,6 +403,18 @@ export class ApiService implements ApiServiceAbstraction {
return this.send('POST', '/two-factor/send-email-login', request, false, false);
}
// Organization APIs
async postOrganization(request: OrganizationCreateRequest): Promise<OrganizationResponse> {
const r = await this.send('POST', '/organizations', request, true, true);
return new OrganizationResponse(r);
}
async postOrganizationLicense(data: FormData): Promise<OrganizationResponse> {
const r = await this.send('POST', '/organizations/license', data, true, true);
return new OrganizationResponse(r);
}
// Helpers
private async send(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, body: any,