Skip to content

Commit bec332a

Browse files
committed
Add patchMembers to GroupsService
1 parent c1c1ed5 commit bec332a

File tree

7 files changed

+39
-17
lines changed

7 files changed

+39
-17
lines changed

dist/Client.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export declare class Client {
5858
teams(): TeamsService;
5959
submissions(): SubmissionsService;
6060
permissions(): PermissionsService;
61-
groups(): GroupsService;
61+
groups(groupId?: string): GroupsService;
6262
vehicles(): VehiclesService;
6363
vehicleManufacturers(): VehicleManufacturersService;
6464
vehicleCategories(): VehicleCategoriesService;

dist/Client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ export class Client {
117117
permissions() {
118118
return new PermissionsService(this);
119119
}
120-
groups() {
121-
return new GroupsService(this);
120+
groups(groupId) {
121+
return new GroupsService(this, groupId);
122122
}
123123
vehicles() {
124124
return new VehiclesService(this);

dist/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,8 +1626,14 @@ class ServiceAccountKeysService extends BaseService {
16261626

16271627
// src/services/GroupService.ts
16281628
class GroupsService extends BaseService {
1629-
constructor(client) {
1630-
super(client, "/v3/orgs/:orgId/iam/groups");
1629+
constructor(client, groupId) {
1630+
const endpoint = groupId ? `/v3/orgs/:orgId/iam/groups/${groupId}` : `/v3/orgs/:orgId/iam/groups`;
1631+
super(client, endpoint);
1632+
}
1633+
async patchMembers(users) {
1634+
const jsonApiSerializer = new JsonApiSerializer(this.hydrator.getModelMap());
1635+
const payload = jsonApiSerializer.buildRelationshipPayload(new User, users);
1636+
return await this.client.makePatchRequest(`${this.endpoint}/relationships/members`, payload);
16311637
}
16321638
}
16331639

@@ -1955,8 +1961,8 @@ class Client {
19551961
permissions() {
19561962
return new PermissionsService(this);
19571963
}
1958-
groups() {
1959-
return new GroupsService(this);
1964+
groups(groupId) {
1965+
return new GroupsService(this, groupId);
19601966
}
19611967
vehicles() {
19621968
return new VehiclesService(this);
@@ -2116,9 +2122,6 @@ class ClientConfig {
21162122
}
21172123
// src/models/Organisation.ts
21182124
class Organisation extends BaseModel {
2119-
constructor() {
2120-
super(...arguments);
2121-
}
21222125
type = "organisations";
21232126
static relationships = [];
21242127
}

dist/services/GroupService.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { BaseService } from "../services/BaseService";
22
import { Client } from "../Client";
33
import { Group } from "../models/Group";
4+
import { User } from "../models/User";
45
export declare class GroupsService extends BaseService<Group> {
5-
constructor(client: Client);
6+
constructor(client: Client, groupId?: string);
7+
patchMembers(users: Array<User>): Promise<any>;
68
}

dist/services/GroupService.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { BaseService } from "../services/BaseService";
22
import { Client } from "../Client";
33
import { Group } from "../models/Group";
4+
import { User } from "../models/User";
5+
import { JsonApiSerializer } from '../utils/JsonSerializer';
46
export class GroupsService extends BaseService {
5-
constructor(client) {
6-
super(client, "/v3/orgs/:orgId/iam/groups");
7+
constructor(client, groupId) {
8+
const endpoint = groupId ? `/v3/orgs/:orgId/iam/groups/${groupId}` : `/v3/orgs/:orgId/iam/groups`;
9+
super(client, endpoint);
10+
}
11+
async patchMembers(users) {
12+
const jsonApiSerializer = new JsonApiSerializer(this.hydrator.getModelMap());
13+
const payload = jsonApiSerializer.buildRelationshipPayload(new User, users);
14+
return await this.client.makePatchRequest(`${this.endpoint}/relationships/members`, payload);
715
}
816
}

src/Client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ export class Client {
145145
return new PermissionsService(this);
146146
}
147147

148-
public groups(): GroupsService {
149-
return new GroupsService(this);
148+
public groups(groupId?: string): GroupsService {
149+
return new GroupsService(this, groupId);
150150
}
151151

152152
public vehicles(): VehiclesService {

src/services/GroupService.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import {BaseService} from "../services/BaseService";
22
import {Client} from "Client";
33
import {Group} from "../models/Group";
4+
import { User } from "@models/User";
5+
import { JsonApiSerializer } from '@utils/JsonSerializer';
46

57
export class GroupsService extends BaseService<Group> {
6-
constructor(client: Client) {
7-
super(client, "/v3/orgs/:orgId/iam/groups");
8+
constructor(client: Client, groupId?: string) {
9+
const endpoint = groupId ? `/v3/orgs/:orgId/iam/groups/${groupId}` : `/v3/orgs/:orgId/iam/groups`;
10+
super(client, endpoint);
11+
}
12+
13+
public async patchMembers(users: Array<User>) {
14+
const jsonApiSerializer = new JsonApiSerializer(this.hydrator.getModelMap());
15+
const payload = jsonApiSerializer.buildRelationshipPayload(new User, users);
16+
return await this.client.makePatchRequest(`${this.endpoint}/relationships/members`, payload);
817
}
918
}

0 commit comments

Comments
 (0)