Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ConvertKit_API_Traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,10 @@ public function filter_subscribers(
foreach ($all as $condition) {
$option = [];

if (array_key_exists('type', $condition) && !empty($condition['type'])) {
$option['type'] = $condition['type'];
}

if (array_key_exists('count_greater_than', $condition) && $condition['count_greater_than'] !== null) {
$option['count_greater_than'] = $condition['count_greater_than'];
}
Expand All @@ -1554,6 +1558,10 @@ public function filter_subscribers(
$option['before'] = $condition['before']->format('Y-m-d');
}

if (array_key_exists('states', $condition) && !empty($condition['states'])) {
$option['states'] = (array) $condition['states'];
}

if (array_key_exists('any', $condition) && !empty($condition['any'])) {
$option['any'] = (array) $condition['any'];
}
Expand Down
25 changes: 24 additions & 1 deletion tests/ConvertKitAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4483,7 +4483,7 @@ public function testFilterSubscribersWithMultipleConditions()

/**
* Test that filter_subscribers() returns the expected data
* when multiple any conditions are specified.
* when no parameters are specified.
*
* @since 2.4.0
*
Expand All @@ -4498,6 +4498,29 @@ public function testFilterSubscribersWithNoParameters()
$this->assertPaginationExists($result);
}

/**
* Test that filter_subscribers() throws a ServerException
* when invalid parameters are specified.
*
* @since 2.4.0
*
* @return void
*/
public function testFilterSubscribersWithInvalidParameters()
{
$this->expectException(ServerException::class);
$result = $this->api->filter_subscribers(
[
[
'foo' => 'bar',
],
[
'type' => 'not-a-real-type',
]
]
);
}

/**
* Test that filter_subscribers() returns the expected data
* when the total count is included.
Expand Down
Loading