From a597aeaddabf1a58c2850a803d03bb213457ec28 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 18 May 2026 14:14:26 +0800 Subject: [PATCH 1/2] List Subscribers: Add Support for `include` parameter --- src/ConvertKit_API_Traits.php | 5 +++++ tests/ConvertKitAPITest.php | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/ConvertKit_API_Traits.php b/src/ConvertKit_API_Traits.php index 42dd987..ace755a 100644 --- a/src/ConvertKit_API_Traits.php +++ b/src/ConvertKit_API_Traits.php @@ -1167,6 +1167,7 @@ public function get_post(int $id) * @param \DateTime|null $updated_before Filter subscribers who have been updated before this date. * @param string $sort_field Sort Field (id|updated_at|cancelled_at). * @param string $sort_order Sort Order (asc|desc). + * @param array $include Additional fields to include: attribution, tags, location, canceled_at. * @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. @@ -1187,6 +1188,7 @@ public function get_subscribers( \DateTime|null $updated_before = null, string $sort_field = 'id', string $sort_order = 'desc', + array $include = [], bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', @@ -1219,6 +1221,9 @@ public function get_subscribers( if (!empty($sort_order)) { $options['sort_order'] = $sort_order; } + if (!empty($include)) { + $options['include'] = implode(',', $include); + } // Send request. return $this->get( diff --git a/tests/ConvertKitAPITest.php b/tests/ConvertKitAPITest.php index be0af11..10e72e4 100644 --- a/tests/ConvertKitAPITest.php +++ b/tests/ConvertKitAPITest.php @@ -3690,6 +3690,28 @@ public function testGetSubscribersWithSortOrderParam() ); } + /** + * Test that get_subscribers() returns the expected data + * when the include parameter is used. + * + * @since 2.5.0 + * + * @return void + */ + public function testGetSubscribersWithIncludeParam() + { + $result = $this->api->get_subscribers( + include: ['tags'] + ); + + // Assert subscribers and pagination exist. + $this->assertDataExists($result, 'subscribers'); + $this->assertPaginationExists($result); + + // Assert fields are included. + $this->assertArrayHasKey('tags', get_object_vars($result->subscribers[0])); + } + /** * Test that get_subscribers() returns the expected data * when pagination parameters and per_page limits are specified. From f29083fb2949605fe44b579b1fad9aadb899d5a1 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 18 May 2026 17:15:42 +0800 Subject: [PATCH 2/2] PHPStan compat. --- src/ConvertKit_API_Traits.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ConvertKit_API_Traits.php b/src/ConvertKit_API_Traits.php index b24b973..7462457 100644 --- a/src/ConvertKit_API_Traits.php +++ b/src/ConvertKit_API_Traits.php @@ -1170,7 +1170,7 @@ public function get_post(int $id) * @param \DateTime|null $updated_before Filter subscribers who have been updated before this date. * @param string $sort_field Sort Field (id|updated_at|cancelled_at). * @param string $sort_order Sort Order (asc|desc). - * @param array $include Additional fields to include: attribution, tags, location, canceled_at. + * @param array $include Additional fields to include: attribution, tags, location, canceled_at. * @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.