Skip to content

Commit 831c2b8

Browse files
committed
Add a way fetch community memebers
Intereacts with the `community_members` endpoint.
1 parent 04ad647 commit 831c2b8

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

src/Endpoint/Member/Members.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@
1313

1414
final class Members extends AbstractEndpoint implements EndpointInterface
1515
{
16+
public function communityMembers(
17+
?string $sortBy = null,
18+
?int $perPage = null,
19+
?int $page = null,
20+
?string $status = null,
21+
?int $communityId = null,
22+
): mixed {
23+
$this->ensureCommunityIdIsPresent($communityId);
24+
25+
$query = [
26+
'sort' => $sortBy ?? 'latest',
27+
'per_page' => $perPage ?? 10,
28+
'page' => $page ?? 1,
29+
'status' => $status ?? 'active',
30+
];
31+
32+
return $this->factorResponse(
33+
$this->circleSo->getHttpClient()->get(
34+
"/community_members?" . http_build_query($query)
35+
)
36+
);
37+
}
38+
1639
/**
1740
* @throws CommunityIdNotPresentException
1841
*/

tests/CircleSoTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ public function test_get_me_not_authorized(): void
4646
$circleSo->me()->info();
4747
}
4848

49+
public function test_community_members_ok(): void
50+
{
51+
$circleSo = $this->getSdkWithMockedClient([
52+
new Response(200, [], json_response('community_members')),
53+
]);
54+
55+
$communityMembers = $circleSo->members()
56+
->communityId(1)
57+
->communityMembers(perPage: 2);
58+
59+
$this->assertCount(2, $communityMembers);
60+
61+
$this->assertSame(1, $communityMembers[0]['id']);
62+
$this->assertSame('Adro', $communityMembers[0]['first_name']);
63+
$this->assertSame('Adro Morelos', $communityMembers[0]['name']);
64+
}
65+
4966
public function test_member_search_ok(): void
5067
{
5168
$circleSo = $this->getSdkWithMockedClient([
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[
2+
{
3+
"id": 1,
4+
"first_name": "Adro",
5+
"last_name": "Morelos",
6+
"headline": "",
7+
"bio": "",
8+
"created_at": "2022-09-26T19:42:37.862Z",
9+
"updated_at": "2023-03-30T14:51:42.959Z",
10+
"community_id": 1,
11+
"member_tags": [],
12+
"last_seen_at": "2023-03-30T14:51:42.000Z",
13+
"profile_url": "https://circle.com/u/123456",
14+
"public_uid": "123456",
15+
"profile_fields": [],
16+
"avatar_url": "https://ui-avatars.com/api/?name=Adro+Morelos",
17+
"user_id": 2,
18+
"name": "Adro Morelos",
19+
"email": "[email protected]",
20+
"topics_count": 0,
21+
"posts_count": 0,
22+
"comments_count": 0,
23+
"location": "",
24+
"website_url": "",
25+
"instagram_url": "",
26+
"twitter_url": "",
27+
"linkedin_url": "",
28+
"facebook_url": "",
29+
"accepted_invitation": "2023-01-01T00:00:00.000Z",
30+
"active": true,
31+
"sso_provider_user_id": "123456"
32+
},
33+
{
34+
"id": 2,
35+
"first_name": "Adro",
36+
"last_name": "Rocker",
37+
"headline": "",
38+
"bio": "",
39+
"created_at": "2022-09-26T19:42:37.862Z",
40+
"updated_at": "2023-03-30T14:51:42.959Z",
41+
"community_id": 1,
42+
"member_tags": [
43+
{
44+
"name": "Member Tag",
45+
"id": 123
46+
}
47+
],
48+
"last_seen_at": "2023-03-30T14:51:42.000Z",
49+
"profile_url": "https://circle.com/u/123456",
50+
"public_uid": "123456",
51+
"profile_fields": [],
52+
"avatar_url": "https://ui-avatars.com/api/?name=Adro+Morelos",
53+
"user_id": 2,
54+
"name": "Adro Morelos",
55+
"email": "[email protected]",
56+
"topics_count": 0,
57+
"posts_count": 0,
58+
"comments_count": 0,
59+
"location": "",
60+
"website_url": "",
61+
"instagram_url": "",
62+
"twitter_url": "",
63+
"linkedin_url": "",
64+
"facebook_url": "",
65+
"accepted_invitation": "2023-01-01T00:00:00.000Z",
66+
"active": true,
67+
"sso_provider_user_id": "123456"
68+
}
69+
]

0 commit comments

Comments
 (0)