From 081b2b61d47536a042c01c1cb2395b8de662ba99 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 8 Jun 2026 11:28:06 +0100 Subject: [PATCH 1/4] `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/4] 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/4] 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/4] 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( [ [