Skip to content

Commit

Permalink
Merge pull request #14 from mailerlite/feature/issue-13/params-on-gro…
Browse files Browse the repository at this point in the history
…up-subscribers-call

Add params support to the get group subscribers call
  • Loading branch information
johnkelesidis authored Aug 30, 2023
2 parents 34efe64 + 6c9b21b commit 11d8385
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Endpoints/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ public function delete(string $groupId): array
}

/**
* @param string $groupId
* @param array<string, mixed> $params
*
* @return array<string, mixed>
*/
public function getSubscribers(string $groupId): array
public function getSubscribers(string $groupId, array $params = []): array
{
return $this->httpLayer->get(
$this->buildUri($this->endpoint) . "/{$groupId}/subscribers"
$this->buildUri($this->endpoint . "/{$groupId}/subscribers", $params)
);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Endpoints/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ public function test_get_group_subscribers()
self::assertEquals("/api/groups/{$this->groupId}/subscribers", $request->getUri()->getPath());
}

public function test_get_group_subscribers_pagination()
{
$this->groups->getSubscribers($this->groupId, [
'cursor' => 'next_page_cursor'
]);

$request = $this->client->getLastRequest();

self::assertEquals('GET', $request->getMethod());
self::assertEquals("cursor=next_page_cursor", $request->getUri()->getQuery());
}

public function test_assign_subscriber_to_group()
{
$subscriberId = '4567';
Expand Down

0 comments on commit 11d8385

Please sign in to comment.