Skip to content

Commit

Permalink
Add params support to the get group subscribers call
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkelesidis committed Aug 29, 2023
1 parent 34efe64 commit f4e23af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Endpoints/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public function delete(string $groupId): array
/**
* @return array<string, mixed>
*/
public function getSubscribers(string $groupId): array
public function getSubscribers(string $groupId, array $params = []): array

Check failure on line 70 in src/Endpoints/Group.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test on ubuntu-latest

Method MailerLite\Endpoints\Group::getSubscribers() has parameter $params with no value type specified in iterable type 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 f4e23af

Please sign in to comment.