Skip to content

Commit 52f0602

Browse files
csrbarberclaude
andauthored
fix: listEnvironmentRoles should not use PaginatedResource (#341)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 52fb6b3 commit 52f0602

2 files changed

Lines changed: 12 additions & 34 deletions

File tree

lib/RBAC.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -183,33 +183,22 @@ public function createEnvironmentRole(
183183
/**
184184
* List Environment Roles.
185185
*
186-
* @param int $limit Maximum number of records to return
187-
* @param null|string $before Role ID to look before
188-
* @param null|string $after Role ID to look after
189-
* @param null|string $order The order in which to paginate records
190-
*
191186
* @throws Exception\WorkOSException
192187
*
193-
* @return Resource\PaginatedResource
188+
* @return Resource\Role[]
194189
*/
195-
public function listEnvironmentRoles(
196-
int $limit = self::DEFAULT_PAGE_SIZE,
197-
?string $before = null,
198-
?string $after = null,
199-
?string $order = null
200-
) {
190+
public function listEnvironmentRoles()
191+
{
201192
$path = "authorization/roles";
202193

203-
$params = [
204-
"limit" => $limit,
205-
"before" => $before,
206-
"after" => $after,
207-
"order" => $order,
208-
];
194+
$response = Client::request(Client::METHOD_GET, $path, null, null, true);
209195

210-
$response = Client::request(Client::METHOD_GET, $path, null, $params, true);
196+
$roles = [];
197+
foreach ($response["data"] as $responseData) {
198+
\array_push($roles, Resource\Role::constructFromResponse($responseData));
199+
}
211200

212-
return Resource\PaginatedResource::constructFromResponse($response, Resource\Role::class, 'roles');
201+
return $roles;
213202
}
214203

215204
/**

tests/WorkOS/RBACTest.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,26 +170,19 @@ public function testListEnvironmentRoles()
170170

171171
$result = $this->rolesListResponseFixture();
172172

173-
$params = [
174-
"limit" => RBAC::DEFAULT_PAGE_SIZE,
175-
"before" => null,
176-
"after" => null,
177-
"order" => null,
178-
];
179-
180173
$this->mockRequest(
181174
Client::METHOD_GET,
182175
$path,
183176
null,
184-
$params,
177+
null,
185178
true,
186179
$result
187180
);
188181

189182
$role = $this->roleFixture();
190183

191-
$response = $this->rbac->listEnvironmentRoles();
192-
$this->assertSame($role, $response->roles[0]->toArray());
184+
$roles = $this->rbac->listEnvironmentRoles();
185+
$this->assertSame($role, $roles[0]->toArray());
193186
}
194187

195188
public function testGetEnvironmentRole()
@@ -552,10 +545,6 @@ private function rolesListResponseFixture()
552545
"created_at" => "2024-01-01T00:00:00.000Z",
553546
"updated_at" => "2024-01-01T00:00:00.000Z"
554547
]
555-
],
556-
"list_metadata" => [
557-
"before" => null,
558-
"after" => null
559548
]
560549
]);
561550
}

0 commit comments

Comments
 (0)