From c90db59487ac8314ead6c3ae3016a09ad4596d15 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 22 Jul 2024 11:06:15 +0800 Subject: [PATCH 1/9] Replace `convertkit.com` with `kit.com` --- .env.dist.testing | 2 +- .env.example | 2 +- composer.json | 2 +- src/class-convertkit-api-traits.php | 108 ++++++++++++------------ src/class-convertkit-api-v4.php | 18 ++-- src/class-convertkit-review-request.php | 2 +- tests/_support/Helper/WPUnit/API.php | 2 +- tests/wpunit/APITest.php | 24 +++--- tests/wpunit/ResourceTest.php | 4 +- 9 files changed, 82 insertions(+), 82 deletions(-) diff --git a/.env.dist.testing b/.env.dist.testing index cc9386b..ed32763 100644 --- a/.env.dist.testing +++ b/.env.dist.testing @@ -25,7 +25,7 @@ CONVERTKIT_API_LANDING_PAGE_URL="https://cheerful-architect-3237.ck.page/99f1db6 CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_ID="2849151" CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_URL="https://cheerful-architect-3237.ck.page/cc5eb21744" CONVERTKIT_API_LEGACY_LANDING_PAGE_ID="470103" -CONVERTKIT_API_LEGACY_LANDING_PAGE_URL="https://app.convertkit.com/landing_pages/470103" +CONVERTKIT_API_LEGACY_LANDING_PAGE_URL="https://app.kit.com/landing_pages/470103" CONVERTKIT_API_POST_ID="3175837" CONVERTKIT_API_PRODUCT_ID="36377" CONVERTKIT_API_SEQUENCE_ID="1030824" diff --git a/.env.example b/.env.example index 4e150e1..3dd7952 100644 --- a/.env.example +++ b/.env.example @@ -33,7 +33,7 @@ CONVERTKIT_API_LANDING_PAGE_URL="https://cheerful-architect-3237.ck.page/99f1db6 CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_ID="2849151" CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_URL="https://cheerful-architect-3237.ck.page/cc5eb21744" CONVERTKIT_API_LEGACY_LANDING_PAGE_ID="470103" -CONVERTKIT_API_LEGACY_LANDING_PAGE_URL="https://app.convertkit.com/landing_pages/470103" +CONVERTKIT_API_LEGACY_LANDING_PAGE_URL="https://app.kit.com/landing_pages/470103" CONVERTKIT_API_POST_ID="3175837" CONVERTKIT_API_PRODUCT_ID="36377" CONVERTKIT_API_SEQUENCE_ID="1030824" diff --git a/composer.json b/composer.json index 10c99ff..c998af9 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "authors": [ { "name": "ConvertKit", - "email": "support@convertkit.com" + "email": "support@kit.com" } ], "type": "library", diff --git a/src/class-convertkit-api-traits.php b/src/class-convertkit-api-traits.php index d57fd1c..ccc7d8e 100644 --- a/src/class-convertkit-api-traits.php +++ b/src/class-convertkit-api-traits.php @@ -36,14 +36,14 @@ trait ConvertKit_API_Traits * * @var string */ - protected $oauth_authorize_url = 'https://app.convertkit.com/oauth/authorize'; + protected $oauth_authorize_url = 'https://app.kit.com/oauth/authorize'; /** * OAuth Token URL * * @var string */ - protected $oauth_token_url = 'https://api.convertkit.com/oauth/token'; + protected $oauth_token_url = 'https://api.kit.com/oauth/token'; /** * Version of ConvertKit API @@ -57,13 +57,13 @@ trait ConvertKit_API_Traits * * @var string */ - protected $api_url_base = 'https://api.convertkit.com/'; + protected $api_url_base = 'https://api.kit.com/'; /** * Gets the current account * - * @see https://developers.convertkit.com/v4.html#get-current-account + * @see https://developers.kit.com/v4.html#get-current-account * * @return WP_Error|array */ @@ -75,7 +75,7 @@ public function get_account() /** * Gets the account's colors * - * @see https://developers.convertkit.com/v4.html#list-colors + * @see https://developers.kit.com/v4.html#list-colors * * @return WP_Error|array */ @@ -89,7 +89,7 @@ public function get_account_colors() * * @param array $colors Hex colors. * - * @see https://developers.convertkit.com/v4.html#list-colors + * @see https://developers.kit.com/v4.html#list-colors * * @return WP_Error|array */ @@ -104,7 +104,7 @@ public function update_account_colors(array $colors) /** * Gets the Creator Profile * - * @see https://developers.convertkit.com/v4.html#get-creator-profile + * @see https://developers.kit.com/v4.html#get-creator-profile * * @return WP_Error|array */ @@ -116,7 +116,7 @@ public function get_creator_profile() /** * Gets email stats * - * @see https://developers.convertkit.com/v4.html#get-email-stats + * @see https://developers.kit.com/v4.html#get-email-stats * * @return WP_Error|array */ @@ -131,7 +131,7 @@ public function get_email_stats() * @param \DateTime $starting Gets stats for time period beginning on this date. Defaults to 90 days ago. * @param \DateTime $ending Gets stats for time period ending on this date. Defaults to today. * - * @see https://developers.convertkit.com/v4.html#get-growth-stats + * @see https://developers.kit.com/v4.html#get-growth-stats * * @return WP_Error|array */ @@ -157,7 +157,7 @@ public function get_growth_stats(\DateTime $starting = null, \DateTime $ending = * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#convertkit-api-forms + * @see https://developers.kit.com/v4.html#convertkit-api-forms * * @return WP_Error|array */ @@ -194,7 +194,7 @@ public function get_forms( * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#convertkit-api-forms + * @see https://developers.kit.com/v4.html#convertkit-api-forms * * @return WP_Error|array */ @@ -226,7 +226,7 @@ public function get_landing_pages( * @param integer $form_id Form ID. * @param string $email_address Email Address. * - * @see https://developers.convertkit.com/v4.html#add-subscriber-to-form-by-email-address + * @see https://developers.kit.com/v4.html#add-subscriber-to-form-by-email-address * * @return WP_Error|array */ @@ -244,7 +244,7 @@ public function add_subscriber_to_form_by_email(int $form_id, string $email_addr * @param integer $form_id Form ID. * @param integer $subscriber_id Subscriber ID. * - * @see https://developers.convertkit.com/v4.html#add-subscriber-to-form + * @see https://developers.kit.com/v4.html#add-subscriber-to-form * * @since 2.0.0 * @@ -284,7 +284,7 @@ public function add_subscriber_to_legacy_form(int $form_id, int $subscriber_id) * @param string $before_cursor Return results before the given pagination cursor. * @param integer $per_page Number of results to return. * - * @see https://developers.convertkit.com/v4.html#list-subscribers-for-a-form + * @see https://developers.kit.com/v4.html#list-subscribers-for-a-form * * @return WP_Error|array */ @@ -340,7 +340,7 @@ public function get_form_subscriptions( * @param string $before_cursor Return results before the given pagination cursor. * @param integer $per_page Number of results to return. * - * @see https://developers.convertkit.com/v4.html#list-sequences + * @see https://developers.kit.com/v4.html#list-sequences * * @return WP_Error|array */ @@ -368,7 +368,7 @@ public function get_sequences( * @param integer $sequence_id Sequence ID. * @param string $email_address Email Address. * - * @see https://developers.convertkit.com/v4.html#add-subscriber-to-sequence-by-email-address + * @see https://developers.kit.com/v4.html#add-subscriber-to-sequence-by-email-address * * @return WP_Error|array */ @@ -386,7 +386,7 @@ public function add_subscriber_to_sequence_by_email(int $sequence_id, string $em * @param integer $sequence_id Sequence ID. * @param integer $subscriber_id Subscriber ID. * - * @see https://developers.convertkit.com/v4.html#add-subscriber-to-sequence + * @see https://developers.kit.com/v4.html#add-subscriber-to-sequence * * @since 2.0.0 * @@ -411,7 +411,7 @@ public function add_subscriber_to_sequence(int $sequence_id, int $subscriber_id) * @param string $before_cursor Return results before the given pagination cursor. * @param integer $per_page Number of results to return. * - * @see https://developers.convertkit.com/v4.html#list-subscribers-for-a-sequence + * @see https://developers.kit.com/v4.html#list-subscribers-for-a-sequence * * @return WP_Error|array */ @@ -467,7 +467,7 @@ public function get_sequence_subscriptions( * @param string $before_cursor Return results before the given pagination cursor. * @param integer $per_page Number of results to return. * - * @see https://developers.convertkit.com/v4.html#list-tags + * @see https://developers.kit.com/v4.html#list-tags * * @return WP_Error|array */ @@ -496,7 +496,7 @@ public function get_tags( * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#create-a-tag + * @see https://developers.kit.com/v4.html#create-a-tag * * @return WP_Error|array */ @@ -516,7 +516,7 @@ public function create_tag(string $tag) * * @since 1.1.0 * - * @see https://developers.convertkit.com/v4.html#bulk-create-tags + * @see https://developers.kit.com/v4.html#bulk-create-tags * * @return WP_Error|array */ @@ -549,7 +549,7 @@ public function create_tags(array $tags, string $callback_url = '') * @param integer $tag_id Tag ID. * @param string $email_address Email Address. * - * @see https://developers.convertkit.com/v4.html#tag-a-subscriber-by-email-address + * @see https://developers.kit.com/v4.html#tag-a-subscriber-by-email-address * * @return WP_Error|array */ @@ -567,7 +567,7 @@ public function tag_subscriber_by_email(int $tag_id, string $email_address) * @param integer $tag_id Tag ID. * @param integer $subscriber_id Subscriber ID. * - * @see https://developers.convertkit.com/v4.html#tag-a-subscriber + * @see https://developers.kit.com/v4.html#tag-a-subscriber * * @return WP_Error|array */ @@ -584,7 +584,7 @@ public function tag_subscriber(int $tag_id, int $subscriber_id) * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#remove-tag-from-subscriber + * @see https://developers.kit.com/v4.html#remove-tag-from-subscriber * * @return WP_Error|array */ @@ -601,7 +601,7 @@ public function remove_tag_from_subscriber(int $tag_id, int $subscriber_id) * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#remove-tag-from-subscriber-by-email-address + * @see https://developers.kit.com/v4.html#remove-tag-from-subscriber-by-email-address * * @return WP_Error|array */ @@ -627,7 +627,7 @@ public function remove_tag_from_subscriber_by_email(int $tag_id, string $email_a * @param string $before_cursor Return results before the given pagination cursor. * @param integer $per_page Number of results to return. * - * @see https://developers.convertkit.com/v4.html#list-subscribers-for-a-tag + * @see https://developers.kit.com/v4.html#list-subscribers-for-a-tag * * @return WP_Error|array */ @@ -685,7 +685,7 @@ public function get_tag_subscriptions( * * @since 2.0.0 * - * @see https://developers.convertkit.com/v4.html#convertkit-api-email-templates + * @see https://developers.kit.com/v4.html#convertkit-api-email-templates * * @return WP_Error|array */ @@ -726,7 +726,7 @@ public function get_email_templates( * * @since 2.0.0 * - * @see https://developers.convertkit.com/v4.html#list-subscribers + * @see https://developers.kit.com/v4.html#list-subscribers * * @return WP_Error|array */ @@ -799,7 +799,7 @@ public function get_subscribers( * * @since 2.0.0 * - * @see https://developers.convertkit.com/v4.html#create-a-subscriber + * @see https://developers.kit.com/v4.html#create-a-subscriber * * @return mixed */ @@ -837,7 +837,7 @@ public function create_subscriber( * * @since 2.0.0 * - * @see https://developers.convertkit.com/v4.html#bulk-create-subscribers + * @see https://developers.kit.com/v4.html#bulk-create-subscribers * * @return mixed */ @@ -865,7 +865,7 @@ public function create_subscribers(array $subscribers, string $callback_url = '' * * @throws \InvalidArgumentException If the email address is not a valid email format. * - * @see https://developers.convertkit.com/v4.html#get-a-subscriber + * @see https://developers.kit.com/v4.html#get-a-subscriber * * @return bool|WP_Error|integer */ @@ -889,7 +889,7 @@ public function get_subscriber_id(string $email_address) * * @param integer $subscriber_id Subscriber ID. * - * @see https://developers.convertkit.com/v4.html#get-a-subscriber + * @see https://developers.kit.com/v4.html#get-a-subscriber * * @return bool|WP_Error|array */ @@ -906,7 +906,7 @@ public function get_subscriber(int $subscriber_id) * @param string $email_address New Email Address. * @param array $fields Updated Custom Fields. * - * @see https://developers.convertkit.com/v4.html#update-a-subscriber + * @see https://developers.kit.com/v4.html#update-a-subscriber * * @return WP_Error|array */ @@ -941,7 +941,7 @@ public function update_subscriber( * * @param string $email_address Email Address. * - * @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber + * @see https://developers.kit.com/v4.html#unsubscribe-subscriber * * @return bool|WP_Error|array */ @@ -960,7 +960,7 @@ public function unsubscribe_by_email(string $email_address) * * @param integer $subscriber_id Subscriber ID. * - * @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber + * @see https://developers.kit.com/v4.html#unsubscribe-subscriber * * @return bool|WP_Error|array */ @@ -978,7 +978,7 @@ public function unsubscribe(int $subscriber_id) * @param string $before_cursor Return results before the given pagination cursor. * @param integer $per_page Number of results to return. * - * @see https://developers.convertkit.com/v4.html#list-tags-for-a-subscriber + * @see https://developers.kit.com/v4.html#list-tags-for-a-subscriber * * @return WP_Error|array */ @@ -1009,7 +1009,7 @@ public function get_subscriber_tags( * @param string $before_cursor Return results before the given pagination cursor. * @param integer $per_page Number of results to return. * - * @see https://developers.convertkit.com/v4.html#list-broadcasts + * @see https://developers.kit.com/v4.html#list-broadcasts * * @return WP_Error|array */ @@ -1055,7 +1055,7 @@ public function get_broadcasts( * @param string $preview_text Specify the preview text of the email. * @param array $subscriber_filter Filter subscriber(s) to send the email to. * - * @see https://developers.convertkit.com/v4.html#create-a-broadcast + * @see https://developers.kit.com/v4.html#create-a-broadcast * * @return bool|WP_Error|array */ @@ -1114,7 +1114,7 @@ public function create_broadcast( * * @param integer $id Broadcast ID. * - * @see https://developers.convertkit.com/v4.html#get-a-broadcast + * @see https://developers.kit.com/v4.html#get-a-broadcast * * @return bool|WP_Error|array */ @@ -1129,7 +1129,7 @@ public function get_broadcast(int $id) * * @param integer $id Broadcast ID. * - * @see https://developers.convertkit.com/v4.html#get-stats + * @see https://developers.kit.com/v4.html#get-stats * * @return bool|WP_Error|array */ @@ -1162,7 +1162,7 @@ public function get_broadcast_stats(int $id) * @param string $preview_text Specify the preview text of the email. * @param array $subscriber_filter Filter subscriber(s) to send the email to. * - * @see https://developers.convertkit.com/#create-a-broadcast + * @see https://developers.kit.com/#create-a-broadcast * * @return bool|WP_Error|array */ @@ -1224,7 +1224,7 @@ public function update_broadcast( * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#delete-a-broadcast + * @see https://developers.kit.com/v4.html#delete-a-broadcast * * @return bool|WP_Error|array */ @@ -1243,7 +1243,7 @@ public function delete_broadcast(int $id) * * @since 2.0.0 * - * @see https://developers.convertkit.com/v4.html#list-webhooks + * @see https://developers.kit.com/v4.html#list-webhooks * * @return WP_Error|array */ @@ -1275,7 +1275,7 @@ public function get_webhooks( * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#create-a-webhook + * @see https://developers.kit.com/v4.html#create-a-webhook * * @throws \InvalidArgumentException If the event is not supported. * @@ -1351,7 +1351,7 @@ public function create_webhook(string $url, string $event, string $parameter = ' * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#delete-a-webhook + * @see https://developers.kit.com/v4.html#delete-a-webhook * * @return bool|WP_Error|array */ @@ -1370,7 +1370,7 @@ public function delete_webhook(int $id) * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#list-custom-fields + * @see https://developers.kit.com/v4.html#list-custom-fields * * @return WP_Error|array */ @@ -1400,7 +1400,7 @@ public function get_custom_fields( * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#create-a-custom-field + * @see https://developers.kit.com/v4.html#create-a-custom-field * * @return bool|WP_Error|array */ @@ -1420,7 +1420,7 @@ public function create_custom_field(string $label) * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#bulk-create-custom-fields + * @see https://developers.kit.com/v4.html#bulk-create-custom-fields * * @return bool|WP_Error|array */ @@ -1455,7 +1455,7 @@ public function create_custom_fields(array $labels, string $callback_url = '') * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#update-a-custom-field + * @see https://developers.kit.com/v4.html#update-a-custom-field * * @return bool|WP_Error|array */ @@ -1474,7 +1474,7 @@ public function update_custom_field(int $id, string $label) * * @since 1.0.0 * - * @see https://developers.convertkit.com/#destroy-field + * @see https://developers.kit.com/#destroy-field * * @return bool|WP_Error|array */ @@ -1493,7 +1493,7 @@ public function delete_custom_field(int $id) * * @since 1.0.0 * - * @see https://developers.convertkit.com/v4.html#list-purchases + * @see https://developers.kit.com/v4.html#list-purchases * * @return WP_Error|array */ @@ -1521,7 +1521,7 @@ public function get_purchases( * * @param integer $purchase_id Purchase ID. * - * @see https://developers.convertkit.com/v4.html#get-a-purchase + * @see https://developers.kit.com/v4.html#get-a-purchase * * @return bool|WP_Error|array */ @@ -1546,7 +1546,7 @@ public function get_purchase(int $purchase_id) * @param float $total Total. * @param \DateTime $transaction_time Transaction date and time. * - * @see https://developers.convertkit.com/v4.html#create-a-purchase + * @see https://developers.kit.com/v4.html#create-a-purchase * * @return bool|WP_Error|array */ @@ -1608,7 +1608,7 @@ public function create_purchase( * * @since 2.0.0 * - * @see https://developers.convertkit.com/v4.html#convertkit-api-segments + * @see https://developers.kit.com/v4.html#convertkit-api-segments * * @return WP_Error|array */ diff --git a/src/class-convertkit-api-v4.php b/src/class-convertkit-api-v4.php index 69ec9d1..5b7f841 100644 --- a/src/class-convertkit-api-v4.php +++ b/src/class-convertkit-api-v4.php @@ -81,7 +81,7 @@ class ConvertKit_API_V4 { /** * ConvertKit API endpoints that use the /oauth/ namespace - * i.e. https://api.convertkit.com/oauth/endpoint + * i.e. https://api.kit.com/oauth/endpoint * * @since 2.0.0 * @@ -93,7 +93,7 @@ class ConvertKit_API_V4 { /** * ConvertKit API endpoints that use the /wordpress/ namespace - * i.e. https://api.convertkit.com/wordpress/endpoint + * i.e. https://api.kit.com/wordpress/endpoint * * @since 1.3.0 * @@ -602,7 +602,7 @@ public function sequence_subscribe( $sequence_id, $email, $first_name = '', $cus * * @param string $email_address Email Address. * - * @see https://developers.convertkit.com/v4.html#get-a-subscriber + * @see https://developers.kit.com/v4.html#get-a-subscriber * * @return WP_Error|false|integer */ @@ -631,7 +631,7 @@ public function get_subscriber_id( string $email_address ) { * * @param string $email_address Email Address. * - * @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber + * @see https://developers.kit.com/v4.html#unsubscribe-subscriber * * @return WP_Error|false|object */ @@ -1106,7 +1106,7 @@ public function get_form_html( $id, $api_key = '' ) { 'k' => $api_key, 'v' => 2, ), - 'https://api.convertkit.com/forms/' . $id . '/embed' + 'https://api.kit.com/forms/' . $id . '/embed' ); // Get HTML. @@ -1221,7 +1221,7 @@ public function get_html( $url, $body_only = true ) { $body = wp_remote_retrieve_body( $result ); // If the body appears to be JSON containing an error, the request for a Legacy Form - // through api.convertkit.com failed, so return a WP_Error now. + // through api.kit.com failed, so return a WP_Error now. if ( $this->is_json( $body ) ) { $json = json_decode( $body ); return new WP_Error( @@ -1661,7 +1661,7 @@ private function get_user_agent() { private function get_api_url( $endpoint ) { // For some specific API endpoints created primarily for the WordPress Plugin, the API base is - // https://api.convertkit.com/wordpress/$endpoint. + // https://api.kit.com/wordpress/$endpoint. // We perform a string search instead of in_array(), because the $endpoint might be e.g. // profile/{subscriber_id} or subscriber_authentication/send_code. foreach ( $this->api_endpoints_wordpress as $wordpress_endpoint ) { @@ -1670,14 +1670,14 @@ private function get_api_url( $endpoint ) { } } - // For oAuth API endpoints, the API base is https://api.convertkit.com/oauth/$endpoint. + // For oAuth API endpoints, the API base is https://api.kit.com/oauth/$endpoint. foreach ( $this->api_endpoints_oauth as $oauth_endpoint ) { if ( strpos( $endpoint, $oauth_endpoint ) !== false ) { return path_join( $this->api_url_base . 'oauth', $endpoint ); } } - // For all other endpoints, it's https://api.convertkit.com/v4/$endpoint. + // For all other endpoints, it's https://api.kit.com/v4/$endpoint. return path_join( $this->api_url_base . $this->api_version, $endpoint ); } diff --git a/src/class-convertkit-review-request.php b/src/class-convertkit-review-request.php index eb9a868..8eeed17 100644 --- a/src/class-convertkit-review-request.php +++ b/src/class-convertkit-review-request.php @@ -275,7 +275,7 @@ public function get_review_url() { */ public function get_support_url() { - return 'https://convertkit.com/support'; + return 'https://kit.com/support'; } diff --git a/tests/_support/Helper/WPUnit/API.php b/tests/_support/Helper/WPUnit/API.php index e4cbc53..732d736 100644 --- a/tests/_support/Helper/WPUnit/API.php +++ b/tests/_support/Helper/WPUnit/API.php @@ -32,7 +32,7 @@ public function apiRequest($endpoint, $method = 'GET', $params = array()) $client = new \GuzzleHttp\Client(); $result = $client->request( $method, - 'https://api.convertkit.com/v3/' . $endpoint . '?' . http_build_query($params), + 'https://api.kit.com/v3/' . $endpoint . '?' . http_build_query($params), [ 'headers' => [ 'Accept-Encoding' => 'gzip', diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index f14af87..19ad2ac 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -327,7 +327,7 @@ public function testGetOAuthURL() // Confirm the OAuth URL returned is correct. $this->assertEquals( $this->api->get_oauth_url(), - 'https://app.convertkit.com/oauth/authorize?' . http_build_query( + 'https://app.kit.com/oauth/authorize?' . http_build_query( [ 'client_id' => $_ENV['CONVERTKIT_OAUTH_CLIENT_ID'], 'response_type' => 'code', @@ -352,7 +352,7 @@ public function testGetOAuthURLWithState() // Confirm the OAuth URL returned is correct. $this->assertEquals( $this->api->get_oauth_url( 'https://example.com' ), - 'https://app.convertkit.com/oauth/authorize?' . http_build_query( + 'https://app.kit.com/oauth/authorize?' . http_build_query( [ 'client_id' => $_ENV['CONVERTKIT_OAUTH_CLIENT_ID'], 'response_type' => 'code', @@ -3701,10 +3701,10 @@ public function testCreateSubscribers() { $subscribers = [ [ - 'email_address' => str_replace('@convertkit.com', '-1@convertkit.com', $this->generateEmailAddress()), + 'email_address' => str_replace('@kit.com', '-1@kit.com', $this->generateEmailAddress()), ], [ - 'email_address' => str_replace('@convertkit.com', '-2@convertkit.com', $this->generateEmailAddress()), + 'email_address' => str_replace('@kit.com', '-2@kit.com', $this->generateEmailAddress()), ], ]; $result = $this->api->create_subscribers($subscribers); @@ -4025,7 +4025,7 @@ public function testUnsubscribeByEmail() */ public function testUnsubscribeByEmailWithNotSubscribedEmailAddress() { - $result = $this->api->unsubscribe_by_email('not-subscribed@convertkit.com'); + $result = $this->api->unsubscribe_by_email('not-subscribed@kit.com'); $this->assertInstanceOf(WP_Error::class, $result); } @@ -5551,7 +5551,7 @@ public function testSubscriberAuthenticationSendCodeWithSubscribedEmail() public function testSubscriberAuthenticationSendCodeWithNotSubscribedEmail() { $result = $this->api->subscriber_authentication_send_code( - 'email-not-subscribed@convertkit.com', + 'email-not-subscribed@kit.com', $_ENV['TEST_SITE_WP_URL'] ); $this->assertInstanceOf(WP_Error::class, $result); @@ -6109,7 +6109,7 @@ public function testGetLegacyFormHTML() { $result = $this->api->get_form_html($_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], $_ENV['CONVERTKIT_API_KEY']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('
', $result); + $this->assertStringContainsString('', $result); // Assert that the API class' manually added UTF-8 Content-Type has been removed prior to output. $this->assertStringNotContainsString('', $result); @@ -6140,7 +6140,7 @@ public function testGetLandingPageHTML() { $result = $this->api->get_landing_page_html($_ENV['CONVERTKIT_API_LANDING_PAGE_URL']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('assertStringContainsString('api->get_landing_page_html($_ENV['CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_URL']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('assertStringContainsString('assertStringContainsString('Vantar þinn ungling sjálfstraust í stærðfræði?', $result); @@ -6169,7 +6169,7 @@ public function testGetLegacyLandingPageHTML() { $result = $this->api->get_landing_page_html($_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_URL']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('', $result); + $this->assertStringContainsString('', $result); } /** @@ -6259,11 +6259,11 @@ private function assertPaginationExists($result) * * @since 2.0.0 * - * @param string $domain Domain (default: convertkit.com). + * @param string $domain Domain (default: kit.com). * * @return string */ - private function generateEmailAddress($domain = 'convertkit.com') + private function generateEmailAddress($domain = 'kit.com') { return 'php-sdk-' . date('Y-m-d-H-i-s') . '-php-' . PHP_VERSION_ID . '@' . $domain; } diff --git a/tests/wpunit/ResourceTest.php b/tests/wpunit/ResourceTest.php index fa830e9..8c80488 100644 --- a/tests/wpunit/ResourceTest.php +++ b/tests/wpunit/ResourceTest.php @@ -307,7 +307,7 @@ public function testRefreshForms() // did call both `get_forms` and `get_legacy_forms` methods. $this->assertArrayHasKey($_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], $resources); $this->assertArrayHasKey('embed_url', $resources[ $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] ]); - $this->assertEquals('https://api.convertkit.com/api/v3/forms/' . $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] . '.html?api_key=' . $_ENV['CONVERTKIT_API_KEY'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] ]['embed_url']); + $this->assertEquals('https://api.kit.com/api/v3/forms/' . $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] . '.html?api_key=' . $_ENV['CONVERTKIT_API_KEY'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] ]['embed_url']); // Delete resources. $this->resource->delete(); @@ -361,7 +361,7 @@ public function testRefreshLandingPages() // did call both `get_landing_pages` and `get_legacy_landing_pages` methods. $this->assertArrayHasKey($_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources); $this->assertArrayHasKey('url', $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]); - $this->assertEquals('https://app.convertkit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); + $this->assertEquals('https://app.kit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); // Delete resources. $this->resource->delete(); From ab992b32166dc4df149ca031449dcdbdc7263699 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 22 Jul 2024 11:18:27 +0800 Subject: [PATCH 2/9] Run tests against latest WP version --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 373be62..39442b8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: # Defines the WordPress and PHP Versions matrix to run tests on. strategy: matrix: - wp-versions: [ '6.6-RC3' ] #[ 'latest', '6.1.1' ] + wp-versions: [ 'latest' ] #[ 'latest', '6.1.1' ] php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] #[ '7.4', '8.0', '8.1', '8.2' ] # Steps to install, configure and run tests From 8fa8a8231f995b27c21a0b8104fc61e882afa28d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 22 Jul 2024 15:18:00 +0800 Subject: [PATCH 3/9] Fix failing test --- tests/wpunit/APITest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index 19ad2ac..2a25075 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -6109,7 +6109,7 @@ public function testGetLegacyFormHTML() { $result = $this->api->get_form_html($_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], $_ENV['CONVERTKIT_API_KEY']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('', $result); + $this->assertStringContainsString('', $result); // Assert that the API class' manually added UTF-8 Content-Type has been removed prior to output. $this->assertStringNotContainsString('', $result); From 85b8560a34bda1c499a349288b59f2a00dc018e4 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 22 Jul 2024 15:25:44 +0800 Subject: [PATCH 4/9] Fix failing test --- tests/wpunit/APITest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index 2a25075..da37006 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -6140,7 +6140,7 @@ public function testGetLandingPageHTML() { $result = $this->api->get_landing_page_html($_ENV['CONVERTKIT_API_LANDING_PAGE_URL']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('assertStringContainsString('api->get_landing_page_html($_ENV['CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_URL']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('assertStringContainsString('assertStringContainsString('Vantar þinn ungling sjálfstraust í stærðfræði?', $result); From cfffe67f66bbd99834579aa82fdb512bfa65ac7c Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 22 Jul 2024 15:32:37 +0800 Subject: [PATCH 5/9] Fix failing test --- tests/wpunit/ResourceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wpunit/ResourceTest.php b/tests/wpunit/ResourceTest.php index 8c80488..d46c6b6 100644 --- a/tests/wpunit/ResourceTest.php +++ b/tests/wpunit/ResourceTest.php @@ -361,7 +361,7 @@ public function testRefreshLandingPages() // did call both `get_landing_pages` and `get_legacy_landing_pages` methods. $this->assertArrayHasKey($_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources); $this->assertArrayHasKey('url', $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]); - $this->assertEquals('https://app.kit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); + $this->assertEquals('https://app.convertkit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); // Delete resources. $this->resource->delete(); From ccd9ba7acfb8ce06c573e6141d987dfe3357f09b Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 18 Sep 2024 11:22:03 +0800 Subject: [PATCH 6/9] Use kit.com domain --- tests/wpunit/APITest.php | 4 ++-- tests/wpunit/ResourceTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index 8bdf3c3..e2e92e0 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -6279,7 +6279,7 @@ function( $response ) use ( $httpCode, $httpMessage, $body ) { // phpcs:ignore G public function mockAccessTokenExpiredResponse( $response, $parsed_args, $url ) { // Only mock requests made to the /account endpoint. - if ( strpos( $url, 'https://api.convertkit.com/v4/account' ) === false ) { + if ( strpos( $url, 'https://api.kit.com/v4/account' ) === false ) { return $response; } @@ -6319,7 +6319,7 @@ public function mockAccessTokenExpiredResponse( $response, $parsed_args, $url ) public function mockRefreshTokenResponse( $response, $parsed_args, $url ) { // Only mock requests made to the /token endpoint. - if ( strpos( $url, 'https://api.convertkit.com/oauth/token' ) === false ) { + if ( strpos( $url, 'https://api.kit.com/oauth/token' ) === false ) { return $response; } diff --git a/tests/wpunit/ResourceTest.php b/tests/wpunit/ResourceTest.php index d46c6b6..8c80488 100644 --- a/tests/wpunit/ResourceTest.php +++ b/tests/wpunit/ResourceTest.php @@ -361,7 +361,7 @@ public function testRefreshLandingPages() // did call both `get_landing_pages` and `get_legacy_landing_pages` methods. $this->assertArrayHasKey($_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources); $this->assertArrayHasKey('url', $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]); - $this->assertEquals('https://app.convertkit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); + $this->assertEquals('https://app.kit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); // Delete resources. $this->resource->delete(); From 56c637bfa68f4ed8f09635243e3b82f7b88ac234 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 18 Sep 2024 11:35:48 +0800 Subject: [PATCH 7/9] Fix failing test --- tests/wpunit/APITest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index e2e92e0..2b011ba 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -6149,7 +6149,7 @@ public function testGetLegacyFormHTML() { $result = $this->api->get_form_html($_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], $_ENV['CONVERTKIT_API_KEY']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('', $result); + $this->assertStringContainsString('', $result); // Assert that the API class' manually added UTF-8 Content-Type has been removed prior to output. $this->assertStringNotContainsString('', $result); From 72fc76762f7ae3dca6fb1b489dfd8e76b9441426 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 18 Sep 2024 11:42:08 +0800 Subject: [PATCH 8/9] Fix failing tests --- tests/wpunit/APITest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index 2b011ba..3d31cfb 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -6180,7 +6180,7 @@ public function testGetLandingPageHTML() { $result = $this->api->get_landing_page_html($_ENV['CONVERTKIT_API_LANDING_PAGE_URL']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('assertStringContainsString('assertStringNotContainsString('rocket-loader.min.js', $result); @@ -6196,7 +6196,7 @@ public function testGetLandingPageWithCharacterEncodingHTML() { $result = $this->api->get_landing_page_html($_ENV['CONVERTKIT_API_LANDING_PAGE_CHARACTER_ENCODING_URL']); $this->assertNotInstanceOf(WP_Error::class, $result); - $this->assertStringContainsString('assertStringContainsString('assertStringContainsString('Vantar þinn ungling sjálfstraust í stærðfræði?', $result); From 556ab6c932ee58e02a5a56a42be3d5fab4262cc3 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 18 Sep 2024 11:50:00 +0800 Subject: [PATCH 9/9] Fix failing tests --- tests/wpunit/ResourceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wpunit/ResourceTest.php b/tests/wpunit/ResourceTest.php index 8c80488..d46c6b6 100644 --- a/tests/wpunit/ResourceTest.php +++ b/tests/wpunit/ResourceTest.php @@ -361,7 +361,7 @@ public function testRefreshLandingPages() // did call both `get_landing_pages` and `get_legacy_landing_pages` methods. $this->assertArrayHasKey($_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources); $this->assertArrayHasKey('url', $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]); - $this->assertEquals('https://app.kit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); + $this->assertEquals('https://app.convertkit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']); // Delete resources. $this->resource->delete();