Adds missing fields to subscribers #780
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
The current
Subscriber
type is missing several fields that are returned by the WordPress.com API, causing incomplete data representation and potential parsing failures. This PR ensures we can properly handle all subscriber data fields.What Changed
New Fields Added to
Subscriber
subscription_id
- Unique identifier for the subscriptionis_email_subscriber
- Boolean flag for email-only subscribersurl
- Subscriber's website URLcountry
- Subscriber's country informationplans
- List of subscription plansNew Types
SubscriberCountry
- Represents country data with code and nameSubscriptionPlan
- Contains plan details including ID and nameBug Fixes
EmailAddress
&DisplayName
inListSubscribersSortField
/sites/<wp_com_site_id>/subscribers/individual
endpoint to properly returnSubscriber
typeType Safety Improvements
Subscriber
fields optional to match API responsesGetSubscriberQuery
to use strongly-typedUserId
&SubscriptionId
Testing
We don't have an infrastructure to run integration tests for WordPress.com endpoints. This makes it very difficult to ensure that the implementation is correct and introduces a lot of manual testing overhead during development. To improve this situation, this PR introduces a basic setup that allows a developer to copy the
wp_com_test_credentials.json-example
aswp_com_test_credentials.json
to run relevant tests.The PR introduces a few tests for subscribers endpoint, however they all have the
#[ignore]
flag and won't be run by default. If a developer has the correct credentials & ids inwp_com_test_credentials.json
, they can run the tests with:I have considered adding instructions for this in the
README
, but I'd like this to be a temporary solution and I have some concerns about having WordPress.com specific instructions, so at least for this PR, I decided to skip this step.Additional Test Changes
Breaking Changes
Subscriber
fields are nowOption<T>
- existing code may need updatesGetSubscriberQuery
now uses typed IDs instead of raw strings