Skip to content
Draft
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
8 changes: 6 additions & 2 deletions src/ConvertKit_API_Traits.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ public function add_subscriber_to_legacy_form(int $form_id, int $subscriber_id)
* @param \DateTime|null $created_before Filter subscribers who have been created before this date.
* @param \DateTime|null $added_after Filter subscribers who have been added to the form after this date.
* @param \DateTime|null $added_before Filter subscribers who have been added to the form before this date.
* @param boolean $slim When true, omits expensive optional fields from the response.
* @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 @@ -348,13 +349,14 @@ public function get_form_subscriptions(
\DateTime|null $created_before = null,
\DateTime|null $added_after = null,
\DateTime|null $added_before = null,
bool $slim = false,
bool $include_total_count = false,
string $after_cursor = '',
string $before_cursor = '',
int $per_page = 100
) {
// Build parameters.
$options = [];
$options = ['slim' => $slim];

if (!empty($subscriber_state)) {
$options['status'] = $subscriber_state;
Expand Down Expand Up @@ -1363,6 +1365,7 @@ public function get_post(int $id)
* @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 $slim When true, omits expensive optional fields from the response.
* @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 @@ -1384,13 +1387,14 @@ public function get_subscribers(
string $sort_field = 'id',
string $sort_order = 'desc',
array $include = [],
bool $slim = false,
bool $include_total_count = false,
string $after_cursor = '',
string $before_cursor = '',
int $per_page = 100
) {
// Build parameters.
$options = [];
$options = ['slim' => $slim];

if (!empty($subscriber_state)) {
$options['status'] = $subscriber_state;
Expand Down
47 changes: 47 additions & 0 deletions tests/ConvertKitAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,30 @@ public function testGetFormSubscriptions()
$this->assertPaginationExists($result);
}

/**
* Test that get_form_subscriptions() returns the expected data
* when the slim parameter is specified.
*
* @since 2.5
*
* @return void
*/
public function testGetFormSubscriptionsWithSlimParameter()
{
$result = $this->api->get_form_subscriptions(
form_id: (int) $_ENV['CONVERTKIT_API_FORM_ID'],
slim: true
);

// Assert subscribers and pagination exist.
$this->assertDataExists($result, 'subscribers');
$this->assertPaginationExists($result);

// Confirm custom field values are excluded from the data.
$subscriber = get_object_vars($result->subscribers[0]);
$this->assertArrayNotHasKey('fields', $subscriber);
}

/**
* Test that get_form_subscriptions() returns the expected data
* when the total count is included.
Expand Down Expand Up @@ -3829,6 +3853,29 @@ public function testGetSubscribers()
$this->assertPaginationExists($result);
}

/**
* Test that get_subscribers() returns the expected data
* when the slim parameter is specified.
*
* @since 2.5
*
* @return void
*/
public function testGetSubscribersWithSlimParameter()
{
$result = $this->api->get_subscribers(
slim: true
);

// Assert subscribers and pagination exist.
$this->assertDataExists($result, 'subscribers');
$this->assertPaginationExists($result);

// Confirm custom field values are excluded from the data.
$subscriber = get_object_vars($result->subscribers[0]);
$this->assertArrayNotHasKey('fields', $subscriber);
}

/**
* Test that get_subscribers() returns the expected data
* when the total count is included.
Expand Down
Loading