Skip to content

Commit fa01676

Browse files
committed
fix(taggedMemebers) - Fix issue when email param is array.
This fixes the issue when the $email param is an array. This use case was not supported even tho the signature of the function allowed it.
1 parent d74d74d commit fa01676

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Endpoint/TaggedMembers/TaggedMembers.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ final class TaggedMembers extends AbstractEndpoint implements EndpointInterface
1818
*/
1919
public function tagMember(string|array $email, int $memberTagId): mixed
2020
{
21+
if (is_array($email)) {
22+
$emailParam = '';
23+
foreach ($email as $e) {
24+
$emailParam .= "user_email[]={$e}&";
25+
}
26+
27+
$emailParam = trim($emailParam, '&');
28+
} else {
29+
$emailParam = "user_email={$email}";
30+
}
31+
2132
return $this->factorResponse(
2233
$this->circleSo->getHttpClient()->post(
23-
"/tagged_members?user_email={$email}&member_tag_id={$memberTagId}"
34+
"/tagged_members?{$emailParam}&member_tag_id={$memberTagId}"
2435
)
2536
);
2637
}

tests/Endpoint/TaggedMembers/TaggedMembersTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ public function test_tag_member_ok(): void
2626
$this->assertSame(true, $response['success']);
2727
}
2828

29+
public function test_tag_member_array_ok(): void
30+
{
31+
$circleSo = $this->getSdkWithMockedClient([
32+
new Response(200, [], json_response('success_true')),
33+
]);
34+
35+
$response = $circleSo->taggedMembers()
36+
->tagMember(['[email protected]', '[email protected]'], 123456);
37+
38+
$this->assertArrayHasKey('success', $response);
39+
40+
$this->assertSame(true, $response['success']);
41+
}
42+
2943
public function test_untag_member_ok(): void
3044
{
3145
$circleSo = $this->getSdkWithMockedClient([

0 commit comments

Comments
 (0)