Skip to content

Commit bc1b033

Browse files
authored
Merge pull request #103 from Kit/fix-tests
Tests: Update Tests to match API behaviour
2 parents 50d7e62 + 5ac12bc commit bc1b033

File tree

3 files changed

+111
-97
lines changed

3 files changed

+111
-97
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
php-versions: [ '8.0', '8.1', '8.2', '8.3' ]
26+
php-versions: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
2727

2828
# Steps to install, configure and run tests
2929
steps:

src/ConvertKit_API_Traits.php

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ public function get_email_stats()
130130
/**
131131
* Gets growth stats
132132
*
133-
* @param \DateTime $starting Gets stats for time period beginning on this date. Defaults to 90 days ago.
134-
* @param \DateTime $ending Gets stats for time period ending on this date. Defaults to today.
133+
* @param \DateTime|null $starting Gets stats for time period beginning on this date. Defaults to 90 days ago.
134+
* @param \DateTime|null $ending Gets stats for time period ending on this date. Defaults to today.
135135
*
136136
* @see https://developers.convertkit.com/v4.html#get-growth-stats
137137
*
138138
* @return false|mixed
139139
*/
140-
public function get_growth_stats(\DateTime $starting = null, \DateTime $ending = null)
140+
public function get_growth_stats(\DateTime|null $starting = null, \DateTime|null $ending = null)
141141
{
142142
return $this->get(
143143
'account/growth_stats',
@@ -308,16 +308,16 @@ public function add_subscriber_to_form(int $form_id, int $subscriber_id, string
308308
/**
309309
* List subscribers for a form
310310
*
311-
* @param integer $form_id Form ID.
312-
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
313-
* @param \DateTime $created_after Filter subscribers who have been created after this date.
314-
* @param \DateTime $created_before Filter subscribers who have been created before this date.
315-
* @param \DateTime $added_after Filter subscribers who have been added to the form after this date.
316-
* @param \DateTime $added_before Filter subscribers who have been added to the form before this date.
317-
* @param boolean $include_total_count To include the total count of records in the response, use true.
318-
* @param string $after_cursor Return results after the given pagination cursor.
319-
* @param string $before_cursor Return results before the given pagination cursor.
320-
* @param integer $per_page Number of results to return.
311+
* @param integer $form_id Form ID.
312+
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
313+
* @param \DateTime|null $created_after Filter subscribers who have been created after this date.
314+
* @param \DateTime|null $created_before Filter subscribers who have been created before this date.
315+
* @param \DateTime|null $added_after Filter subscribers who have been added to the form after this date.
316+
* @param \DateTime|null $added_before Filter subscribers who have been added to the form before this date.
317+
* @param boolean $include_total_count To include the total count of records in the response, use true.
318+
* @param string $after_cursor Return results after the given pagination cursor.
319+
* @param string $before_cursor Return results before the given pagination cursor.
320+
* @param integer $per_page Number of results to return.
321321
*
322322
* @see https://developers.convertkit.com/v4.html#list-subscribers-for-a-form
323323
*
@@ -326,10 +326,10 @@ public function add_subscriber_to_form(int $form_id, int $subscriber_id, string
326326
public function get_form_subscriptions(
327327
int $form_id,
328328
string $subscriber_state = 'active',
329-
\DateTime $created_after = null,
330-
\DateTime $created_before = null,
331-
\DateTime $added_after = null,
332-
\DateTime $added_before = null,
329+
\DateTime|null $created_after = null,
330+
\DateTime|null $created_before = null,
331+
\DateTime|null $added_after = null,
332+
\DateTime|null $added_before = null,
333333
bool $include_total_count = false,
334334
string $after_cursor = '',
335335
string $before_cursor = '',
@@ -435,16 +435,16 @@ public function add_subscriber_to_sequence(int $sequence_id, int $subscriber_id)
435435
/**
436436
* List subscribers for a sequence
437437
*
438-
* @param integer $sequence_id Sequence ID.
439-
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
440-
* @param \DateTime $created_after Filter subscribers who have been created after this date.
441-
* @param \DateTime $created_before Filter subscribers who have been created before this date.
442-
* @param \DateTime $added_after Filter subscribers who have been added to the form after this date.
443-
* @param \DateTime $added_before Filter subscribers who have been added to the form before this date.
444-
* @param boolean $include_total_count To include the total count of records in the response, use true.
445-
* @param string $after_cursor Return results after the given pagination cursor.
446-
* @param string $before_cursor Return results before the given pagination cursor.
447-
* @param integer $per_page Number of results to return.
438+
* @param integer $sequence_id Sequence ID.
439+
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
440+
* @param \DateTime|null $created_after Filter subscribers who have been created after this date.
441+
* @param \DateTime|null $created_before Filter subscribers who have been created before this date.
442+
* @param \DateTime|null $added_after Filter subscribers who have been added to the form after this date.
443+
* @param \DateTime|null $added_before Filter subscribers who have been added to the form before this date.
444+
* @param boolean $include_total_count To include the total count of records in the response, use true.
445+
* @param string $after_cursor Return results after the given pagination cursor.
446+
* @param string $before_cursor Return results before the given pagination cursor.
447+
* @param integer $per_page Number of results to return.
448448
*
449449
* @see https://developers.convertkit.com/v4.html#list-subscribers-for-a-sequence
450450
*
@@ -453,10 +453,10 @@ public function add_subscriber_to_sequence(int $sequence_id, int $subscriber_id)
453453
public function get_sequence_subscriptions(
454454
int $sequence_id,
455455
string $subscriber_state = 'active',
456-
\DateTime $created_after = null,
457-
\DateTime $created_before = null,
458-
\DateTime $added_after = null,
459-
\DateTime $added_before = null,
456+
\DateTime|null $created_after = null,
457+
\DateTime|null $created_before = null,
458+
\DateTime|null $added_after = null,
459+
\DateTime|null $added_before = null,
460460
bool $include_total_count = false,
461461
string $after_cursor = '',
462462
string $before_cursor = '',
@@ -651,16 +651,16 @@ public function remove_tag_from_subscriber_by_email(int $tag_id, string $email_a
651651
/**
652652
* List subscribers for a tag
653653
*
654-
* @param integer $tag_id Tag ID.
655-
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
656-
* @param \DateTime $created_after Filter subscribers who have been created after this date.
657-
* @param \DateTime $created_before Filter subscribers who have been created before this date.
658-
* @param \DateTime $tagged_after Filter subscribers who have been tagged after this date.
659-
* @param \DateTime $tagged_before Filter subscribers who have been tagged before this date.
660-
* @param boolean $include_total_count To include the total count of records in the response, use true.
661-
* @param string $after_cursor Return results after the given pagination cursor.
662-
* @param string $before_cursor Return results before the given pagination cursor.
663-
* @param integer $per_page Number of results to return.
654+
* @param integer $tag_id Tag ID.
655+
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
656+
* @param \DateTime|null $created_after Filter subscribers who have been created after this date.
657+
* @param \DateTime|null $created_before Filter subscribers who have been created before this date.
658+
* @param \DateTime|null $tagged_after Filter subscribers who have been tagged after this date.
659+
* @param \DateTime|null $tagged_before Filter subscribers who have been tagged before this date.
660+
* @param boolean $include_total_count To include the total count of records in the response, use true.
661+
* @param string $after_cursor Return results after the given pagination cursor.
662+
* @param string $before_cursor Return results before the given pagination cursor.
663+
* @param integer $per_page Number of results to return.
664664
*
665665
* @see https://developers.convertkit.com/v4.html#list-subscribers-for-a-tag
666666
*
@@ -669,10 +669,10 @@ public function remove_tag_from_subscriber_by_email(int $tag_id, string $email_a
669669
public function get_tag_subscriptions(
670670
int $tag_id,
671671
string $subscriber_state = 'active',
672-
\DateTime $created_after = null,
673-
\DateTime $created_before = null,
674-
\DateTime $tagged_after = null,
675-
\DateTime $tagged_before = null,
672+
\DateTime|null $created_after = null,
673+
\DateTime|null $created_before = null,
674+
\DateTime|null $tagged_after = null,
675+
\DateTime|null $tagged_before = null,
676676
bool $include_total_count = false,
677677
string $after_cursor = '',
678678
string $before_cursor = '',
@@ -746,18 +746,18 @@ public function get_email_templates(
746746
/**
747747
* List subscribers.
748748
*
749-
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
750-
* @param string $email_address Search susbcribers by email address. This is an exact match search.
751-
* @param \DateTime $created_after Filter subscribers who have been created after this date.
752-
* @param \DateTime $created_before Filter subscribers who have been created before this date.
753-
* @param \DateTime $updated_after Filter subscribers who have been updated after this date.
754-
* @param \DateTime $updated_before Filter subscribers who have been updated before this date.
755-
* @param string $sort_field Sort Field (id|updated_at|cancelled_at).
756-
* @param string $sort_order Sort Order (asc|desc).
757-
* @param boolean $include_total_count To include the total count of records in the response, use true.
758-
* @param string $after_cursor Return results after the given pagination cursor.
759-
* @param string $before_cursor Return results before the given pagination cursor.
760-
* @param integer $per_page Number of results to return.
749+
* @param string $subscriber_state Subscriber State (active|bounced|cancelled|complained|inactive).
750+
* @param string $email_address Search susbcribers by email address. This is an exact match search.
751+
* @param \DateTime|null $created_after Filter subscribers who have been created after this date.
752+
* @param \DateTime|null $created_before Filter subscribers who have been created before this date.
753+
* @param \DateTime|null $updated_after Filter subscribers who have been updated after this date.
754+
* @param \DateTime|null $updated_before Filter subscribers who have been updated before this date.
755+
* @param string $sort_field Sort Field (id|updated_at|cancelled_at).
756+
* @param string $sort_order Sort Order (asc|desc).
757+
* @param boolean $include_total_count To include the total count of records in the response, use true.
758+
* @param string $after_cursor Return results after the given pagination cursor.
759+
* @param string $before_cursor Return results before the given pagination cursor.
760+
* @param integer $per_page Number of results to return.
761761
*
762762
* @since 2.0.0
763763
*
@@ -768,10 +768,10 @@ public function get_email_templates(
768768
public function get_subscribers(
769769
string $subscriber_state = 'active',
770770
string $email_address = '',
771-
\DateTime $created_after = null,
772-
\DateTime $created_before = null,
773-
\DateTime $updated_after = null,
774-
\DateTime $updated_before = null,
771+
\DateTime|null $created_after = null,
772+
\DateTime|null $created_before = null,
773+
\DateTime|null $updated_after = null,
774+
\DateTime|null $updated_before = null,
775775
string $sort_field = 'id',
776776
string $sort_order = 'desc',
777777
bool $include_total_count = false,
@@ -1090,9 +1090,9 @@ public function get_broadcasts(
10901090
* @param string $content The broadcast's email HTML content.
10911091
* @param string $description An internal description of this broadcast.
10921092
* @param boolean $public Specifies whether or not this is a public post.
1093-
* @param \DateTime $published_at Specifies the time that this post was published (applicable
1093+
* @param \DateTime|null $published_at Specifies the time that this post was published (applicable
10941094
* only to public posts).
1095-
* @param \DateTime $send_at Time that this broadcast should be sent; leave blank to create
1095+
* @param \DateTime|null $send_at Time that this broadcast should be sent; leave blank to create
10961096
* a draft broadcast. If set to a future time, this is the time that
10971097
* the broadcast will be scheduled to send.
10981098
* @param string $email_address Sending email address; leave blank to use your account's
@@ -1115,8 +1115,8 @@ public function create_broadcast(
11151115
string $content = '',
11161116
string $description = '',
11171117
bool $public = false,
1118-
\DateTime $published_at = null,
1119-
\DateTime $send_at = null,
1118+
\DateTime|null $published_at = null,
1119+
\DateTime|null $send_at = null,
11201120
string $email_address = '',
11211121
string $email_template_id = '',
11221122
string $thumbnail_alt = '',
@@ -1197,9 +1197,9 @@ public function get_broadcast_stats(int $id)
11971197
* @param string $content The broadcast's email HTML content.
11981198
* @param string $description An internal description of this broadcast.
11991199
* @param boolean $public Specifies whether or not this is a public post.
1200-
* @param \DateTime $published_at Specifies the time that this post was published (applicable
1200+
* @param \DateTime|null $published_at Specifies the time that this post was published (applicable
12011201
* only to public posts).
1202-
* @param \DateTime $send_at Time that this broadcast should be sent; leave blank to create
1202+
* @param \DateTime|null $send_at Time that this broadcast should be sent; leave blank to create
12031203
* a draft broadcast. If set to a future time, this is the time that
12041204
* the broadcast will be scheduled to send.
12051205
* @param string $email_address Sending email address; leave blank to use your account's
@@ -1223,8 +1223,8 @@ public function update_broadcast(
12231223
string $content = '',
12241224
string $description = '',
12251225
bool $public = false,
1226-
\DateTime $published_at = null,
1227-
\DateTime $send_at = null,
1226+
\DateTime|null $published_at = null,
1227+
\DateTime|null $send_at = null,
12281228
string $email_address = '',
12291229
string $email_template_id = '',
12301230
string $thumbnail_alt = '',
@@ -1588,14 +1588,14 @@ public function get_purchase(int $purchase_id)
15881588
* @param string $transaction_id Transaction ID.
15891589
* @param array<string,int|float|string> $products Products.
15901590
* @param string $currency ISO Currency Code.
1591-
* @param string $first_name First Name.
1592-
* @param string $status Order Status.
1591+
* @param string|null $first_name First Name.
1592+
* @param string|null $status Order Status.
15931593
* @param float $subtotal Subtotal.
15941594
* @param float $tax Tax.
15951595
* @param float $shipping Shipping.
15961596
* @param float $discount Discount.
15971597
* @param float $total Total.
1598-
* @param \DateTime $transaction_time Transaction date and time.
1598+
* @param \DateTime|null $transaction_time Transaction date and time.
15991599
*
16001600
* @see https://developers.convertkit.com/v4.html#create-a-purchase
16011601
*
@@ -1606,14 +1606,14 @@ public function create_purchase(
16061606
string $transaction_id,
16071607
array $products,
16081608
string $currency = 'USD',
1609-
string $first_name = null,
1610-
string $status = null,
1609+
string|null $first_name = null,
1610+
string|null $status = null,
16111611
float $subtotal = 0,
16121612
float $tax = 0,
16131613
float $shipping = 0,
16141614
float $discount = 0,
16151615
float $total = 0,
1616-
\DateTime $transaction_time = null
1616+
\DateTime|null $transaction_time = null
16171617
) {
16181618
// Build parameters.
16191619
$options = [

0 commit comments

Comments
 (0)