Skip to content
Merged
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 @@ -1212,6 +1212,7 @@ public function remove_tag_from_subscriber_by_email(int $tag_id, string $email_a
* @param \DateTime|null $created_before Filter subscribers who have been created before this date.
* @param \DateTime|null $tagged_after Filter subscribers who have been tagged after this date.
* @param \DateTime|null $tagged_before Filter subscribers who have been tagged 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 @@ -1228,13 +1229,14 @@ public function get_tag_subscriptions(
\DateTime|null $created_before = null,
\DateTime|null $tagged_after = null,
\DateTime|null $tagged_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 @@ -1750,6 +1752,7 @@ public function get_subscriber_tags(
*
* @param \DateTime|null $sent_after Get broadcasts sent after the given date.
* @param \DateTime|null $sent_before Get broadcasts sent before the given 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 @@ -1762,13 +1765,14 @@ public function get_subscriber_tags(
public function get_broadcasts(
\DateTime|null $sent_after = null,
\DateTime|null $sent_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 (!is_null($sent_after)) {
$options['sent_after'] = $sent_after->format('Y-m-d');
Expand Down
51 changes: 51 additions & 0 deletions tests/ConvertKitAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2959,6 +2959,30 @@ public function testGetTagSubscriptions()
$this->assertPaginationExists($result);
}

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

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

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

/**
* Test that get_tag_subscriptions() returns the expected data
* when the total count is included.
Expand Down Expand Up @@ -5292,6 +5316,33 @@ public function testGetBroadcastsWithSentBefore()
$this->assertCount(12, $result->broadcasts);
}

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

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

// Confirm content, public_url, email_address, email_template and subscriber_filter are excluded from the data.
$broadcast = get_object_vars($result->broadcasts[0]);
$this->assertArrayNotHasKey('content', $broadcast);
$this->assertArrayNotHasKey('public_url', $broadcast);
$this->assertArrayNotHasKey('email_address', $broadcast);
$this->assertArrayNotHasKey('email_template', $broadcast);
$this->assertArrayNotHasKey('subscriber_filter', $broadcast);
}

/**
* Test that get_broadcasts() returns the expected data
* when pagination parameters and per_page limits are specified.
Expand Down
Loading