diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index 977a893862..3a8b104d82 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -33,6 +33,7 @@ import { PasswordHintRequest } from '../models/request/passwordHintRequest'; import { PasswordRequest } from '../models/request/passwordRequest'; import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest'; import { PaymentRequest } from '../models/request/paymentRequest'; +import { PolicyRequest } from '../models/request/policyRequest'; import { PreloginRequest } from '../models/request/preloginRequest'; import { RegisterRequest } from '../models/request/registerRequest'; import { SeatRequest } from '../models/request/seatRequest'; @@ -80,6 +81,7 @@ import { OrganizationUserUserDetailsResponse, } from '../models/response/organizationUserResponse'; import { PaymentResponse } from '../models/response/paymentResponse'; +import { PolicyResponse } from '../models/response/policyResponse'; import { PreloginResponse } from '../models/response/preloginResponse'; import { ProfileResponse } from '../models/response/profileResponse'; import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse'; @@ -186,6 +188,12 @@ export abstract class ApiService { deleteGroup: (organizationId: string, id: string) => Promise; deleteGroupUser: (organizationId: string, id: string, organizationUserId: string) => Promise; + getPolicy: (organizationId: string, id: string) => Promise; + getPolicies: (organizationId: string) => Promise>; + postPolicy: (organizationId: string, request: PolicyRequest) => Promise; + putPolicy: (organizationId: string, id: string, request: PolicyRequest) => Promise; + deletePolicy: (organizationId: string, id: string) => Promise; + getOrganizationUser: (organizationId: string, id: string) => Promise; getOrganizationUserGroups: (organizationId: string, id: string) => Promise; getOrganizationUsers: (organizationId: string) => Promise>; diff --git a/src/models/request/policyRequest.ts b/src/models/request/policyRequest.ts new file mode 100644 index 0000000000..a1314d08ac --- /dev/null +++ b/src/models/request/policyRequest.ts @@ -0,0 +1,7 @@ +import { PolicyType } from '../../enums/policyType'; + +export class PolicyRequest { + type: PolicyType; + enabled: boolean; + data: any; +} diff --git a/src/models/response/policyResponse.ts b/src/models/response/policyResponse.ts new file mode 100644 index 0000000000..2fa931f324 --- /dev/null +++ b/src/models/response/policyResponse.ts @@ -0,0 +1,20 @@ +import { BaseResponse } from './baseResponse'; + +import { PolicyType } from '../../enums/policyType'; + +export class PolicyResponse extends BaseResponse { + id: string; + organizationId: string; + type: PolicyType; + data: any; + enabled: boolean; + + constructor(response: any) { + super(response); + this.id = this.getResponseProperty('Id'); + this.organizationId = this.getResponseProperty('OrganizationId'); + this.type = this.getResponseProperty('Type'); + this.data = this.getResponseProperty('Data'); + this.enabled = this.getResponseProperty('Enabled'); + } +} diff --git a/src/services/api.service.ts b/src/services/api.service.ts index a1a0ca3c55..4ceec11601 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -39,6 +39,7 @@ import { PasswordHintRequest } from '../models/request/passwordHintRequest'; import { PasswordRequest } from '../models/request/passwordRequest'; import { PasswordVerificationRequest } from '../models/request/passwordVerificationRequest'; import { PaymentRequest } from '../models/request/paymentRequest'; +import { PolicyRequest } from '../models/request/policyRequest'; import { PreloginRequest } from '../models/request/preloginRequest'; import { RegisterRequest } from '../models/request/registerRequest'; import { SeatRequest } from '../models/request/seatRequest'; @@ -87,6 +88,7 @@ import { OrganizationUserUserDetailsResponse, } from '../models/response/organizationUserResponse'; import { PaymentResponse } from '../models/response/paymentResponse'; +import { PolicyResponse } from '../models/response/policyResponse'; import { PreloginResponse } from '../models/response/preloginResponse'; import { ProfileResponse } from '../models/response/profileResponse'; import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse'; @@ -549,6 +551,32 @@ export class ApiService implements ApiServiceAbstraction { '/organizations/' + organizationId + '/groups/' + id + '/user/' + organizationUserId, null, true, false); } + // Policy APIs + + async getPolicy(organizationId: string, id: string): Promise { + const r = await this.send('GET', '/organizations/' + organizationId + '/policies/' + id, null, true, true); + return new PolicyResponse(r); + } + + async getPolicies(organizationId: string): Promise> { + const r = await this.send('GET', '/organizations/' + organizationId + '/policies', null, true, true); + return new ListResponse(r, PolicyResponse); + } + + async postPolicy(organizationId: string, request: PolicyRequest): Promise { + const r = await this.send('POST', '/organizations/' + organizationId + '/policies', request, true, true); + return new PolicyResponse(r); + } + + async putPolicy(organizationId: string, id: string, request: PolicyRequest): Promise { + const r = await this.send('PUT', '/organizations/' + organizationId + '/policies/' + id, request, true, true); + return new PolicyResponse(r); + } + + deletePolicy(organizationId: string, id: string): Promise { + return this.send('DELETE', '/organizations/' + organizationId + '/policies/' + id, null, true, false); + } + // Organization User APIs async getOrganizationUser(organizationId: string, id: string): Promise {