Skip to content

Migrate poll option responses to the generated PollOptionResponse model - #6627

Open
gpunto wants to merge 1 commit into
developfrom
migrate/poll-options
Open

Migrate poll option responses to the generated PollOptionResponse model#6627
gpunto wants to merge 1 commit into
developfrom
migrate/poll-options

Conversation

@gpunto

@gpunto gpunto commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the poll option responses from the hand-written PollOptionResponse to the generated network models.

Part of AND-1291

Implementation

  • Add generated PollOptionResponse and PollOptionResponseData; remove the hand-written PollOptionResponse.
  • Add PollOptionResponseDataAdapter so the custom data the v1 endpoints flatten to the root is collected into custom.
  • Retype the option endpoints in PollsApi and map PollOptionResponseData to the domain Option in DomainMapping.

Testing

  • PollOptionResponseParsingTest covers the option and its collected custom fields. Removing the adapter registration makes the custom assertions fail.
  • Device-probed the option endpoints on the wire, with custom data round-tripping through create and update (sentiment).

Summary by CodeRabbit

  • Bug Fixes

    • Improved poll option response handling, including duration, identifiers, text, and custom fields.
    • Ensured poll options are correctly converted into the app’s domain model.
    • Added support for responses with or without custom fields.
  • Tests

    • Added coverage for poll option parsing and custom-field handling.

@gpunto gpunto added the pr:internal Internal changes / housekeeping label Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.96 MB 5.96 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.26 MB 11.26 MB 0.00 MB 🟢
stream-chat-android-compose 12.74 MB 12.74 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

@gpunto
gpunto marked this pull request as ready for review August 10, 2026 13:09
@gpunto
gpunto requested a review from a team as a code owner August 10, 2026 13:09
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5865166d-54b2-4174-93c7-c31d5ba6dd2d

📥 Commits

Reviewing files that changed from the base of the PR and between 3e0160e and 9864d6b.

📒 Files selected for processing (11)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/MoshiChatApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/endpoint/PollsApi.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/DomainMapping.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/MoshiChatParser.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/adapters/PollOptionResponseDataAdapter.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollOptionResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/PollOptionResponseData.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/Mother.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/api2/MoshiChatApiTestArguments.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/PollOptionResponseParsingTest.kt

Walkthrough

Poll option API responses now use network-layer Moshi models. A custom adapter extracts root-level metadata, and domain mapping converts the parsed data into PollOption.

Changes

Poll option response handling

Layer / File(s) Summary
Response models and Moshi contract
stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/*
PollOptionResponse now uses explicit JSON mappings and PollOptionResponseData for poll option data.
Custom response parsing
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/parser2/*
Moshi registers an adapter that collects root-level custom fields during deserialization.
API and domain integration
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/*
Create and update operations read pollOption and map it with toDomain().
Test coverage and fixtures
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/*
Tests cover response fields, custom metadata, absent custom metadata, and updated API fixtures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: velikovpetar, andremion

Poem

I hop through models, neat and bright,
Custom fields now parse just right.
Poll options map from wire to hay,
Tests guard each field along the way.
— A cheerful rabbit 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the migration of poll option responses to the generated model.
Description check ✅ Passed The description covers the goal, implementation, related issue, testing, and wire verification; omitted UI sections are not relevant.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/poll-options

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gpunto
gpunto enabled auto-merge August 10, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:internal Internal changes / housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant