|
|
|
|
@ -13,6 +13,7 @@ import { OrganizationUserStatusType } from '../enums/organizationUserStatusType'
@@ -13,6 +13,7 @@ import { OrganizationUserStatusType } from '../enums/organizationUserStatusType'
|
|
|
|
|
import { OrganizationUserType } from '../enums/organizationUserType'; |
|
|
|
|
import { PolicyType } from '../enums/policyType'; |
|
|
|
|
|
|
|
|
|
import { ApiService } from '../abstractions/api.service'; |
|
|
|
|
import { ListResponse } from '../models/response/listResponse'; |
|
|
|
|
import { PolicyResponse } from '../models/response/policyResponse'; |
|
|
|
|
|
|
|
|
|
@ -23,7 +24,8 @@ const Keys = {
@@ -23,7 +24,8 @@ const Keys = {
|
|
|
|
|
export class PolicyService implements PolicyServiceAbstraction { |
|
|
|
|
policyCache: Policy[]; |
|
|
|
|
|
|
|
|
|
constructor(private userService: UserService, private storageService: StorageService) { |
|
|
|
|
constructor(private userService: UserService, private storageService: StorageService, |
|
|
|
|
private apiService: ApiService) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clearCache(): void { |
|
|
|
|
@ -51,6 +53,18 @@ export class PolicyService implements PolicyServiceAbstraction {
@@ -51,6 +53,18 @@ export class PolicyService implements PolicyServiceAbstraction {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getPolicyForOrganization(policyType: PolicyType, organizationId: string): Promise<Policy> { |
|
|
|
|
const org = await this.userService.getOrganization(organizationId); |
|
|
|
|
if (org?.isProviderUser) { |
|
|
|
|
const orgPolicies = await this.apiService.getPolicies(organizationId); |
|
|
|
|
const policy = orgPolicies.data.find(p => p.organizationId === organizationId); |
|
|
|
|
|
|
|
|
|
if (policy == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return new Policy(new PolicyData(policy)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const policies = await this.getAll(policyType); |
|
|
|
|
return policies.find(p => p.organizationId === organizationId); |
|
|
|
|
} |
|
|
|
|
|