diff --git a/src/ConvertKit_API_Traits.php b/src/ConvertKit_API_Traits.php index 200bc32..7462457 100644 --- a/src/ConvertKit_API_Traits.php +++ b/src/ConvertKit_API_Traits.php @@ -1170,6 +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 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. @@ -1190,6 +1191,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 = '', @@ -1222,6 +1224,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 09f64fe..3fbdded 100644 --- a/tests/ConvertKitAPITest.php +++ b/tests/ConvertKitAPITest.php @@ -3721,6 +3721,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.