mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
[AC-2276] Move policyService helper methods to domain object (#8254)
* Move mapPolicyFromResponse and mapPoliciesFromToken to static factory methods
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { ListResponse } from "../../../models/response/list.response";
|
||||
import Domain from "../../../platform/models/domain/domain-base";
|
||||
import { PolicyId } from "../../../types/guid";
|
||||
import { PolicyType } from "../../enums";
|
||||
import { PolicyData } from "../data/policy.data";
|
||||
import { PolicyResponse } from "../response/policy.response";
|
||||
|
||||
export class Policy extends Domain {
|
||||
id: PolicyId;
|
||||
@@ -27,4 +29,12 @@ export class Policy extends Domain {
|
||||
this.data = obj.data;
|
||||
this.enabled = obj.enabled;
|
||||
}
|
||||
|
||||
static fromResponse(response: PolicyResponse): Policy {
|
||||
return new Policy(new PolicyData(response));
|
||||
}
|
||||
|
||||
static fromListResponse(response: ListResponse<PolicyResponse>): Policy[] | undefined {
|
||||
return response.data?.map((d) => Policy.fromResponse(d)) ?? undefined;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user