Skip to content

Commit

Permalink
feat: Adding ability to get a singular member of a project or group, …
Browse files Browse the repository at this point in the history
…including inheritedMemebrs (#508)

BREAKING CHANGE: Updated the Members.all function to have the inheritedMembers option to be in the optional object.

closes: #507
  • Loading branch information
jdalrymple authored Dec 9, 2019
1 parent 63b1157 commit 807171c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/core/templates/ResourceMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ import {
RequestHelper,
Sudo,
} from '../infrastructure';

import { AccessLevel } from './ResourceAccessRequests';

interface IncludeInherited {
includeInherited?: boolean;
}

export class ResourceMembers extends BaseService {
constructor(resourceType: string, options: BaseServiceOptions) {
super({ url: resourceType, ...options });
}

all(resourceId: string | number, includeInherited = false, options?: PaginatedRequestOptions) {
all(
resourceId: string | number,
{ includeInherited, ...options }: IncludeInherited & PaginatedRequestOptions = {},
) {
const rId = encodeURIComponent(resourceId);
const url = [rId, 'members'];

Expand Down Expand Up @@ -52,10 +58,19 @@ export class ResourceMembers extends BaseService {
});
}

show(resourceId: string | number, userId: number, options?: Sudo) {
show(
resourceId: string | number,
userId: number,
{ includeInherited, ...options }: IncludeInherited & Sudo = {},
) {
const [rId, uId] = [resourceId, userId].map(encodeURIComponent);
const url = [rId, 'members'];

if (includeInherited) url.push('all');

url.push(uId);

return RequestHelper.get(this, `${rId}/members/${uId}`, options);
return RequestHelper.get(this, url.join('/'), { options });
}

remove(resourceId: string | number, userId: number, options?: Sudo) {
Expand Down

0 comments on commit 807171c

Please sign in to comment.