Skip to content

Add stats emails summary endpoint#1200

Draft
adalpari wants to merge 4 commits intotrunkfrom
feature/CMM-1288-create-endpoints-for-Subscribers-tab
Draft

Add stats emails summary endpoint#1200
adalpari wants to merge 4 commits intotrunkfrom
feature/CMM-1288-create-endpoints-for-Subscribers-tab

Conversation

@adalpari
Copy link
Contributor

@adalpari adalpari commented Feb 26, 2026

Description

Add three new WP.com API endpoints to support the Subscribers tab feature:

  1. Stats emails summary/rest/v1.1/sites/{site_id}/stats/emails/summary
  2. Stats subscribers/rest/v1.1/sites/{site_id}/stats/subscribers
  3. Subscribers by user type/wpcom/v2/sites/{site_id}/subscribers_by_user_type

Changes

Stats emails summary

  • Add StatsEmailsSummaryParams with period, quantity, sort_field, and sort_order parameters
  • Add StatsEmailsSummaryResponse and StatsEmailsSummaryPost response types
  • Add endpoint definition using WpDerivedRequest macro with WpComNamespace::RestV1_1
  • Wire up the endpoint in WpComApiRequestBuilder and WpComApiClient
  • Add 10 unit tests and 3 JSON test fixtures
  • Add e2e integration test

Stats subscribers

  • Add StatsSubscribersParams with unit, quantity, and stat_fields (comma-joined) parameters
  • Add StatsSubscribersResponse reusing StatsVisitsDataValue for the fields+data array pattern
  • Add helper methods subscribers_data() and subscribers_paid_data() with #[uniffi::export]
  • Add endpoint definition with WpComNamespace::RestV1_1
  • Wire up the endpoint in WpComApiRequestBuilder and WpComApiClient
  • Add 13 unit tests and 5 JSON test fixtures (day/week/month/year/empty)
  • Add e2e integration test

Subscribers by user type

  • Add SubscribersByUserTypeParams with user_type, per_page, page, and sort parameters
  • Add SubscribersByUserTypeUserType and SubscribersByUserTypeSortField enums
  • Reuse existing ListSubscribersResponse type
  • Add ListSubscribersByUserType variant to SubscribersRequest with WpComNamespace::V2
  • Add 4 unit tests and 2 JSON test fixtures

Test plan

  • cargo build succeeds
  • cargo test --lib -p wp_api — all new unit tests pass
  • cargo fmt clean
  • Run e2e tests with WP.com credentials

🤖 Generated with Claude Code

adalpari and others added 4 commits February 26, 2026 13:54
Implements the /rest/v1.1/sites/{site_id}/stats/emails/summary endpoint
with params (period, quantity, sort_field, sort_order), response types,
unit tests, JSON fixtures, and e2e integration tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements the /rest/v1.1/sites/{site_id}/stats/subscribers endpoint
with params (unit, quantity, date, stat_fields), response types with
helper methods for extracting subscribers and paid subscribers data,
unit tests, JSON fixtures for day/week/month/year/empty responses,
and e2e integration tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds the /wpcom/v2/sites/{site_id}/subscribers_by_user_type endpoint
to the existing subscribers module. Includes params (per_page, page,
user_type, sort), reuses the existing ListSubscribersResponse type,
unit tests, and JSON test fixtures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The API can return invalid dates like "-001-11-30T00:00:00+00:00" for
some subscribers. Change date_subscribed to Option<WpGmtDateTime> with
a lenient deserializer that returns None for unparseable dates instead
of failing the entire response.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant