mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
apis for new create with collections
This commit is contained in:
parent
d1f7a97011
commit
bf48b45010
@ -4,6 +4,7 @@ import { CipherBulkDeleteRequest } from '../models/request/cipherBulkDeleteReque
|
||||
import { CipherBulkMoveRequest } from '../models/request/cipherBulkMoveRequest';
|
||||
import { CipherBulkShareRequest } from '../models/request/cipherBulkShareRequest';
|
||||
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
|
||||
import { CipherCreateRequest } from '../models/request/cipherCreateRequest';
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { CipherShareRequest } from '../models/request/cipherShareRequest';
|
||||
import { CollectionRequest } from '../models/request/collectionRequest';
|
||||
@ -132,7 +133,8 @@ export abstract class ApiService {
|
||||
getCipherAdmin: (id: string) => Promise<CipherResponse>;
|
||||
getCiphersOrganization: (organizationId: string) => Promise<ListResponse<CipherResponse>>;
|
||||
postCipher: (request: CipherRequest) => Promise<CipherResponse>;
|
||||
postCipherAdmin: (request: CipherRequest) => Promise<CipherResponse>;
|
||||
postCipherCreate: (request: CipherCreateRequest) => Promise<CipherResponse>;
|
||||
postCipherAdmin: (request: CipherCreateRequest) => Promise<CipherResponse>;
|
||||
putCipher: (id: string, request: CipherRequest) => Promise<CipherResponse>;
|
||||
putCipherAdmin: (id: string, request: CipherRequest) => Promise<CipherResponse>;
|
||||
deleteCipher: (id: string) => Promise<any>;
|
||||
|
@ -25,7 +25,7 @@ export abstract class CipherService {
|
||||
getLastUsedForUrl: (url: string) => Promise<CipherView>;
|
||||
updateLastUsedDate: (id: string) => Promise<void>;
|
||||
saveNeverDomain: (domain: string) => Promise<void>;
|
||||
saveWithServer: (cipher: Cipher) => Promise<any>;
|
||||
saveWithServer: (cipher: Cipher, collectionIds?: string[]) => Promise<any>;
|
||||
shareWithServer: (cipher: CipherView, organizationId: string, collectionIds: string[]) => Promise<any>;
|
||||
shareManyWithServer: (ciphers: CipherView[], organizationId: string, collectionIds: string[]) => Promise<any>;
|
||||
shareAttachmentWithServer: (attachmentView: AttachmentView, cipherId: string,
|
||||
|
13
src/models/request/cipherCreateRequest.ts
Normal file
13
src/models/request/cipherCreateRequest.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { CipherRequest } from './cipherRequest';
|
||||
|
||||
import { Cipher } from '../domain/cipher';
|
||||
|
||||
export class CipherCreateRequest {
|
||||
cipher: CipherRequest;
|
||||
collectionIds: string[];
|
||||
|
||||
constructor(cipher: Cipher, collectionIds: string[]) {
|
||||
this.cipher = new CipherRequest(cipher);
|
||||
this.collectionIds = collectionIds;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import { CipherBulkDeleteRequest } from '../models/request/cipherBulkDeleteReque
|
||||
import { CipherBulkMoveRequest } from '../models/request/cipherBulkMoveRequest';
|
||||
import { CipherBulkShareRequest } from '../models/request/cipherBulkShareRequest';
|
||||
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
|
||||
import { CipherCreateRequest } from '../models/request/cipherCreateRequest';
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { CipherShareRequest } from '../models/request/cipherShareRequest';
|
||||
import { CollectionRequest } from '../models/request/collectionRequest';
|
||||
@ -337,7 +338,12 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return new CipherResponse(r);
|
||||
}
|
||||
|
||||
async postCipherAdmin(request: CipherRequest): Promise<CipherResponse> {
|
||||
async postCipherCreate(request: CipherCreateRequest): Promise<CipherResponse> {
|
||||
const r = await this.send('POST', '/ciphers/create', request, true, true);
|
||||
return new CipherResponse(r);
|
||||
}
|
||||
|
||||
async postCipherAdmin(request: CipherCreateRequest): Promise<CipherResponse> {
|
||||
const r = await this.send('POST', '/ciphers/admin', request, true, true);
|
||||
return new CipherResponse(r);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import { CipherBulkDeleteRequest } from '../models/request/cipherBulkDeleteReque
|
||||
import { CipherBulkMoveRequest } from '../models/request/cipherBulkMoveRequest';
|
||||
import { CipherBulkShareRequest } from '../models/request/cipherBulkShareRequest';
|
||||
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
|
||||
import { CipherCreateRequest } from '../models/request/cipherCreateRequest';
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { CipherShareRequest } from '../models/request/cipherShareRequest';
|
||||
|
||||
@ -438,14 +439,19 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
await this.storageService.save(Keys.neverDomains, domains);
|
||||
}
|
||||
|
||||
async saveWithServer(cipher: Cipher): Promise<any> {
|
||||
const request = new CipherRequest(cipher);
|
||||
|
||||
async saveWithServer(cipher: Cipher, collectionIds: string[] = null): Promise<any> {
|
||||
let response: CipherResponse;
|
||||
if (cipher.id == null) {
|
||||
response = await this.apiService.postCipher(request);
|
||||
if (collectionIds != null) {
|
||||
const request = new CipherCreateRequest(cipher, collectionIds);
|
||||
response = await this.apiService.postCipherCreate(request);
|
||||
} else {
|
||||
const request = new CipherRequest(cipher);
|
||||
response = await this.apiService.postCipher(request);
|
||||
}
|
||||
cipher.id = response.id;
|
||||
} else {
|
||||
const request = new CipherRequest(cipher);
|
||||
response = await this.apiService.putCipher(cipher.id, request);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user