Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/ConvertKit_API_Traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> $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.
Expand All @@ -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 = '',
Expand Down Expand Up @@ -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(
Expand Down
22 changes: 22 additions & 0 deletions tests/ConvertKitAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading