Skip to content

2.6.0: Update Traits from PHP SDK - #127

Open
n7studios wants to merge 15 commits into
mainfrom
update-traits-from-sdk
Open

2.6.0: Update Traits from PHP SDK#127
n7studios wants to merge 15 commits into
mainfrom
update-traits-from-sdk

Conversation

@n7studios

@n7studios n7studios commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Restructures the Kit WordPress Libraries as a WordPress mirror of the PHP SDK. API surface, tests, and version numbers now track the SDK; only genuinely WordPress-specific methods and tests stay unique to this repo.

Based on ConvertKitSDK-PHP #155:

  1. Backports SDK 2.6.0 API methods to ConvertKit_API_Traits, adjusted for PHP 7.x (nullable shorthand, positional args, etc.).
  2. Adopts the SDK's TestsTrait verbatim. APITest.php now uses the trait and provides two shims (assertApiError, assertLastResponseStatusCode) that translate SDK-style thrown exceptions into WP_Error assertions. WP-only tests remain in APITest.php / ResourceTest.php / APINoDataTest.php.
  3. Bumps version to 2.6.0 to match the SDK release.

Future SDK updates port over in two steps: copy the changed API methods into ConvertKit_API_Traits (with PHP 7.x tweaks), then copy the SDK's TestsTrait.php into this repo.

Testing

Existing tests pass. This is a large PR which is difficult to review, so I've added comments to cover the main items, and tests are also performed on each Kit WordPress Plugin against this branch to confirm no breaking changes:

Checklist

@n7studios n7studios added this to the 2.6.0 milestone Aug 11, 2026
@n7studios n7studios self-assigned this Aug 11, 2026
@n7studios n7studios added the enhancement New feature or request label Aug 11, 2026
@n7studios
n7studios requested review from a team, ciccio-kit and noelherrick and removed request for a team August 12, 2026 14:29
*
* @return int HTTP status code of the last API response (0 if none).
*/
public function get_last_response_code() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mirrors how the PHP SDK works, when a developer wants to fetch the last response code for a request.

}

// Treat any 4xx or 5xx status as an error.
if ( $http_response_code >= 400 ) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mirrors the PHP SDK, where a 4xx or 5xx status code returns an error

// Build array of arguments depending on the resource type.
switch ( $resource_type ) {
case 'forms':
$args = array(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These arguments are modified to work with the new API Traits, which come from the PHP SDK Traits, which provide more parameters.

namespace Helper\WPUnit;

/**
* Wraps `ConvertKit_API_V4` and converts every array response to a nested `stdClass`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's always been a difference between the WordPress Libraries and PHP SDK:

  • WordPress Libraries return an array of data on success
  • PHP SDK returns a nested stdClass object on success

Rather than rewrite all of the tests in TestsTrait, this proxy converts array responses to stdClass objects so they can be run through the TestsTrait.

@n7studios
n7studios marked this pull request as ready for review August 13, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant