group user apis

This commit is contained in:
Kyle Spearrin 2018-10-17 22:56:28 -04:00
parent 2b8ffea494
commit d1f7a97011
3 changed files with 11 additions and 28 deletions

View File

@ -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<CollectionGroupDetailsResponse>;
getUserCollections: () => Promise<ListResponse<CollectionResponse>>;
getCollections: (organizationId: string) => Promise<ListResponse<CollectionResponse>>;
getCollectionUsers: (organizationId: string, id: string) => Promise<ListResponse<SelectionReadOnlyResponse>>;
getCollectionUsers: (organizationId: string, id: string) => Promise<SelectionReadOnlyResponse[]>;
postCollection: (organizationId: string, request: CollectionRequest) => Promise<CollectionResponse>;
putCollectionUsers: (organizationId: string, id: string, request: SelectionReadOnlyRequest[]) => Promise<any>;
putCollection: (organizationId: string, id: string, request: CollectionRequest) => Promise<CollectionResponse>;
@ -167,9 +166,10 @@ export abstract class ApiService {
getGroupDetails: (organizationId: string, id: string) => Promise<GroupDetailsResponse>;
getGroups: (organizationId: string) => Promise<ListResponse<GroupResponse>>;
getGroupUsers: (organizationId: string, id: string) => Promise<ListResponse<GroupUserResponse>>;
getGroupUsers: (organizationId: string, id: string) => Promise<string[]>;
postGroup: (organizationId: string, request: GroupRequest) => Promise<GroupResponse>;
putGroup: (organizationId: string, id: string, request: GroupRequest) => Promise<GroupResponse>;
putGroupUsers: (organizationId: string, id: string, request: string[]) => Promise<any>;
deleteGroup: (organizationId: string, id: string) => Promise<any>;
deleteGroupUser: (organizationId: string, id: string, organizationUserId: string) => Promise<any>;

View File

@ -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;
}
}

View File

@ -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<ListResponse<SelectionReadOnlyResponse>> {
async getCollectionUsers(organizationId: string, id: string): Promise<SelectionReadOnlyResponse[]> {
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<CollectionResponse> {
@ -490,10 +489,10 @@ export class ApiService implements ApiServiceAbstraction {
return new ListResponse(r, GroupResponse);
}
async getGroupUsers(organizationId: string, id: string): Promise<ListResponse<GroupUserResponse>> {
async getGroupUsers(organizationId: string, id: string): Promise<string[]> {
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<GroupResponse> {
@ -506,6 +505,10 @@ export class ApiService implements ApiServiceAbstraction {
return new GroupResponse(r);
}
async putGroupUsers(organizationId: string, id: string, request: string[]): Promise<any> {
await this.send('PUT', '/organizations/' + organizationId + '/groups/' + id + '/users', request, true, false);
}
deleteGroup(organizationId: string, id: string): Promise<any> {
return this.send('DELETE', '/organizations/' + organizationId + '/groups/' + id, null, true, false);
}