From 081b2b61d47536a042c01c1cb2395b8de662ba99 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 8 Jun 2026 11:28:06 +0100 Subject: [PATCH 1/6] `filter_subscribers()`: Add `type` and `states` --- src/ConvertKit_API_Traits.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ConvertKit_API_Traits.php b/src/ConvertKit_API_Traits.php index f758017..d9b63a1 100644 --- a/src/ConvertKit_API_Traits.php +++ b/src/ConvertKit_API_Traits.php @@ -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']; } @@ -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']; } From 708e9da9227445a321e49f245c6bf3e876f3ecba Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 8 Jun 2026 11:29:55 +0100 Subject: [PATCH 2/6] Updated tests --- tests/ConvertKitAPITest.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/ConvertKitAPITest.php b/tests/ConvertKitAPITest.php index cb07ce6..805a2e1 100644 --- a/tests/ConvertKitAPITest.php +++ b/tests/ConvertKitAPITest.php @@ -4483,13 +4483,36 @@ 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 * * @return void */ public function testFilterSubscribersWithNoParameters() + { + $this->expectException(ClientException::class); + $result = $this->api->filter_subscribers( + [ + [ + 'foo' => 'bar', + ], + [ + 'type' => 'not-a-real-type', + ] + ] + ); + } + + /** + * Test that filter_subscribers() throws a ClientException + * when invalid parameters are specified. + * + * @since 2.4.0 + * + * @return void + */ + public function testFilterSubscribersWithInvalidParameters() { $result = $this->api->filter_subscribers(); From 5ae4a9ea8b117d2d6b8977083aa4c48f200bb1e0 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 8 Jun 2026 11:31:26 +0100 Subject: [PATCH 3/6] Fix test --- tests/ConvertKitAPITest.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/ConvertKitAPITest.php b/tests/ConvertKitAPITest.php index 805a2e1..3314dae 100644 --- a/tests/ConvertKitAPITest.php +++ b/tests/ConvertKitAPITest.php @@ -4491,17 +4491,11 @@ public function testFilterSubscribersWithMultipleConditions() */ public function testFilterSubscribersWithNoParameters() { - $this->expectException(ClientException::class); - $result = $this->api->filter_subscribers( - [ - [ - 'foo' => 'bar', - ], - [ - 'type' => 'not-a-real-type', - ] - ] - ); + $result = $this->api->filter_subscribers(); + + // Assert subscribers and pagination exist. + $this->assertDataExists($result, 'subscribers'); + $this->assertPaginationExists($result); } /** @@ -4514,11 +4508,17 @@ public function testFilterSubscribersWithNoParameters() */ public function testFilterSubscribersWithInvalidParameters() { - $result = $this->api->filter_subscribers(); - - // Assert subscribers and pagination exist. - $this->assertDataExists($result, 'subscribers'); - $this->assertPaginationExists($result); + $this->expectException(ClientException::class); + $result = $this->api->filter_subscribers( + [ + [ + 'foo' => 'bar', + ], + [ + 'type' => 'not-a-real-type', + ] + ] + ); } /** From 3c8b03f8be28d0aca5f20c9d735d14d26b6bfc24 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 11 Jun 2026 22:49:59 +0100 Subject: [PATCH 4/6] Fix test --- tests/ConvertKitAPITest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ConvertKitAPITest.php b/tests/ConvertKitAPITest.php index 477bc1e..fedf928 100644 --- a/tests/ConvertKitAPITest.php +++ b/tests/ConvertKitAPITest.php @@ -4499,7 +4499,7 @@ public function testFilterSubscribersWithNoParameters() } /** - * Test that filter_subscribers() throws a ClientException + * Test that filter_subscribers() throws a ServerException * when invalid parameters are specified. * * @since 2.4.0 @@ -4508,7 +4508,7 @@ public function testFilterSubscribersWithNoParameters() */ public function testFilterSubscribersWithInvalidParameters() { - $this->expectException(ClientException::class); + $this->expectException(ServerException::class); $result = $this->api->filter_subscribers( [ [ From 181cb8152762cfb65f705cf0166cd9c884834960 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 16 Jun 2026 19:49:18 +0800 Subject: [PATCH 5/6] Tests: Include `states` --- tests/ConvertKitAPITest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/ConvertKitAPITest.php b/tests/ConvertKitAPITest.php index fedf928..5d135e0 100644 --- a/tests/ConvertKitAPITest.php +++ b/tests/ConvertKitAPITest.php @@ -4438,6 +4438,9 @@ public function testFilterSubscribers() 'count_less_than' => 100, 'after' => new \DateTime('2024-01-01'), 'before' => new \DateTime('2027-01-01'), + 'states' => [ + 'active', + ], ] ] ); @@ -4465,6 +4468,9 @@ public function testFilterSubscribersWithMultipleConditions() 'count_less_than' => 100, 'after' => new \DateTime('2024-01-01'), 'before' => new \DateTime('2027-01-01'), + 'states' => [ + 'active', + ], ], [ 'type' => 'clicks', From 3c70c389cb53b79c6ddb34077d35eddc18af5d57 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 16 Jun 2026 20:03:05 +0800 Subject: [PATCH 6/6] Update docblock comment --- src/ConvertKit_API_Traits.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ConvertKit_API_Traits.php b/src/ConvertKit_API_Traits.php index 75dbf94..93f1c2e 100644 --- a/src/ConvertKit_API_Traits.php +++ b/src/ConvertKit_API_Traits.php @@ -1514,6 +1514,7 @@ public function create_subscribers(array $subscribers, string $callback_url = '' * - 'count_less_than' (int|null). * - 'after' (\DateTime|null). * - 'before' (\DateTime|null). + * - 'states' (array). * - 'any' (array|null). * @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.