From fbc73e2f22173b1788e6435c99d3d02d3506a3e2 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 30 Sep 2025 12:48:42 +0800 Subject: [PATCH] Fix API Doc Generation --- composer.json | 3 +- docs/Home.md | 18 + docs/classes/ConvertKit_API/ConvertKit_API.md | 1183 +++++++------- .../ConvertKit_API/ConvertKit_API_Traits.md | 1397 +++++++++++++++++ 4 files changed, 2038 insertions(+), 563 deletions(-) create mode 100644 docs/Home.md create mode 100644 docs/classes/ConvertKit_API/ConvertKit_API_Traits.md diff --git a/composer.json b/composer.json index 30a377e..ce31a17 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "vlucas/phpdotenv": "^5.5", "phpunit/phpunit": "^5.7 || ^9.0", "squizlabs/php_codesniffer": "^3.3", - "phpstan/phpstan": "^2.0" + "phpstan/phpstan": "^2.0", + "saggre/phpdocumentor-markdown": "^1.0" }, "autoload": { "psr-4": { diff --git a/docs/Home.md b/docs/Home.md new file mode 100644 index 0000000..a452da0 --- /dev/null +++ b/docs/Home.md @@ -0,0 +1,18 @@ + +This is an automatically generated documentation for **Documentation**. + +## Namespaces + +### \ConvertKit_API + +#### Classes + +| Class | Description | +|-------------------------------------------------------------|----------------------| +| [`ConvertKit_API`](./classes/ConvertKit_API/ConvertKit_API) | ConvertKit API Class | + +#### Traits + +| Trait | Description | +|---------------------------------------------------------------------------|-----------------------| +| [`ConvertKit_API_Traits`](./classes/ConvertKit_API/ConvertKit_API_Traits) | ConvertKit API Traits | diff --git a/docs/classes/ConvertKit_API/ConvertKit_API.md b/docs/classes/ConvertKit_API/ConvertKit_API.md index c2a1db3..1766fef 100644 --- a/docs/classes/ConvertKit_API/ConvertKit_API.md +++ b/docs/classes/ConvertKit_API/ConvertKit_API.md @@ -1,13 +1,16 @@ -# ConvertKit_API ConvertKit API Class + +*** + * Full name: `\ConvertKit_API\ConvertKit_API` ## Constants -| Constant | Visibility | Type | Value | -|:---------|:-----------|:-----|:------| -|`VERSION`|public|string|'2.0.0'| +| Constant | Visibility | Type | Value | +|-----------|------------|--------|---------| +| `VERSION` | public | string | '2.0.0' | + ## Properties ### debug @@ -18,6 +21,8 @@ Debug protected bool $debug ``` +*** + ### debug_logger Debug @@ -26,6 +31,8 @@ Debug protected \Monolog\Logger $debug_logger ``` +*** + ### client Guzzle Http ClientInterface @@ -34,6 +41,8 @@ Guzzle Http ClientInterface protected \GuzzleHttp\ClientInterface $client ``` +*** + ### response Guzzle Http Response @@ -42,6 +51,8 @@ Guzzle Http Response protected \Psr\Http\Message\ResponseInterface $response ``` +*** + ## Methods ### __construct @@ -49,22 +60,22 @@ protected \Psr\Http\Message\ResponseInterface $response Constructor for ConvertKitAPI instance ```php -public __construct(string $clientID, string $clientSecret, string $accessToken = '', bool $debug = false, string $debugLogFileLocation = ''): mixed +public __construct(string $clientID = '', string $clientSecret = '', string $accessToken = '', string $apiKey = '', bool $debug = false, string $debugLogFileLocation = ''): mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$clientID` | **string** | OAuth Client ID. | -| `$clientSecret` | **string** | OAuth Client Secret. | -| `$accessToken` | **string** | OAuth Access Token. | -| `$debug` | **bool** | Log requests to debugger. | +| Parameter | Type | Description | +|-------------------------|------------|----------------------------------------------| +| `$clientID` | **string** | OAuth Client ID. | +| `$clientSecret` | **string** | OAuth Client Secret. | +| `$accessToken` | **string** | OAuth Access Token. | +| `$apiKey` | **string** | API Key. | +| `$debug` | **bool** | Log requests to debugger. | | `$debugLogFileLocation` | **string** | Path and filename of debug file to write to. | +*** ---- ### set_http_client Set the Guzzle client implementation to use for API requests. @@ -73,15 +84,14 @@ Set the Guzzle client implementation to use for API requests. public set_http_client(\GuzzleHttp\ClientInterface $client): void ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|-----------|---------------------------------|-------------------------------| | `$client` | **\GuzzleHttp\ClientInterface** | Guzzle client implementation. | +*** ---- ### create_log Add an entry to monologger. @@ -90,15 +100,14 @@ Add an entry to monologger. private create_log(string $message): void ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$message` | **string** | Message. | +| Parameter | Type | Description | +|------------|------------|-------------| +| `$message` | **string** | Message. | +*** ---- ### get_oauth_url Returns the OAuth URL to begin the OAuth process. @@ -107,59 +116,56 @@ Returns the OAuth URL to begin the OAuth process. public get_oauth_url(string $redirectURI): string ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|----------------|------------|---------------| | `$redirectURI` | **string** | Redirect URI. | +*** ---- ### get_access_token Exchanges the given authorization code for an access token and refresh token. ```php -public get_access_token(string $authCode, string $redirectURI): array +public get_access_token(string $authCode, string $redirectURI): mixed|array ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$authCode` | **string** | Authorization Code, returned from get_oauth_url() flow. | -| `$redirectURI` | **string** | Redirect URI. | +| Parameter | Type | Description | +|----------------|------------|---------------------------------------------------------| +| `$authCode` | **string** | Authorization Code, returned from get_oauth_url() flow. | +| `$redirectURI` | **string** | Redirect URI. | **Return Value:** API response +*** ---- ### refresh_token Fetches a new access token using the supplied refresh token. ```php -public refresh_token(string $refreshToken, string $redirectURI): array +public refresh_token(string $refreshToken, string $redirectURI): mixed|array ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|-----------------|------------|----------------| | `$refreshToken` | **string** | Refresh Token. | -| `$redirectURI` | **string** | Redirect URI. | +| `$redirectURI` | **string** | Redirect URI. | **Return Value:** API response +*** ---- ### get_resource Get markup from ConvertKit for the provided $url. @@ -167,6 +173,7 @@ Get markup from ConvertKit for the provided $url. ```php public get_resource(string $url): false|string ``` + Supports legacy forms and legacy landing pages. Forms and Landing Pages should be embedded using the supplied JS embed script in @@ -174,31 +181,42 @@ the API response when using get_forms() or get_landing_pages(). **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$url` | **string** | URL of HTML page. | +| Parameter | Type | Description | +|-----------|------------|-------------------| +| `$url` | **string** | URL of HTML page. | +**Throws:** + +If the URL is not a valid URL format. +- [`InvalidArgumentException`](../InvalidArgumentException) +If parsing the legacy form or landing page failed. +- [`Exception`](../Exception) + +*** ---- ### request Performs an API request using Guzzle. ```php -public request(string $endpoint, string $method, array> $args = []): false|mixed +public request(string $endpoint, string $method, array> $args = []): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$endpoint` | **string** | API Endpoint. | -| `$method` | **string** | Request method. | -| `$args` | **array>** | Request arguments. | +| Parameter | Type | Description | +|-------------|-----------------------------------------------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$method` | **string** | Request method. | +| `$args` | **array>** | Request arguments. | + +**Throws:** +If JSON encoding arguments failed. +- [`Exception`](../Exception) + +*** ---- ### getResponseInterface Returns the response interface used for the last API request. @@ -207,9 +225,8 @@ Returns the response interface used for the last API request. public getResponseInterface(): \Psr\Http\Message\ResponseInterface ``` +*** - ---- ### get_request_headers Returns the headers to use in an API request. @@ -218,16 +235,15 @@ Returns the headers to use in an API request. public get_request_headers(string $type = 'application/json', bool $auth = true): array ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$type` | **string** | Accept and Content-Type Headers. | -| `$auth` | **bool** | Include authorization header. | +| Parameter | Type | Description | +|-----------|------------|----------------------------------| +| `$type` | **string** | Accept and Content-Type Headers. | +| `$auth` | **bool** | Include authorization header. | +*** ---- ### get_timeout Returns the maximum amount of time to wait for @@ -237,13 +253,12 @@ a response to the request before exiting. public get_timeout(): int ``` - **Return Value:** Timeout, in seconds. +*** ---- ### get_user_agent Returns the user agent string to use in all HTTP requests. @@ -252,9 +267,7 @@ Returns the user agent string to use in all HTTP requests. public get_user_agent(): string ``` - - ---- +*** ## Inherited methods @@ -266,12 +279,12 @@ Gets the current account public get_account(): false|mixed ``` - **See Also:** -* https://developers.convertkit.com/v4.html#get-current-account +* https://developers.convertkit.com/v4.html#get-current-account + +*** ---- ### get_account_colors Gets the account's colors @@ -280,12 +293,12 @@ Gets the account's colors public get_account_colors(): false|mixed ``` - **See Also:** -* https://developers.convertkit.com/v4.html#list-colors +* https://developers.convertkit.com/v4.html#list-colors + +*** ---- ### update_account_colors Gets the account's colors @@ -294,18 +307,18 @@ Gets the account's colors public update_account_colors(array $colors): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|-----------|--------------------------|-------------| | `$colors` | **array** | Hex colors. | **See Also:** -* https://developers.convertkit.com/v4.html#list-colors +* https://developers.convertkit.com/v4.html#list-colors + +*** ---- ### get_creator_profile Gets the Creator Profile @@ -314,12 +327,12 @@ Gets the Creator Profile public get_creator_profile(): false|mixed ``` - **See Also:** -* https://developers.convertkit.com/v4.html#get-creator-profile +* https://developers.convertkit.com/v4.html#get-creator-profile + +*** ---- ### get_email_stats Gets email stats @@ -328,152 +341,175 @@ Gets email stats public get_email_stats(): false|mixed ``` - **See Also:** -* https://developers.convertkit.com/v4.html#get-email-stats +* https://developers.convertkit.com/v4.html#get-email-stats + +*** ---- ### get_growth_stats Gets growth stats ```php -public get_growth_stats(\DateTime $starting = null, \DateTime $ending = null): false|mixed +public get_growth_stats(\DateTime|null $starting = null, \DateTime|null $ending = null): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$starting` | **\DateTime** | Gets stats for time period beginning on this date. Defaults to 90 days ago. | -| `$ending` | **\DateTime** | Gets stats for time period ending on this date. Defaults to today. | +| Parameter | Type | Description | +|-------------|---------------------|-----------------------------------------------------------------------------| +| `$starting` | **\DateTime\|null** | Gets stats for time period beginning on this date. Defaults to 90 days ago. | +| `$ending` | **\DateTime\|null** | Gets stats for time period ending on this date. Defaults to today. | **See Also:** -* https://developers.convertkit.com/v4.html#get-growth-stats +* https://developers.convertkit.com/v4.html#get-growth-stats + +*** ---- ### get_forms Get forms. ```php -public get_forms(string $status = 'active', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|array +public get_forms(string $status = 'active', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$status` | **string** | Form status (active\|archived\|trashed\|all). | -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$status` | **string** | Form status (active\|archived\|trashed\|all). | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#convertkit-api-forms +* https://developers.convertkit.com/v4.html#convertkit-api-forms + +*** ---- ### get_landing_pages Get landing pages. ```php -public get_landing_pages(string $status = 'active', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|array +public get_landing_pages(string $status = 'active', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array ``` +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$status` | **string** | Form status (active\|archived\|trashed\|all). | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#convertkit-api-forms + +*** + +### add_subscribers_to_forms + +Adds subscribers to forms in bulk. + +```php +public add_subscribers_to_forms(array[] $forms_subscribers_ids, string $callback_url = ''): mixed|object +``` **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$status` | **string** | Form status (active\|archived\|trashed\|all). | -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|--------------------------|----------------------------|---------------------------------------------------------------------------------------| +| `$forms_subscribers_ids` | **array[]** | Array of arrays comprising of `form_id`, `subscriber_id` and optional `referrer` URL. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | **See Also:** -* https://developers.convertkit.com/v4.html#convertkit-api-forms +* https://developers.kit.com/v4.html#bulk-add-subscribers-to-forms + +*** ---- ### add_subscriber_to_form_by_email Adds a subscriber to a form by email address ```php -public add_subscriber_to_form_by_email(int $form_id, string $email_address): false|mixed +public add_subscriber_to_form_by_email(int $form_id, string $email_address, string $referrer = ''): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$form_id` | **int** | Form ID. | +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$form_id` | **int** | Form ID. | | `$email_address` | **string** | Email Address. | +| `$referrer` | **string** | Referrer. | **See Also:** -* https://developers.convertkit.com/v4.html#add-subscriber-to-form-by-email-address +* https://developers.convertkit.com/v4.html#add-subscriber-to-form-by-email-address + +*** ---- ### add_subscriber_to_form Adds a subscriber to a form by subscriber ID ```php -public add_subscriber_to_form(int $form_id, int $subscriber_id): false|mixed +public add_subscriber_to_form(int $form_id, int $subscriber_id, string $referrer = ''): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$form_id` | **int** | Form ID. | -| `$subscriber_id` | **int** | Subscriber ID. | +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$form_id` | **int** | Form ID. | +| `$subscriber_id` | **int** | Subscriber ID. | +| `$referrer` | **string** | Referrer URL. | **See Also:** -* https://developers.convertkit.com/v4.html#add-subscriber-to-form +* https://developers.convertkit.com/v4.html#add-subscriber-to-form + +*** ---- ### get_form_subscriptions List subscribers for a form ```php -public get_form_subscriptions(int $form_id, string $subscriber_state = 'active', \DateTime $created_after = null, \DateTime $created_before = null, \DateTime $added_after = null, \DateTime $added_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +public get_form_subscriptions(int $form_id, string $subscriber_state = 'active', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $added_after = null, \DateTime|null $added_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$form_id` | **int** | Form ID. | -| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | -| `$created_after` | **\DateTime** | Filter subscribers who have been created after this date. | -| `$created_before` | **\DateTime** | Filter subscribers who have been created before this date. | -| `$added_after` | **\DateTime** | Filter subscribers who have been added to the form after this date. | -| `$added_before` | **\DateTime** | Filter subscribers who have been added to the form before this date. | -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$form_id` | **int** | Form ID. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$added_after` | **\DateTime\|null** | Filter subscribers who have been added to the form after this date. | +| `$added_before` | **\DateTime\|null** | Filter subscribers who have been added to the form before this date. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-subscribers-for-a-form +* https://developers.convertkit.com/v4.html#list-subscribers-for-a-form + +*** ---- ### get_sequences Gets sequences @@ -482,21 +518,21 @@ Gets sequences public get_sequences(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-sequences +* https://developers.convertkit.com/v4.html#list-sequences + +*** ---- ### add_subscriber_to_sequence_by_email Adds a subscriber to a sequence by email address @@ -505,19 +541,19 @@ Adds a subscriber to a sequence by email address public add_subscriber_to_sequence_by_email(int $sequence_id, string $email_address): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$sequence_id` | **int** | Sequence ID. | +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$sequence_id` | **int** | Sequence ID. | | `$email_address` | **string** | Email Address. | **See Also:** -* https://developers.convertkit.com/v4.html#add-subscriber-to-sequence-by-email-address +* https://developers.convertkit.com/v4.html#add-subscriber-to-sequence-by-email-address + +*** ---- ### add_subscriber_to_sequence Adds a subscriber to a sequence by subscriber ID @@ -526,71 +562,71 @@ Adds a subscriber to a sequence by subscriber ID public add_subscriber_to_sequence(int $sequence_id, int $subscriber_id): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$sequence_id` | **int** | Sequence ID. | +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$sequence_id` | **int** | Sequence ID. | | `$subscriber_id` | **int** | Subscriber ID. | **See Also:** -* https://developers.convertkit.com/v4.html#add-subscriber-to-sequence +* https://developers.convertkit.com/v4.html#add-subscriber-to-sequence + +*** ---- ### get_sequence_subscriptions List subscribers for a sequence ```php -public get_sequence_subscriptions(int $sequence_id, string $subscriber_state = 'active', \DateTime $created_after = null, \DateTime $created_before = null, \DateTime $added_after = null, \DateTime $added_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +public get_sequence_subscriptions(int $sequence_id, string $subscriber_state = 'active', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $added_after = null, \DateTime|null $added_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$sequence_id` | **int** | Sequence ID. | -| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | -| `$created_after` | **\DateTime** | Filter subscribers who have been created after this date. | -| `$created_before` | **\DateTime** | Filter subscribers who have been created before this date. | -| `$added_after` | **\DateTime** | Filter subscribers who have been added to the form after this date. | -| `$added_before` | **\DateTime** | Filter subscribers who have been added to the form before this date. | -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$sequence_id` | **int** | Sequence ID. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$added_after` | **\DateTime\|null** | Filter subscribers who have been added to the form after this date. | +| `$added_before` | **\DateTime\|null** | Filter subscribers who have been added to the form before this date. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-subscribers-for-a-sequence +* https://developers.convertkit.com/v4.html#list-subscribers-for-a-sequence + +*** ---- ### get_tags List tags. ```php -public get_tags(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|array +public get_tags(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-tags +* https://developers.convertkit.com/v4.html#list-tags + +*** ---- ### create_tag Creates a tag. @@ -599,18 +635,18 @@ Creates a tag. public create_tag(string $tag): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$tag` | **string** | Tag Name. | +| Parameter | Type | Description | +|-----------|------------|-------------| +| `$tag` | **string** | Tag Name. | **See Also:** -* https://developers.convertkit.com/v4.html#create-a-tag +* https://developers.convertkit.com/v4.html#create-a-tag + +*** ---- ### create_tags Creates multiple tags. @@ -619,19 +655,19 @@ Creates multiple tags. public create_tags(array $tags, string $callback_url = ''): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$tags` | **array** | Tag Names. | -| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | +| Parameter | Type | Description | +|-----------------|-----------------------|--------------------------------------------------------------------| +| `$tags` | **array** | Tag Names. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | **See Also:** -* https://developers.convertkit.com/v4.html#bulk-create-tags +* https://developers.convertkit.com/v4.html#bulk-create-tags + +*** ---- ### tag_subscriber_by_email Tags a subscriber with the given existing Tag. @@ -640,19 +676,19 @@ Tags a subscriber with the given existing Tag. public tag_subscriber_by_email(int $tag_id, string $email_address): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$tag_id` | **int** | Tag ID. | +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$tag_id` | **int** | Tag ID. | | `$email_address` | **string** | Email Address. | **See Also:** -* https://developers.convertkit.com/v4.html#tag-a-subscriber-by-email-address +* https://developers.convertkit.com/v4.html#tag-a-subscriber-by-email-address + +*** ---- ### tag_subscriber Tags a subscriber by subscriber ID with the given existing Tag. @@ -661,19 +697,19 @@ Tags a subscriber by subscriber ID with the given existing Tag. public tag_subscriber(int $tag_id, int $subscriber_id): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$tag_id` | **int** | Tag ID. | +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$tag_id` | **int** | Tag ID. | | `$subscriber_id` | **int** | Subscriber ID. | **See Also:** -* https://developers.convertkit.com/v4.html#tag-a-subscriber +* https://developers.convertkit.com/v4.html#tag-a-subscriber + +*** ---- ### remove_tag_from_subscriber Removes a tag from a subscriber. @@ -682,19 +718,19 @@ Removes a tag from a subscriber. public remove_tag_from_subscriber(int $tag_id, int $subscriber_id): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$tag_id` | **int** | Tag ID. | +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$tag_id` | **int** | Tag ID. | | `$subscriber_id` | **int** | Subscriber ID. | **See Also:** -* https://developers.convertkit.com/v4.html#remove-tag-from-subscriber +* https://developers.convertkit.com/v4.html#remove-tag-from-subscriber + +*** ---- ### remove_tag_from_subscriber_by_email Removes a tag from a subscriber by email address. @@ -703,48 +739,48 @@ Removes a tag from a subscriber by email address. public remove_tag_from_subscriber_by_email(int $tag_id, string $email_address): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$tag_id` | **int** | Tag ID. | +| Parameter | Type | Description | +|------------------|------------|---------------------------| +| `$tag_id` | **int** | Tag ID. | | `$email_address` | **string** | Subscriber email address. | **See Also:** -* https://developers.convertkit.com/v4.html#remove-tag-from-subscriber-by-email-address +* https://developers.convertkit.com/v4.html#remove-tag-from-subscriber-by-email-address + +*** ---- ### get_tag_subscriptions List subscribers for a tag ```php -public get_tag_subscriptions(int $tag_id, string $subscriber_state = 'active', \DateTime $created_after = null, \DateTime $created_before = null, \DateTime $tagged_after = null, \DateTime $tagged_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +public get_tag_subscriptions(int $tag_id, string $subscriber_state = 'active', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $tagged_after = null, \DateTime|null $tagged_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$tag_id` | **int** | Tag ID. | -| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | -| `$created_after` | **\DateTime** | Filter subscribers who have been created after this date. | -| `$created_before` | **\DateTime** | Filter subscribers who have been created before this date. | -| `$tagged_after` | **\DateTime** | Filter subscribers who have been tagged after this date. | -| `$tagged_before` | **\DateTime** | Filter subscribers who have been tagged before this date. | -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$tag_id` | **int** | Tag ID. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$tagged_after` | **\DateTime\|null** | Filter subscribers who have been tagged after this date. | +| `$tagged_before` | **\DateTime\|null** | Filter subscribers who have been tagged before this date. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-subscribers-for-a-tag +* https://developers.convertkit.com/v4.html#list-subscribers-for-a-tag + +*** ---- ### get_email_templates List email templates. @@ -753,52 +789,52 @@ List email templates. public get_email_templates(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#convertkit-api-email-templates +* https://developers.convertkit.com/v4.html#convertkit-api-email-templates + +*** ---- ### get_subscribers List subscribers. ```php -public get_subscribers(string $subscriber_state = 'active', string $email_address = '', \DateTime $created_after = null, \DateTime $created_before = null, \DateTime $updated_after = null, \DateTime $updated_before = null, string $sort_field = 'id', string $sort_order = 'desc', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +public get_subscribers(string $subscriber_state = 'active', string $email_address = '', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $updated_after = null, \DateTime|null $updated_before = null, string $sort_field = 'id', string $sort_order = 'desc', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | -| `$email_address` | **string** | Search susbcribers by email address. This is an exact match search. | -| `$created_after` | **\DateTime** | Filter subscribers who have been created after this date. | -| `$created_before` | **\DateTime** | Filter subscribers who have been created before this date. | -| `$updated_after` | **\DateTime** | Filter subscribers who have been updated after this date. | -| `$updated_before` | **\DateTime** | Filter subscribers who have been updated before this date. | -| `$sort_field` | **string** | Sort Field (id\|updated_at\|cancelled_at). | -| `$sort_order` | **string** | Sort Order (asc\|desc). | -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$email_address` | **string** | Search susbcribers by email address. This is an exact match search. | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$updated_after` | **\DateTime\|null** | Filter subscribers who have been updated after this date. | +| `$updated_before` | **\DateTime\|null** | Filter subscribers who have been updated before this date. | +| `$sort_field` | **string** | Sort Field (id\|updated_at\|cancelled_at). | +| `$sort_order` | **string** | Sort Order (asc\|desc). | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-subscribers +* https://developers.convertkit.com/v4.html#list-subscribers + +*** ---- ### create_subscriber Create a subscriber. @@ -806,24 +842,26 @@ Create a subscriber. ```php public create_subscriber(string $email_address, string $first_name = '', string $subscriber_state = '', array $fields = []): mixed ``` + Behaves as an upsert. If a subscriber with the provided email address does not exist, it creates one with the specified first name and state. If a subscriber with the provided email address already exists, it updates the first name. **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$email_address` | **string** | Email Address. | -| `$first_name` | **string** | First Name. | -| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | -| `$fields` | **array** | Custom Fields. | +| Parameter | Type | Description | +|---------------------|--------------------------|----------------------------------------------------------------------| +| `$email_address` | **string** | Email Address. | +| `$first_name` | **string** | First Name. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$fields` | **array** | Custom Fields. | **See Also:** -* https://developers.convertkit.com/v4.html#create-a-subscriber +* https://developers.convertkit.com/v4.html#create-a-subscriber + +*** ---- ### create_subscribers Create multiple subscribers. @@ -832,19 +870,19 @@ Create multiple subscribers. public create_subscribers(array> $subscribers, string $callback_url = ''): mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$subscribers` | **array>** | Subscribers. | -| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | +| Parameter | Type | Description | +|-----------------|-------------------------------------|--------------------------------------------------------------------| +| `$subscribers` | **array>** | Subscribers. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | **See Also:** -* https://developers.convertkit.com/v4.html#bulk-create-subscribers +* https://developers.convertkit.com/v4.html#bulk-create-subscribers + +*** ---- ### get_subscriber_id Get the ConvertKit subscriber ID associated with email address if it exists. @@ -852,126 +890,133 @@ Get the ConvertKit subscriber ID associated with email address if it exists. ```php public get_subscriber_id(string $email_address): false|int ``` + Return false if subscriber not found. **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|------------------|------------|----------------| | `$email_address` | **string** | Email Address. | +**Throws:** + +If the email address is not a valid email format. +- [`InvalidArgumentException`](../InvalidArgumentException) + **See Also:** -* https://developers.convertkit.com/v4.html#get-a-subscriber +* https://developers.convertkit.com/v4.html#get-a-subscriber + +*** ---- ### get_subscriber Get subscriber by id ```php -public get_subscriber(int $subscriber_id): false|int +public get_subscriber(int $subscriber_id): mixed|int ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|------------------|---------|----------------| | `$subscriber_id` | **int** | Subscriber ID. | **See Also:** -* https://developers.convertkit.com/v4.html#get-a-subscriber +* https://developers.convertkit.com/v4.html#get-a-subscriber + +*** ---- ### update_subscriber Updates the information for a single subscriber. ```php -public update_subscriber(int $subscriber_id, string $first_name = '', string $email_address = '', array $fields = []): false|mixed +public update_subscriber(int $subscriber_id, string $first_name = '', string $email_address = '', array $fields = []): mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$subscriber_id` | **int** | Existing Subscriber ID. | -| `$first_name` | **string** | New First Name. | -| `$email_address` | **string** | New Email Address. | -| `$fields` | **array** | Updated Custom Fields. | +| Parameter | Type | Description | +|------------------|--------------------------|-------------------------| +| `$subscriber_id` | **int** | Existing Subscriber ID. | +| `$first_name` | **string** | New First Name. | +| `$email_address` | **string** | New Email Address. | +| `$fields` | **array** | Updated Custom Fields. | **See Also:** -* https://developers.convertkit.com/v4.html#update-a-subscriber +* https://developers.convertkit.com/v4.html#update-a-subscriber + +*** ---- ### unsubscribe_by_email Unsubscribe an email address. ```php -public unsubscribe_by_email(string $email_address): false|object +public unsubscribe_by_email(string $email_address): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|------------------|------------|----------------| | `$email_address` | **string** | Email Address. | **See Also:** -* https://developers.convertkit.com/v4.html#unsubscribe-subscriber +* https://developers.convertkit.com/v4.html#unsubscribe-subscriber + +*** ---- ### unsubscribe Unsubscribe the given subscriber ID. ```php -public unsubscribe(int $subscriber_id): false|object +public unsubscribe(int $subscriber_id): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|------------------|---------|----------------| | `$subscriber_id` | **int** | Subscriber ID. | **See Also:** -* https://developers.convertkit.com/v4.html#unsubscribe-subscriber +* https://developers.convertkit.com/v4.html#unsubscribe-subscriber + +*** ---- ### get_subscriber_tags Get a list of the tags for a subscriber. ```php -public get_subscriber_tags(int $subscriber_id, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|array +public get_subscriber_tags(int $subscriber_id, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$subscriber_id` | **int** | Subscriber ID. | -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$subscriber_id` | **int** | Subscriber ID. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-tags-for-a-subscriber +* https://developers.convertkit.com/v4.html#list-tags-for-a-subscriber + +*** ---- ### get_broadcasts List broadcasts. @@ -980,145 +1025,159 @@ List broadcasts. public get_broadcasts(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-broadcasts +* https://developers.convertkit.com/v4.html#list-broadcasts + +*** ---- ### create_broadcast Creates a broadcast. ```php -public create_broadcast(string $subject = '', string $content = '', string $description = '', bool $public = false, \DateTime $published_at = null, \DateTime $send_at = null, string $email_address = '', string $email_template_id = '', string $thumbnail_alt = '', string $thumbnail_url = '', string $preview_text = '', array $subscriber_filter = []): false|object +public create_broadcast(string $subject = '', string $content = '', string $description = '', bool $public = false, \DateTime|null $published_at = null, \DateTime|null $send_at = null, string $email_address = '', string $email_template_id = '', string $thumbnail_alt = '', string $thumbnail_url = '', string $preview_text = '', array $subscriber_filter = []): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$subject` | **string** | The broadcast email's subject. | -| `$content` | **string** | The broadcast's email HTML content. | -| `$description` | **string** | An internal description of this broadcast. | -| `$public` | **bool** | Specifies whether or not this is a public post. | -| `$published_at` | **\DateTime** | Specifies the time that this post was published (applicable
only to public posts). | -| `$send_at` | **\DateTime** | Time that this broadcast should be sent; leave blank to create
a draft broadcast. If set to a future time, this is the time that
the broadcast will be scheduled to send. | -| `$email_address` | **string** | Sending email address; leave blank to use your account's
default sending email address. | -| `$email_template_id` | **string** | ID of the email template to use; leave blank to use your
account's default email template. | -| `$thumbnail_alt` | **string** | Specify the ALT attribute of the public thumbnail image
(applicable only to public posts). | -| `$thumbnail_url` | **string** | Specify the URL of the thumbnail image to accompany the broadcast
post (applicable only to public posts). | -| `$preview_text` | **string** | Specify the preview text of the email. | -| `$subscriber_filter` | **array** | Filter subscriber(s) to send the email to. | +| Parameter | Type | Description | +|----------------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `$subject` | **string** | The broadcast email's subject. | +| `$content` | **string** | The broadcast's email HTML content. | +| `$description` | **string** | An internal description of this broadcast. | +| `$public` | **bool** | Specifies whether or not this is a public post. | +| `$published_at` | **\DateTime\|null** | Specifies the time that this post was published (applicable +only to public posts). | +| `$send_at` | **\DateTime\|null** | Time that this broadcast should be sent; leave blank to create +a draft broadcast. If set to a future time, this is the time that +the broadcast will be scheduled to send. | +| `$email_address` | **string** | Sending email address; leave blank to use your account's +default sending email address. | +| `$email_template_id` | **string** | ID of the email template to use; leave blank to use your +account's default email template. | +| `$thumbnail_alt` | **string** | Specify the ALT attribute of the public thumbnail image +(applicable only to public posts). | +| `$thumbnail_url` | **string** | Specify the URL of the thumbnail image to accompany the broadcast +post (applicable only to public posts). | +| `$preview_text` | **string** | Specify the preview text of the email. | +| `$subscriber_filter` | **array** | Filter subscriber(s) to send the email to. | **See Also:** -* https://developers.convertkit.com/v4.html#create-a-broadcast +* https://developers.convertkit.com/v4.html#create-a-broadcast + +*** ---- ### get_broadcast Retrieve a specific broadcast. ```php -public get_broadcast(int $id): false|object +public get_broadcast(int $id): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$id` | **int** | Broadcast ID. | +| Parameter | Type | Description | +|-----------|---------|---------------| +| `$id` | **int** | Broadcast ID. | **See Also:** -* https://developers.convertkit.com/v4.html#get-a-broadcast +* https://developers.convertkit.com/v4.html#get-a-broadcast + +*** ---- ### get_broadcast_stats Get the statistics (recipient count, open rate, click rate, unsubscribe count, total clicks, status, and send progress) for a specific broadcast. ```php -public get_broadcast_stats(int $id): false|object +public get_broadcast_stats(int $id): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$id` | **int** | Broadcast ID. | +| Parameter | Type | Description | +|-----------|---------|---------------| +| `$id` | **int** | Broadcast ID. | **See Also:** -* https://developers.convertkit.com/v4.html#get-stats +* https://developers.convertkit.com/v4.html#get-stats + +*** ---- ### update_broadcast Updates a broadcast. ```php -public update_broadcast(int $id, string $subject = '', string $content = '', string $description = '', bool $public = false, \DateTime $published_at = null, \DateTime $send_at = null, string $email_address = '', string $email_template_id = '', string $thumbnail_alt = '', string $thumbnail_url = '', string $preview_text = '', array $subscriber_filter = []): false|object +public update_broadcast(int $id, string $subject = '', string $content = '', string $description = '', bool $public = false, \DateTime|null $published_at = null, \DateTime|null $send_at = null, string $email_address = '', string $email_template_id = '', string $thumbnail_alt = '', string $thumbnail_url = '', string $preview_text = '', array $subscriber_filter = []): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$id` | **int** | Broadcast ID. | -| `$subject` | **string** | The broadcast email's subject. | -| `$content` | **string** | The broadcast's email HTML content. | -| `$description` | **string** | An internal description of this broadcast. | -| `$public` | **bool** | Specifies whether or not this is a public post. | -| `$published_at` | **\DateTime** | Specifies the time that this post was published (applicable
only to public posts). | -| `$send_at` | **\DateTime** | Time that this broadcast should be sent; leave blank to create
a draft broadcast. If set to a future time, this is the time that
the broadcast will be scheduled to send. | -| `$email_address` | **string** | Sending email address; leave blank to use your account's
default sending email address. | -| `$email_template_id` | **string** | ID of the email template to use; leave blank to use your
account's default email template. | -| `$thumbnail_alt` | **string** | Specify the ALT attribute of the public thumbnail image
(applicable only to public posts). | -| `$thumbnail_url` | **string** | Specify the URL of the thumbnail image to accompany the broadcast
post (applicable only to public posts). | -| `$preview_text` | **string** | Specify the preview text of the email. | -| `$subscriber_filter` | **array** | Filter subscriber(s) to send the email to. | +| Parameter | Type | Description | +|----------------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `$id` | **int** | Broadcast ID. | +| `$subject` | **string** | The broadcast email's subject. | +| `$content` | **string** | The broadcast's email HTML content. | +| `$description` | **string** | An internal description of this broadcast. | +| `$public` | **bool** | Specifies whether or not this is a public post. | +| `$published_at` | **\DateTime\|null** | Specifies the time that this post was published (applicable +only to public posts). | +| `$send_at` | **\DateTime\|null** | Time that this broadcast should be sent; leave blank to create +a draft broadcast. If set to a future time, this is the time that +the broadcast will be scheduled to send. | +| `$email_address` | **string** | Sending email address; leave blank to use your account's +default sending email address. | +| `$email_template_id` | **string** | ID of the email template to use; leave blank to use your +account's default email template. | +| `$thumbnail_alt` | **string** | Specify the ALT attribute of the public thumbnail image +(applicable only to public posts). | +| `$thumbnail_url` | **string** | Specify the URL of the thumbnail image to accompany the broadcast +post (applicable only to public posts). | +| `$preview_text` | **string** | Specify the preview text of the email. | +| `$subscriber_filter` | **array** | Filter subscriber(s) to send the email to. | **See Also:** -* https://developers.convertkit.com/#create-a-broadcast +* https://developers.convertkit.com/#create-a-broadcast + +*** ---- ### delete_broadcast Deletes an existing broadcast. ```php -public delete_broadcast(int $id): false|object +public delete_broadcast(int $id): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$id` | **int** | Broadcast ID. | +| Parameter | Type | Description | +|-----------|---------|---------------| +| `$id` | **int** | Broadcast ID. | **See Also:** -* https://developers.convertkit.com/v4.html#delete-a-broadcast +* https://developers.convertkit.com/v4.html#delete-a-broadcast + +*** ---- ### get_webhooks List webhooks. @@ -1127,63 +1186,68 @@ List webhooks. public get_webhooks(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-webhooks +* https://developers.convertkit.com/v4.html#list-webhooks + +*** ---- ### create_webhook Creates a webhook that will be called based on the chosen event types. ```php -public create_webhook(string $url, string $event, string $parameter = ''): false|object +public create_webhook(string $url, string $event, string $parameter = ''): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$url` | **string** | URL to receive event. | -| `$event` | **string** | Event to subscribe to. | +| Parameter | Type | Description | +|--------------|------------|--------------------------------------------| +| `$url` | **string** | URL to receive event. | +| `$event` | **string** | Event to subscribe to. | | `$parameter` | **string** | Optional parameter depending on the event. | +**Throws:** + +If the event is not supported. +- [`InvalidArgumentException`](../InvalidArgumentException) + **See Also:** -* https://developers.convertkit.com/v4.html#create-a-webhook +* https://developers.convertkit.com/v4.html#create-a-webhook + +*** ---- ### delete_webhook Deletes an existing webhook. ```php -public delete_webhook(int $id): false|object +public delete_webhook(int $id): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$id` | **int** | Webhook ID. | +| Parameter | Type | Description | +|-----------|---------|-------------| +| `$id` | **int** | Webhook ID. | **See Also:** -* https://developers.convertkit.com/v4.html#delete-a-webhook +* https://developers.convertkit.com/v4.html#delete-a-webhook + +*** ---- ### get_custom_fields List custom fields. @@ -1192,103 +1256,103 @@ List custom fields. public get_custom_fields(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-custom-fields +* https://developers.convertkit.com/v4.html#list-custom-fields + +*** ---- ### create_custom_field Creates a custom field. ```php -public create_custom_field(string $label): false|object +public create_custom_field(string $label): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$label` | **string** | Custom Field label. | +| Parameter | Type | Description | +|-----------|------------|---------------------| +| `$label` | **string** | Custom Field label. | **See Also:** -* https://developers.convertkit.com/v4.html#create-a-custom-field +* https://developers.convertkit.com/v4.html#create-a-custom-field + +*** ---- ### create_custom_fields Creates multiple custom fields. ```php -public create_custom_fields(string[] $labels, string $callback_url = ''): false|object +public create_custom_fields(string[] $labels, string $callback_url = ''): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$labels` | **string[]** | Custom Fields labels. | -| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | +| Parameter | Type | Description | +|-----------------|--------------|--------------------------------------------------------------------| +| `$labels` | **string[]** | Custom Fields labels. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | **See Also:** -* https://developers.convertkit.com/v4.html#bulk-create-custom-fields +* https://developers.convertkit.com/v4.html#bulk-create-custom-fields + +*** ---- ### update_custom_field Updates an existing custom field. ```php -public update_custom_field(int $id, string $label): false|object +public update_custom_field(int $id, string $label): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$id` | **int** | Custom Field ID. | -| `$label` | **string** | Updated Custom Field label. | +| Parameter | Type | Description | +|-----------|------------|-----------------------------| +| `$id` | **int** | Custom Field ID. | +| `$label` | **string** | Updated Custom Field label. | **See Also:** -* https://developers.convertkit.com/v4.html#update-a-custom-field +* https://developers.convertkit.com/v4.html#update-a-custom-field + +*** ---- ### delete_custom_field Deletes an existing custom field. ```php -public delete_custom_field(int $id): false|object +public delete_custom_field(int $id): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$id` | **int** | Custom Field ID. | +| Parameter | Type | Description | +|-----------|---------|------------------| +| `$id` | **int** | Custom Field ID. | **See Also:** -* https://developers.convertkit.com/#destroy-field +* https://developers.convertkit.com/#destroy-field + +*** ---- ### get_purchases List purchases. @@ -1297,72 +1361,72 @@ List purchases. public get_purchases(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#list-purchases +* https://developers.convertkit.com/v4.html#list-purchases + +*** ---- ### get_purchase Retuns a specific purchase. ```php -public get_purchase(int $purchase_id): false|object +public get_purchase(int $purchase_id): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|----------------|---------|--------------| | `$purchase_id` | **int** | Purchase ID. | **See Also:** -* https://developers.convertkit.com/v4.html#get-a-purchase +* https://developers.convertkit.com/v4.html#get-a-purchase + +*** ---- ### create_purchase Creates a purchase. ```php -public create_purchase(string $email_address, string $transaction_id, array $products, string $currency = 'USD', string $first_name = null, string $status = null, float $subtotal, float $tax, float $shipping, float $discount, float $total, \DateTime $transaction_time = null): false|object +public create_purchase(string $email_address, string $transaction_id, array $products, string $currency = 'USD', string|null $first_name = null, string|null $status = null, float $subtotal, float $tax, float $shipping, float $discount, float $total, \DateTime|null $transaction_time = null): mixed|object ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$email_address` | **string** | Email Address. | -| `$transaction_id` | **string** | Transaction ID. | -| `$products` | **array** | Products. | -| `$currency` | **string** | ISO Currency Code. | -| `$first_name` | **string** | First Name. | -| `$status` | **string** | Order Status. | -| `$subtotal` | **float** | Subtotal. | -| `$tax` | **float** | Tax. | -| `$shipping` | **float** | Shipping. | -| `$discount` | **float** | Discount. | -| `$total` | **float** | Total. | -| `$transaction_time` | **\DateTime** | Transaction date and time. | +| Parameter | Type | Description | +|---------------------|--------------------------------------|----------------------------| +| `$email_address` | **string** | Email Address. | +| `$transaction_id` | **string** | Transaction ID. | +| `$products` | **array** | Products. | +| `$currency` | **string** | ISO Currency Code. | +| `$first_name` | **string\|null** | First Name. | +| `$status` | **string\|null** | Order Status. | +| `$subtotal` | **float** | Subtotal. | +| `$tax` | **float** | Tax. | +| `$shipping` | **float** | Shipping. | +| `$discount` | **float** | Discount. | +| `$total` | **float** | Total. | +| `$transaction_time` | **\DateTime\|null** | Transaction date and time. | **See Also:** -* https://developers.convertkit.com/v4.html#create-a-purchase +* https://developers.convertkit.com/v4.html#create-a-purchase + +*** ---- ### get_segments List segments. @@ -1371,21 +1435,21 @@ List segments. public get_segments(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | **See Also:** -* https://developers.convertkit.com/v4.html#convertkit-api-segments +* https://developers.convertkit.com/v4.html#convertkit-api-segments + +*** ---- ### convert_relative_to_absolute_urls Converts any relative URls to absolute, fully qualified HTTP(s) URLs for the given @@ -1395,17 +1459,16 @@ DOM Elements. public convert_relative_to_absolute_urls(\DOMNodeList<\DOMElement> $elements, string $attribute, string $url): void ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$elements` | **\DOMNodeList<\DOMElement>** | Elements. | -| `$attribute` | **string** | HTML Attribute. | -| `$url` | **string** | Absolute URL to prepend to relative URLs. | +| Parameter | Type | Description | +|--------------|-------------------------------|-------------------------------------------| +| `$elements` | **\DOMNodeList<\DOMElement>** | Elements. | +| `$attribute` | **string** | HTML Attribute. | +| `$url` | **string** | Absolute URL to prepend to relative URLs. | +*** ---- ### strip_html_head_body_tags Strips , and opening and closing tags from the given markup, @@ -1415,19 +1478,18 @@ as well as the Content-Type meta tag we might have added in get_html(). public strip_html_head_body_tags(string $markup): string ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| +| Parameter | Type | Description | +|-----------|------------|--------------| | `$markup` | **string** | HTML Markup. | **Return Value:** HTML Markup +*** ---- ### build_total_count_and_pagination_params Adds total count and pagination parameters to the given array of existing API parameters. @@ -1436,19 +1498,18 @@ Adds total count and pagination parameters to the given array of existing API pa private build_total_count_and_pagination_params(array $params = [], bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): array ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$params` | **array** | API parameters. | -| `$include_total_count` | **bool** | Return total count of records. | -| `$after_cursor` | **string** | Return results after the given pagination cursor. | -| `$before_cursor` | **string** | Return results before the given pagination cursor. | -| `$per_page` | **int** | Number of results to return. | +| Parameter | Type | Description | +|------------------------|-------------------------------------|----------------------------------------------------| +| `$params` | **array** | API parameters. | +| `$include_total_count` | **bool** | Return total count of records. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | +*** ---- ### get Performs a GET request to the API. @@ -1457,16 +1518,15 @@ Performs a GET request to the API. public get(string $endpoint, array> $args = []): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$endpoint` | **string** | API Endpoint. | -| `$args` | **array>** | Request arguments. | +| Parameter | Type | Description | +|-------------|----------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | +*** ---- ### post Performs a POST request to the API. @@ -1475,16 +1535,15 @@ Performs a POST request to the API. public post(string $endpoint, array> $args = []): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$endpoint` | **string** | API Endpoint. | -| `$args` | **array>** | Request arguments. | +| Parameter | Type | Description | +|-------------|-----------------------------------------------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | +*** ---- ### put Performs a PUT request to the API. @@ -1493,16 +1552,15 @@ Performs a PUT request to the API. public put(string $endpoint, array> $args = []): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$endpoint` | **string** | API Endpoint. | -| `$args` | **array>** | Request arguments. | +| Parameter | Type | Description | +|-------------|----------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | +*** ---- ### delete Performs a DELETE request to the API. @@ -1511,16 +1569,15 @@ Performs a DELETE request to the API. public delete(string $endpoint, array> $args = []): false|mixed ``` - **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$endpoint` | **string** | API Endpoint. | -| `$args` | **array>** | Request arguments. | +| Parameter | Type | Description | +|-------------|----------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | +*** ---- ### request Performs an API request. @@ -1528,18 +1585,23 @@ Performs an API request. ```php public request(string $endpoint, string $method, array> $args = []): false|mixed ``` -* This method is **abstract**. +* This method is **abstract**. **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$endpoint` | **string** | API Endpoint. | -| `$method` | **string** | Request method. | -| `$args` | **array>** | Request arguments. | +| Parameter | Type | Description | +|-------------|-----------------------------------------------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$method` | **string** | Request method. | +| `$args` | **array>** | Request arguments. | + +**Throws:** +If JSON encoding arguments failed. +- [`Exception`](../Exception) + +*** ---- ### get_request_headers Returns the headers to use in an API request. @@ -1547,17 +1609,17 @@ Returns the headers to use in an API request. ```php public get_request_headers(string $type = 'application/json', bool $auth = true): array ``` -* This method is **abstract**. +* This method is **abstract**. **Parameters:** -| Parameter | Type | Description | -|-----------|------|-------------| -| `$type` | **string** | Accept and Content-Type Headers. | -| `$auth` | **bool** | Include authorization header. | +| Parameter | Type | Description | +|-----------|------------|----------------------------------| +| `$type` | **string** | Accept and Content-Type Headers. | +| `$auth` | **bool** | Include authorization header. | +*** ---- ### get_timeout Returns the maximum amount of time to wait for @@ -1566,14 +1628,14 @@ a response to the request before exiting. ```php public get_timeout(): int ``` -* This method is **abstract**. +* This method is **abstract**. **Return Value:** Timeout, in seconds. +*** ---- ### get_user_agent Returns the user agent string to use in all HTTP requests. @@ -1581,9 +1643,6 @@ Returns the user agent string to use in all HTTP requests. ```php public get_user_agent(): string ``` -* This method is **abstract**. - - ---- - +* This method is **abstract**. +*** diff --git a/docs/classes/ConvertKit_API/ConvertKit_API_Traits.md b/docs/classes/ConvertKit_API/ConvertKit_API_Traits.md new file mode 100644 index 0000000..9d25991 --- /dev/null +++ b/docs/classes/ConvertKit_API/ConvertKit_API_Traits.md @@ -0,0 +1,1397 @@ + +ConvertKit API Traits + +*** + +* Full name: `\ConvertKit_API\ConvertKit_API_Traits` + +## Properties + +### client_id + +ConvertKit OAuth Application Client ID + +```php +protected string $client_id +``` + +*** +### client_secret + +ConvertKit OAuth Application Client Secret + +```php +protected string $client_secret +``` + +*** +### access_token + +Access Token + +```php +protected string $access_token +``` + +*** +### api_key + +API Key + +```php +protected string $api_key +``` + +*** +### oauth_authorize_url + +OAuth Authorization URL + +```php +protected string $oauth_authorize_url +``` + +*** +### oauth_token_url + +OAuth Token URL + +```php +protected string $oauth_token_url +``` + +*** +### api_version + +Version of ConvertKit API + +```php +protected string $api_version +``` + +*** +### api_url_base + +ConvertKit API URL + +```php +protected string $api_url_base +``` + +*** + +## Methods + +### get_account + +Gets the current account + +```php +public get_account(): false|mixed +``` + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-current-account + +*** +### get_account_colors + +Gets the account's colors + +```php +public get_account_colors(): false|mixed +``` + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-colors + +*** +### update_account_colors + +Gets the account's colors + +```php +public update_account_colors(array $colors): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|--------------------------|-------------| +| `$colors` | **array** | Hex colors. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-colors + +*** +### get_creator_profile + +Gets the Creator Profile + +```php +public get_creator_profile(): false|mixed +``` + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-creator-profile + +*** +### get_email_stats + +Gets email stats + +```php +public get_email_stats(): false|mixed +``` + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-email-stats + +*** +### get_growth_stats + +Gets growth stats + +```php +public get_growth_stats(\DateTime|null $starting = null, \DateTime|null $ending = null): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-------------|---------------------|-----------------------------------------------------------------------------| +| `$starting` | **\DateTime\|null** | Gets stats for time period beginning on this date. Defaults to 90 days ago. | +| `$ending` | **\DateTime\|null** | Gets stats for time period ending on this date. Defaults to today. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-growth-stats + +*** +### get_forms + +Get forms. + +```php +public get_forms(string $status = 'active', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$status` | **string** | Form status (active\|archived\|trashed\|all). | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#convertkit-api-forms + +*** +### get_landing_pages + +Get landing pages. + +```php +public get_landing_pages(string $status = 'active', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$status` | **string** | Form status (active\|archived\|trashed\|all). | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#convertkit-api-forms + +*** +### add_subscribers_to_forms + +Adds subscribers to forms in bulk. + +```php +public add_subscribers_to_forms(array[] $forms_subscribers_ids, string $callback_url = ''): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|--------------------------|----------------------------|---------------------------------------------------------------------------------------| +| `$forms_subscribers_ids` | **array[]** | Array of arrays comprising of `form_id`, `subscriber_id` and optional `referrer` URL. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | + +**See Also:** + +* https://developers.kit.com/v4.html#bulk-add-subscribers-to-forms + +*** +### add_subscriber_to_form_by_email + +Adds a subscriber to a form by email address + +```php +public add_subscriber_to_form_by_email(int $form_id, string $email_address, string $referrer = ''): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$form_id` | **int** | Form ID. | +| `$email_address` | **string** | Email Address. | +| `$referrer` | **string** | Referrer. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#add-subscriber-to-form-by-email-address + +*** +### add_subscriber_to_form + +Adds a subscriber to a form by subscriber ID + +```php +public add_subscriber_to_form(int $form_id, int $subscriber_id, string $referrer = ''): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$form_id` | **int** | Form ID. | +| `$subscriber_id` | **int** | Subscriber ID. | +| `$referrer` | **string** | Referrer URL. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#add-subscriber-to-form + +*** +### get_form_subscriptions + +List subscribers for a form + +```php +public get_form_subscriptions(int $form_id, string $subscriber_state = 'active', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $added_after = null, \DateTime|null $added_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$form_id` | **int** | Form ID. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$added_after` | **\DateTime\|null** | Filter subscribers who have been added to the form after this date. | +| `$added_before` | **\DateTime\|null** | Filter subscribers who have been added to the form before this date. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-subscribers-for-a-form + +*** +### get_sequences + +Gets sequences + +```php +public get_sequences(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-sequences + +*** +### add_subscriber_to_sequence_by_email + +Adds a subscriber to a sequence by email address + +```php +public add_subscriber_to_sequence_by_email(int $sequence_id, string $email_address): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$sequence_id` | **int** | Sequence ID. | +| `$email_address` | **string** | Email Address. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#add-subscriber-to-sequence-by-email-address + +*** +### add_subscriber_to_sequence + +Adds a subscriber to a sequence by subscriber ID + +```php +public add_subscriber_to_sequence(int $sequence_id, int $subscriber_id): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$sequence_id` | **int** | Sequence ID. | +| `$subscriber_id` | **int** | Subscriber ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#add-subscriber-to-sequence + +*** +### get_sequence_subscriptions + +List subscribers for a sequence + +```php +public get_sequence_subscriptions(int $sequence_id, string $subscriber_state = 'active', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $added_after = null, \DateTime|null $added_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$sequence_id` | **int** | Sequence ID. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$added_after` | **\DateTime\|null** | Filter subscribers who have been added to the form after this date. | +| `$added_before` | **\DateTime\|null** | Filter subscribers who have been added to the form before this date. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-subscribers-for-a-sequence + +*** +### get_tags + +List tags. + +```php +public get_tags(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-tags + +*** +### create_tag + +Creates a tag. + +```php +public create_tag(string $tag): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------------|-------------| +| `$tag` | **string** | Tag Name. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#create-a-tag + +*** +### create_tags + +Creates multiple tags. + +```php +public create_tags(array $tags, string $callback_url = ''): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------------|-----------------------|--------------------------------------------------------------------| +| `$tags` | **array** | Tag Names. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#bulk-create-tags + +*** +### tag_subscriber_by_email + +Tags a subscriber with the given existing Tag. + +```php +public tag_subscriber_by_email(int $tag_id, string $email_address): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$tag_id` | **int** | Tag ID. | +| `$email_address` | **string** | Email Address. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#tag-a-subscriber-by-email-address + +*** +### tag_subscriber + +Tags a subscriber by subscriber ID with the given existing Tag. + +```php +public tag_subscriber(int $tag_id, int $subscriber_id): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$tag_id` | **int** | Tag ID. | +| `$subscriber_id` | **int** | Subscriber ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#tag-a-subscriber + +*** +### remove_tag_from_subscriber + +Removes a tag from a subscriber. + +```php +public remove_tag_from_subscriber(int $tag_id, int $subscriber_id): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$tag_id` | **int** | Tag ID. | +| `$subscriber_id` | **int** | Subscriber ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#remove-tag-from-subscriber + +*** +### remove_tag_from_subscriber_by_email + +Removes a tag from a subscriber by email address. + +```php +public remove_tag_from_subscriber_by_email(int $tag_id, string $email_address): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|------------|---------------------------| +| `$tag_id` | **int** | Tag ID. | +| `$email_address` | **string** | Subscriber email address. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#remove-tag-from-subscriber-by-email-address + +*** +### get_tag_subscriptions + +List subscribers for a tag + +```php +public get_tag_subscriptions(int $tag_id, string $subscriber_state = 'active', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $tagged_after = null, \DateTime|null $tagged_before = null, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$tag_id` | **int** | Tag ID. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$tagged_after` | **\DateTime\|null** | Filter subscribers who have been tagged after this date. | +| `$tagged_before` | **\DateTime\|null** | Filter subscribers who have been tagged before this date. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-subscribers-for-a-tag + +*** +### get_email_templates + +List email templates. + +```php +public get_email_templates(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#convertkit-api-email-templates + +*** +### get_subscribers + +List subscribers. + +```php +public get_subscribers(string $subscriber_state = 'active', string $email_address = '', \DateTime|null $created_after = null, \DateTime|null $created_before = null, \DateTime|null $updated_after = null, \DateTime|null $updated_before = null, string $sort_field = 'id', string $sort_order = 'desc', bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|---------------------|----------------------------------------------------------------------| +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$email_address` | **string** | Search susbcribers by email address. This is an exact match search. | +| `$created_after` | **\DateTime\|null** | Filter subscribers who have been created after this date. | +| `$created_before` | **\DateTime\|null** | Filter subscribers who have been created before this date. | +| `$updated_after` | **\DateTime\|null** | Filter subscribers who have been updated after this date. | +| `$updated_before` | **\DateTime\|null** | Filter subscribers who have been updated before this date. | +| `$sort_field` | **string** | Sort Field (id\|updated_at\|cancelled_at). | +| `$sort_order` | **string** | Sort Order (asc\|desc). | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-subscribers + +*** +### create_subscriber + +Create a subscriber. + +```php +public create_subscriber(string $email_address, string $first_name = '', string $subscriber_state = '', array $fields = []): mixed +``` + +Behaves as an upsert. If a subscriber with the provided email address does not exist, +it creates one with the specified first name and state. If a subscriber with the provided +email address already exists, it updates the first name. + +**Parameters:** + +| Parameter | Type | Description | +|---------------------|--------------------------|----------------------------------------------------------------------| +| `$email_address` | **string** | Email Address. | +| `$first_name` | **string** | First Name. | +| `$subscriber_state` | **string** | Subscriber State (active\|bounced\|cancelled\|complained\|inactive). | +| `$fields` | **array** | Custom Fields. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#create-a-subscriber + +*** +### create_subscribers + +Create multiple subscribers. + +```php +public create_subscribers(array> $subscribers, string $callback_url = ''): mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------------|-------------------------------------|--------------------------------------------------------------------| +| `$subscribers` | **array>** | Subscribers. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#bulk-create-subscribers + +*** +### get_subscriber_id + +Get the ConvertKit subscriber ID associated with email address if it exists. + +```php +public get_subscriber_id(string $email_address): false|int +``` + +Return false if subscriber not found. + +**Parameters:** + +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$email_address` | **string** | Email Address. | + +**Throws:** + +If the email address is not a valid email format. +- [`InvalidArgumentException`](../InvalidArgumentException) + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-a-subscriber + +*** +### get_subscriber + +Get subscriber by id + +```php +public get_subscriber(int $subscriber_id): mixed|int +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$subscriber_id` | **int** | Subscriber ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-a-subscriber + +*** +### update_subscriber + +Updates the information for a single subscriber. + +```php +public update_subscriber(int $subscriber_id, string $first_name = '', string $email_address = '', array $fields = []): mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|--------------------------|-------------------------| +| `$subscriber_id` | **int** | Existing Subscriber ID. | +| `$first_name` | **string** | New First Name. | +| `$email_address` | **string** | New Email Address. | +| `$fields` | **array** | Updated Custom Fields. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#update-a-subscriber + +*** +### unsubscribe_by_email + +Unsubscribe an email address. + +```php +public unsubscribe_by_email(string $email_address): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|------------|----------------| +| `$email_address` | **string** | Email Address. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#unsubscribe-subscriber + +*** +### unsubscribe + +Unsubscribe the given subscriber ID. + +```php +public unsubscribe(int $subscriber_id): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------|---------|----------------| +| `$subscriber_id` | **int** | Subscriber ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#unsubscribe-subscriber + +*** +### get_subscriber_tags + +Get a list of the tags for a subscriber. + +```php +public get_subscriber_tags(int $subscriber_id, bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): mixed|array +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$subscriber_id` | **int** | Subscriber ID. | +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-tags-for-a-subscriber + +*** +### get_broadcasts + +List broadcasts. + +```php +public get_broadcasts(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-broadcasts + +*** +### create_broadcast + +Creates a broadcast. + +```php +public create_broadcast(string $subject = '', string $content = '', string $description = '', bool $public = false, \DateTime|null $published_at = null, \DateTime|null $send_at = null, string $email_address = '', string $email_template_id = '', string $thumbnail_alt = '', string $thumbnail_url = '', string $preview_text = '', array $subscriber_filter = []): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|----------------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `$subject` | **string** | The broadcast email's subject. | +| `$content` | **string** | The broadcast's email HTML content. | +| `$description` | **string** | An internal description of this broadcast. | +| `$public` | **bool** | Specifies whether or not this is a public post. | +| `$published_at` | **\DateTime\|null** | Specifies the time that this post was published (applicable +only to public posts). | +| `$send_at` | **\DateTime\|null** | Time that this broadcast should be sent; leave blank to create +a draft broadcast. If set to a future time, this is the time that +the broadcast will be scheduled to send. | +| `$email_address` | **string** | Sending email address; leave blank to use your account's +default sending email address. | +| `$email_template_id` | **string** | ID of the email template to use; leave blank to use your +account's default email template. | +| `$thumbnail_alt` | **string** | Specify the ALT attribute of the public thumbnail image +(applicable only to public posts). | +| `$thumbnail_url` | **string** | Specify the URL of the thumbnail image to accompany the broadcast +post (applicable only to public posts). | +| `$preview_text` | **string** | Specify the preview text of the email. | +| `$subscriber_filter` | **array** | Filter subscriber(s) to send the email to. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#create-a-broadcast + +*** +### get_broadcast + +Retrieve a specific broadcast. + +```php +public get_broadcast(int $id): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|---------|---------------| +| `$id` | **int** | Broadcast ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-a-broadcast + +*** +### get_broadcast_stats + +Get the statistics (recipient count, open rate, click rate, unsubscribe count, +total clicks, status, and send progress) for a specific broadcast. + +```php +public get_broadcast_stats(int $id): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|---------|---------------| +| `$id` | **int** | Broadcast ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-stats + +*** +### update_broadcast + +Updates a broadcast. + +```php +public update_broadcast(int $id, string $subject = '', string $content = '', string $description = '', bool $public = false, \DateTime|null $published_at = null, \DateTime|null $send_at = null, string $email_address = '', string $email_template_id = '', string $thumbnail_alt = '', string $thumbnail_url = '', string $preview_text = '', array $subscriber_filter = []): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|----------------------|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `$id` | **int** | Broadcast ID. | +| `$subject` | **string** | The broadcast email's subject. | +| `$content` | **string** | The broadcast's email HTML content. | +| `$description` | **string** | An internal description of this broadcast. | +| `$public` | **bool** | Specifies whether or not this is a public post. | +| `$published_at` | **\DateTime\|null** | Specifies the time that this post was published (applicable +only to public posts). | +| `$send_at` | **\DateTime\|null** | Time that this broadcast should be sent; leave blank to create +a draft broadcast. If set to a future time, this is the time that +the broadcast will be scheduled to send. | +| `$email_address` | **string** | Sending email address; leave blank to use your account's +default sending email address. | +| `$email_template_id` | **string** | ID of the email template to use; leave blank to use your +account's default email template. | +| `$thumbnail_alt` | **string** | Specify the ALT attribute of the public thumbnail image +(applicable only to public posts). | +| `$thumbnail_url` | **string** | Specify the URL of the thumbnail image to accompany the broadcast +post (applicable only to public posts). | +| `$preview_text` | **string** | Specify the preview text of the email. | +| `$subscriber_filter` | **array** | Filter subscriber(s) to send the email to. | + +**See Also:** + +* https://developers.convertkit.com/#create-a-broadcast + +*** +### delete_broadcast + +Deletes an existing broadcast. + +```php +public delete_broadcast(int $id): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|---------|---------------| +| `$id` | **int** | Broadcast ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#delete-a-broadcast + +*** +### get_webhooks + +List webhooks. + +```php +public get_webhooks(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-webhooks + +*** +### create_webhook + +Creates a webhook that will be called based on the chosen event types. + +```php +public create_webhook(string $url, string $event, string $parameter = ''): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|--------------|------------|--------------------------------------------| +| `$url` | **string** | URL to receive event. | +| `$event` | **string** | Event to subscribe to. | +| `$parameter` | **string** | Optional parameter depending on the event. | + +**Throws:** + +If the event is not supported. +- [`InvalidArgumentException`](../InvalidArgumentException) + +**See Also:** + +* https://developers.convertkit.com/v4.html#create-a-webhook + +*** +### delete_webhook + +Deletes an existing webhook. + +```php +public delete_webhook(int $id): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|---------|-------------| +| `$id` | **int** | Webhook ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#delete-a-webhook + +*** +### get_custom_fields + +List custom fields. + +```php +public get_custom_fields(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-custom-fields + +*** +### create_custom_field + +Creates a custom field. + +```php +public create_custom_field(string $label): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------------|---------------------| +| `$label` | **string** | Custom Field label. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#create-a-custom-field + +*** +### create_custom_fields + +Creates multiple custom fields. + +```php +public create_custom_fields(string[] $labels, string $callback_url = ''): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------------|--------------|--------------------------------------------------------------------| +| `$labels` | **string[]** | Custom Fields labels. | +| `$callback_url` | **string** | URL to notify for large batch size when async processing complete. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#bulk-create-custom-fields + +*** +### update_custom_field + +Updates an existing custom field. + +```php +public update_custom_field(int $id, string $label): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------------|-----------------------------| +| `$id` | **int** | Custom Field ID. | +| `$label` | **string** | Updated Custom Field label. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#update-a-custom-field + +*** +### delete_custom_field + +Deletes an existing custom field. + +```php +public delete_custom_field(int $id): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|---------|------------------| +| `$id` | **int** | Custom Field ID. | + +**See Also:** + +* https://developers.convertkit.com/#destroy-field + +*** +### get_purchases + +List purchases. + +```php +public get_purchases(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#list-purchases + +*** +### get_purchase + +Retuns a specific purchase. + +```php +public get_purchase(int $purchase_id): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|----------------|---------|--------------| +| `$purchase_id` | **int** | Purchase ID. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#get-a-purchase + +*** +### create_purchase + +Creates a purchase. + +```php +public create_purchase(string $email_address, string $transaction_id, array $products, string $currency = 'USD', string|null $first_name = null, string|null $status = null, float $subtotal, float $tax, float $shipping, float $discount, float $total, \DateTime|null $transaction_time = null): mixed|object +``` + +**Parameters:** + +| Parameter | Type | Description | +|---------------------|--------------------------------------|----------------------------| +| `$email_address` | **string** | Email Address. | +| `$transaction_id` | **string** | Transaction ID. | +| `$products` | **array** | Products. | +| `$currency` | **string** | ISO Currency Code. | +| `$first_name` | **string\|null** | First Name. | +| `$status` | **string\|null** | Order Status. | +| `$subtotal` | **float** | Subtotal. | +| `$tax` | **float** | Tax. | +| `$shipping` | **float** | Shipping. | +| `$discount` | **float** | Discount. | +| `$total` | **float** | Total. | +| `$transaction_time` | **\DateTime\|null** | Transaction date and time. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#create-a-purchase + +*** +### get_segments + +List segments. + +```php +public get_segments(bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|------------|------------------------------------------------------------------| +| `$include_total_count` | **bool** | To include the total count of records in the response, use true. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +**See Also:** + +* https://developers.convertkit.com/v4.html#convertkit-api-segments + +*** +### convert_relative_to_absolute_urls + +Converts any relative URls to absolute, fully qualified HTTP(s) URLs for the given +DOM Elements. + +```php +public convert_relative_to_absolute_urls(\DOMNodeList<\DOMElement> $elements, string $attribute, string $url): void +``` + +**Parameters:** + +| Parameter | Type | Description | +|--------------|-------------------------------|-------------------------------------------| +| `$elements` | **\DOMNodeList<\DOMElement>** | Elements. | +| `$attribute` | **string** | HTML Attribute. | +| `$url` | **string** | Absolute URL to prepend to relative URLs. | + +*** +### strip_html_head_body_tags + +Strips , and opening and closing tags from the given markup, +as well as the Content-Type meta tag we might have added in get_html(). + +```php +public strip_html_head_body_tags(string $markup): string +``` + +**Parameters:** + +| Parameter | Type | Description | +|-----------|------------|--------------| +| `$markup` | **string** | HTML Markup. | + +**Return Value:** + +HTML Markup + +*** +### build_total_count_and_pagination_params + +Adds total count and pagination parameters to the given array of existing API parameters. + +```php +private build_total_count_and_pagination_params(array $params = [], bool $include_total_count = false, string $after_cursor = '', string $before_cursor = '', int $per_page = 100): array +``` + +**Parameters:** + +| Parameter | Type | Description | +|------------------------|-------------------------------------|----------------------------------------------------| +| `$params` | **array** | API parameters. | +| `$include_total_count` | **bool** | Return total count of records. | +| `$after_cursor` | **string** | Return results after the given pagination cursor. | +| `$before_cursor` | **string** | Return results before the given pagination cursor. | +| `$per_page` | **int** | Number of results to return. | + +*** +### get + +Performs a GET request to the API. + +```php +public get(string $endpoint, array> $args = []): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-------------|----------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | + +*** +### post + +Performs a POST request to the API. + +```php +public post(string $endpoint, array> $args = []): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-------------|-----------------------------------------------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | + +*** +### put + +Performs a PUT request to the API. + +```php +public put(string $endpoint, array> $args = []): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-------------|----------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | + +*** +### delete + +Performs a DELETE request to the API. + +```php +public delete(string $endpoint, array> $args = []): false|mixed +``` + +**Parameters:** + +| Parameter | Type | Description | +|-------------|----------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$args` | **array>** | Request arguments. | + +*** +### request + +Performs an API request. + +```php +public request(string $endpoint, string $method, array> $args = []): false|mixed +``` + +* This method is **abstract**. +**Parameters:** + +| Parameter | Type | Description | +|-------------|-----------------------------------------------------------------------------------------------------|--------------------| +| `$endpoint` | **string** | API Endpoint. | +| `$method` | **string** | Request method. | +| `$args` | **array>** | Request arguments. | + +**Throws:** + +If JSON encoding arguments failed. +- [`Exception`](../Exception) + +*** +### get_request_headers + +Returns the headers to use in an API request. + +```php +public get_request_headers(string $type = 'application/json', bool $auth = true): array +``` + +* This method is **abstract**. +**Parameters:** + +| Parameter | Type | Description | +|-----------|------------|----------------------------------| +| `$type` | **string** | Accept and Content-Type Headers. | +| `$auth` | **bool** | Include authorization header. | + +*** +### get_timeout + +Returns the maximum amount of time to wait for +a response to the request before exiting. + +```php +public get_timeout(): int +``` + +* This method is **abstract**. +**Return Value:** + +Timeout, in seconds. + +*** +### get_user_agent + +Returns the user agent string to use in all HTTP requests. + +```php +public get_user_agent(): string +``` + +* This method is **abstract**. +***