mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
add necessary apis for org directory imports
This commit is contained in:
parent
12533dd951
commit
66bdf442d6
@ -2,6 +2,7 @@ import { EnvironmentUrls } from '../models/domain/environmentUrls';
|
||||
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { FolderRequest } from '../models/request/folderRequest';
|
||||
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
||||
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
||||
import { RegisterRequest } from '../models/request/registerRequest';
|
||||
import { TokenRequest } from '../models/request/tokenRequest';
|
||||
@ -36,4 +37,5 @@ export abstract class ApiService {
|
||||
postCipherAttachment: (id: string, data: FormData) => Promise<CipherResponse>;
|
||||
deleteCipherAttachment: (id: string, attachmentId: string) => Promise<any>;
|
||||
getSync: () => Promise<SyncResponse>;
|
||||
postImportDirectory: (organizationId: string, request: ImportDirectoryRequest) => Promise<any>;
|
||||
}
|
||||
|
7
src/models/request/importDirectoryRequest.ts
Normal file
7
src/models/request/importDirectoryRequest.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { ImportDirectoryRequestGroup } from './importDirectoryRequestGroup';
|
||||
import { ImportDirectoryRequestUser } from './importDirectoryRequestUser';
|
||||
|
||||
export class ImportDirectoryRequest {
|
||||
groups: ImportDirectoryRequestGroup[] = [];
|
||||
users: ImportDirectoryRequestUser[] = [];
|
||||
}
|
5
src/models/request/importDirectoryRequestGroup.ts
Normal file
5
src/models/request/importDirectoryRequestGroup.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class ImportDirectoryRequestGroup {
|
||||
name: string;
|
||||
externalId: string;
|
||||
users: string[];
|
||||
}
|
5
src/models/request/importDirectoryRequestUser.ts
Normal file
5
src/models/request/importDirectoryRequestUser.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class ImportDirectoryRequestUser {
|
||||
externalId: string;
|
||||
email: string;
|
||||
deleted: boolean;
|
||||
}
|
@ -8,6 +8,7 @@ import { EnvironmentUrls } from '../models/domain/environmentUrls';
|
||||
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { FolderRequest } from '../models/request/folderRequest';
|
||||
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
||||
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
||||
import { RegisterRequest } from '../models/request/registerRequest';
|
||||
import { TokenRequest } from '../models/request/tokenRequest';
|
||||
@ -379,6 +380,26 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
async postImportDirectory(organizationId: string, request: ImportDirectoryRequest): Promise<any> {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.baseUrl + '/organizations/' + organizationId + '/import', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Authorization': authHeader,
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Device-Type': this.deviceType,
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
if (response.status !== 200) {
|
||||
const error = await this.handleError(response, false);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
private async handleError(response: Response, tokenError: boolean): Promise<ErrorResponse> {
|
||||
|
Loading…
Reference in New Issue
Block a user