From d1f7a97011f043a6225f603e71f0565acbe7dcdd Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 17 Oct 2018 22:56:28 -0400 Subject: [PATCH] group user apis --- src/abstractions/api.service.ts | 6 +++--- src/models/response/groupUserResponse.ts | 20 -------------------- src/services/api.service.ts | 13 ++++++++----- 3 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 src/models/response/groupUserResponse.ts diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index a2e5f48542..264da1bfa9 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -63,7 +63,6 @@ import { GroupDetailsResponse, GroupResponse, } from '../models/response/groupResponse'; -import { GroupUserResponse } from '../models/response/groupUserResponse'; import { IdentityTokenResponse } from '../models/response/identityTokenResponse'; import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse'; import { ListResponse } from '../models/response/listResponse'; @@ -158,7 +157,7 @@ export abstract class ApiService { getCollectionDetails: (organizationId: string, id: string) => Promise; getUserCollections: () => Promise>; getCollections: (organizationId: string) => Promise>; - getCollectionUsers: (organizationId: string, id: string) => Promise>; + getCollectionUsers: (organizationId: string, id: string) => Promise; postCollection: (organizationId: string, request: CollectionRequest) => Promise; putCollectionUsers: (organizationId: string, id: string, request: SelectionReadOnlyRequest[]) => Promise; putCollection: (organizationId: string, id: string, request: CollectionRequest) => Promise; @@ -167,9 +166,10 @@ export abstract class ApiService { getGroupDetails: (organizationId: string, id: string) => Promise; getGroups: (organizationId: string) => Promise>; - getGroupUsers: (organizationId: string, id: string) => Promise>; + getGroupUsers: (organizationId: string, id: string) => Promise; postGroup: (organizationId: string, request: GroupRequest) => Promise; putGroup: (organizationId: string, id: string, request: GroupRequest) => Promise; + putGroupUsers: (organizationId: string, id: string, request: string[]) => Promise; deleteGroup: (organizationId: string, id: string) => Promise; deleteGroupUser: (organizationId: string, id: string, organizationUserId: string) => Promise; diff --git a/src/models/response/groupUserResponse.ts b/src/models/response/groupUserResponse.ts deleted file mode 100644 index 0d8d25c30d..0000000000 --- a/src/models/response/groupUserResponse.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { OrganizationUserStatusType } from '../../enums/organizationUserStatusType'; -import { OrganizationUserType } from '../../enums/organizationUserType'; - -export class GroupUserResponse { - organizationUserId: string; - accessAll: boolean; - name: string; - email: string; - type: OrganizationUserType; - status: OrganizationUserStatusType; - - constructor(response: any) { - this.organizationUserId = response.OrganizationUserId; - this.accessAll = response.AccessAll; - this.name = response.Name; - this.email = response.Email; - this.type = response.Type; - this.status = response.Status; - } -} diff --git a/src/services/api.service.ts b/src/services/api.service.ts index a7b6f530c8..0206e3d643 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -70,7 +70,6 @@ import { GroupDetailsResponse, GroupResponse, } from '../models/response/groupResponse'; -import { GroupUserResponse } from '../models/response/groupUserResponse'; import { IdentityTokenResponse } from '../models/response/identityTokenResponse'; import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse'; import { ListResponse } from '../models/response/listResponse'; @@ -445,10 +444,10 @@ export class ApiService implements ApiServiceAbstraction { return new ListResponse(r, CollectionResponse); } - async getCollectionUsers(organizationId: string, id: string): Promise> { + async getCollectionUsers(organizationId: string, id: string): Promise { const r = await this.send('GET', '/organizations/' + organizationId + '/collections/' + id + '/users', null, true, true); - return new ListResponse(r, SelectionReadOnlyResponse); + return r.map((dr: any) => new SelectionReadOnlyResponse(dr)); } async postCollection(organizationId: string, request: CollectionRequest): Promise { @@ -490,10 +489,10 @@ export class ApiService implements ApiServiceAbstraction { return new ListResponse(r, GroupResponse); } - async getGroupUsers(organizationId: string, id: string): Promise> { + async getGroupUsers(organizationId: string, id: string): Promise { const r = await this.send('GET', '/organizations/' + organizationId + '/groups/' + id + '/users', null, true, true); - return new ListResponse(r, GroupUserResponse); + return r; } async postGroup(organizationId: string, request: GroupRequest): Promise { @@ -506,6 +505,10 @@ export class ApiService implements ApiServiceAbstraction { return new GroupResponse(r); } + async putGroupUsers(organizationId: string, id: string, request: string[]): Promise { + await this.send('PUT', '/organizations/' + organizationId + '/groups/' + id + '/users', request, true, false); + } + deleteGroup(organizationId: string, id: string): Promise { return this.send('DELETE', '/organizations/' + organizationId + '/groups/' + id, null, true, false); }