Skip to content
Merged
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
9 changes: 8 additions & 1 deletion src/ConvertKit_API_Traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,9 @@ public function create_subscribers(array $subscribers, string $callback_url = ''
* - 'before' (\DateTime|null).
* - 'states' (array<string>).
* - 'any' (array<int|string, mixed>|null).
* @param string $counting_mode Controls how engagement-filter count thresholds are tallied.
* - 'raw' (default) counts every event — five opens of the same email = five.
* - 'unique_email' counts distinct emails on which the action occurred.
* @param boolean $include_total_count To include the total count of records in the response, use true.
* @param string $after_cursor Return results after the given pagination cursor.
* @param string $before_cursor Return results before the given pagination cursor.
Expand All @@ -1529,6 +1532,7 @@ public function create_subscribers(array $subscribers, string $callback_url = ''
*/
public function filter_subscribers(
array $all = [],
string $counting_mode = 'raw',
bool $include_total_count = false,
string $after_cursor = '',
string $before_cursor = '',
Expand Down Expand Up @@ -1573,7 +1577,10 @@ public function filter_subscribers(
return $this->post(
'subscribers/filter',
$this->build_total_count_and_pagination_params(
['all' => $options],
[
'all' => $options,
'counting_mode' => $counting_mode,
],
$include_total_count,
$after_cursor,
$before_cursor,
Expand Down
31 changes: 31 additions & 0 deletions tests/ConvertKitAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4487,6 +4487,37 @@ public function testFilterSubscribersWithMultipleConditions()
$this->assertPaginationExists($result);
}

/**
* Test that filter_subscribers() returns the expected data
* when a counting mode is specified.
*
* @since 2.5.0
*
* @return void
*/
public function testFilterSubscribersWithCountingMode()
{
$result = $this->api->filter_subscribers(
all: [
[
'type' => 'opens',
'count_greater_than' => 10,
'count_less_than' => 100,
'after' => new \DateTime('2024-01-01'),
'before' => new \DateTime('2027-01-01'),
'states' => [
'active',
],
]
],
counting_mode: 'unique_email'
);

// Assert subscribers and pagination exist.
$this->assertDataExists($result, 'subscribers');
$this->assertPaginationExists($result);
}

/**
* Test that filter_subscribers() returns the expected data
* when no parameters are specified.
Expand Down
Loading