mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
sync policies., set up policy service
This commit is contained in:
19
src/models/data/policyData.ts
Normal file
19
src/models/data/policyData.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { PolicyResponse } from '../response/policyResponse';
|
||||
|
||||
import { PolicyType } from '../../enums/policyType';
|
||||
|
||||
export class PolicyData {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
type: PolicyType;
|
||||
data: any;
|
||||
enabled: boolean;
|
||||
|
||||
constructor(response: PolicyResponse) {
|
||||
this.id = response.id;
|
||||
this.organizationId = response.organizationId;
|
||||
this.type = response.type;
|
||||
this.data = response.data;
|
||||
this.enabled = response.enabled;
|
||||
}
|
||||
}
|
||||
26
src/models/domain/policy.ts
Normal file
26
src/models/domain/policy.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { PolicyData } from '../data/policyData';
|
||||
|
||||
import Domain from './domainBase';
|
||||
|
||||
import { PolicyType } from '../../enums/policyType';
|
||||
|
||||
export class Policy extends Domain {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
type: PolicyType;
|
||||
data: any;
|
||||
enabled: boolean;
|
||||
|
||||
constructor(obj?: PolicyData) {
|
||||
super();
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.id = obj.id;
|
||||
this.organizationId = obj.organizationId;
|
||||
this.type = obj.type;
|
||||
this.data = obj.data;
|
||||
this.enabled = obj.enabled;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { CipherResponse } from './cipherResponse';
|
||||
import { CollectionDetailsResponse } from './collectionResponse';
|
||||
import { DomainsResponse } from './domainsResponse';
|
||||
import { FolderResponse } from './folderResponse';
|
||||
import { PolicyResponse } from './policyResponse';
|
||||
import { ProfileResponse } from './profileResponse';
|
||||
|
||||
export class SyncResponse extends BaseResponse {
|
||||
@@ -11,6 +12,7 @@ export class SyncResponse extends BaseResponse {
|
||||
collections: CollectionDetailsResponse[] = [];
|
||||
ciphers: CipherResponse[] = [];
|
||||
domains?: DomainsResponse;
|
||||
policies?: PolicyResponse[] = [];
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
@@ -39,5 +41,10 @@ export class SyncResponse extends BaseResponse {
|
||||
if (domains != null) {
|
||||
this.domains = new DomainsResponse(domains);
|
||||
}
|
||||
|
||||
const policies = this.getResponseProperty('Policies');
|
||||
if (policies != null) {
|
||||
this.policies = policies.map((p: any) => new PolicyResponse(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user