Skip to content

Add unified support conversations endpoints#1288

Draft
jkmassel wants to merge 2 commits into
trunkfrom
jkmassel/unified-support
Draft

Add unified support conversations endpoints#1288
jkmassel wants to merge 2 commits into
trunkfrom
jkmassel/unified-support

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

Description

Wires /wpcom/v2/mobile-support/unified-conversations into WpComApiClient. This is the newer unified support endpoint that supersedes /mobile-support/conversations; the response shape is different enough that reusing the existing SupportConversation types isn't a good fit.

Changes

  • New module wp_com::unified_conversations with response/param types:
    • UnifiedConversationSummary (list item — adds can_accept_reply: bool vs. the older summary)
    • UnifiedConversation + UnifiedMessage (flat message / author_role / author_name shape — not the older nested SupportMessageAuthor enum)
    • UnifiedAttachment with metadata: HashMap<String, JsonValue> — reference-link attachments carry a float score, and the existing AttachmentMetadataValue is Eq-bound so can't hold f64. Reusing the crate-wide JsonValue avoided either breaking Eq on the existing type or inventing a parallel value enum.
    • ReplyToUnifiedConversationParams { message: String } — JSON body, no attachments (the current API doesn't accept them on reply)
    • Reuses ConversationId from support_tickets (the IDs are in the same namespace)
  • New UnifiedConversationsRequest endpoint enum under WpComNamespace::V2:
    • GET /mobile-support/unified-conversations
    • GET /mobile-support/unified-conversations/<conversation_id>
    • POST /mobile-support/unified-conversations/<conversation_id>
  • Wired through wp_com/mod.rs, wp_com/endpoint.rs, and wp_com/client.rs (builder + executor + api_client_generate_endpoint_impl!)

Test plan

  • cargo build -p wp_api
  • cargo test --lib -p wp_api unified_conversations — 6 tests pass
    • List fixture deserializes to 70 items; can_accept_reply / status spot-checked
    • Single-conversation fixture deserializes with 10 messages; bot-response attachments verified to contain a JsonValue::Float score
    • Reply-response fixture (same shape as single GET) deserializes
    • Endpoint URL tests for list / get one / reply
  • cargo fmt --all -- --check
  • cargo clippy -p wp_api --tests --all-features -- -D warnings
  • End-to-end hit against public-api.wordpress.com from the example app (follow-up)

Wires `/wpcom/v2/mobile-support/unified-conversations` into `WpComApiClient`:
list, get one, and reply. Message/attachment shape differs from the older
`/mobile-support/conversations` endpoints, and reference-link attachments
carry a float `score` in metadata — using `JsonValue` for metadata values
rather than extending the Eq-bound `AttachmentMetadataValue`.
- Swift: expose `unifiedConversations` on `WPComApiClient`; add a
  read-only "Unified Conversations" row to the WPCom root list
  showing title, status, and created date.
- Kotlin: add a list screen (tappable) and a detail screen showing
  messages, author role/name, and attachment count. Wired through
  `WpComSiteScreen` and `App.kt` navigation. Conversation ID passed
  through remembered state to match the existing pattern for
  post type / taxonomy navigation.
@wpmobilebot
Copy link
Copy Markdown
Collaborator

XCFramework Build

This PR's XCFramework is available for testing. Add to your Package.swift:

.package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1288")

Built from bc3f97d

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.

2 participants