Skip to content

Migrate device endpoints to generated models#6547

Draft
gpunto wants to merge 1 commit into
developfrom
migrate/devices
Draft

Migrate device endpoints to generated models#6547
gpunto wants to merge 1 commit into
developfrom
migrate/devices

Conversation

@gpunto

@gpunto gpunto commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Goal

Migrate the /devices endpoints to generated models. Part of the incremental OpenAPI model migration.

Built on top of the Serializer foundation PR (this is the first slice with a generated enum, PushProvider).

Part of AND-1291

Implementation

  • Add generated DeviceResponse, ListDevicesResponse, and CreateDeviceRequest (with the typed PushProvider sealed enum); delete the hand-written DeviceDto, DevicesResponse, and AddDeviceRequest.
  • Register CreateDeviceRequest.PushProvider.PushProviderAdapter() in Serializer (the one-line-per-enum pattern the foundation enables).
  • Point DeviceApi/MoshiChatApi/mappers at the generated types (real names, no aliases); Device.toDto() supplies placeholder createdAt/userId (required by the generated model, ignored by the server on upstream payloads).

Testing

  • Project-wide spotlessApply, apiDump (no API drift), lint, detekt, and testDebugUnitTest all pass.
  • Verified on device: addDevice (generated request + PushProvider enum) succeeds, getDevices parses 22 real DeviceResponses (roundTrip=true), deleteDevice succeeds.

Summary by CodeRabbit

  • New Features

    • Updated device registration and retrieval to support the latest push device format, including additional device details.
    • Improved handling of multiple push provider types for broader notification support.
  • Bug Fixes

    • Fixed device data parsing so device lists and device details load more reliably.
    • Aligned device response handling with the current API, reducing issues with missing or malformed device information.

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

github-actions Bot commented Jul 6, 2026

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.

@gpunto gpunto force-pushed the migrate/devices branch from 6202136 to b8ab16b Compare July 6, 2026 11:26
@gpunto gpunto changed the title Migrate device endpoints to generated models and route Moshi through Serializer Migrate device endpoints to generated models Jul 6, 2026
@gpunto gpunto changed the base branch from develop to migrate/serializer-foundation July 6, 2026 11:26
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.93 MB 5.94 MB 0.01 MB 🟢
stream-chat-android-ui-components 11.20 MB 11.20 MB 0.00 MB 🟢
stream-chat-android-compose 12.66 MB 12.67 MB 0.01 MB 🟢

@gpunto gpunto force-pushed the migrate/serializer-foundation branch from 464cbfc to a91a64c Compare July 6, 2026 13:29
@gpunto gpunto force-pushed the migrate/devices branch from b8ab16b to afdf37f Compare July 6, 2026 13:30
@gpunto gpunto force-pushed the migrate/serializer-foundation branch from 9048f69 to 32c54f4 Compare July 6, 2026 13:50
@gpunto gpunto force-pushed the migrate/devices branch 2 times, most recently from 932db00 to dc1ead9 Compare July 7, 2026 10:21
Base automatically changed from migrate/serializer-foundation to develop July 7, 2026 12:57
@gpunto gpunto force-pushed the migrate/devices branch from dc1ead9 to 9a33bb3 Compare July 7, 2026 13:23
@gpunto gpunto force-pushed the migrate/devices branch from 9a33bb3 to 3167c2d Compare July 7, 2026 13:28
@gpunto

gpunto commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 7, 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

Run ID: 5652b8af-9608-4790-913c-efabe59669c9

📥 Commits

Reviewing files that changed from the base of the PR and between 7eb3570 and 3167c2d.

📒 Files selected for processing (16)
  • 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/DeviceApi.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/api2/model/requests/AddDeviceRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/infrastructure/Serializer.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/CreateDeviceRequest.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/DeviceResponse.kt
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/network/models/ListDevicesResponse.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/api2/mapping/DomainMappingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/DeviceParsingTest.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/DeviceTestData.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/UserDtoTestData.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/parser2/testdata/UserTestData.kt
💤 Files with no reviewable changes (1)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/requests/AddDeviceRequest.kt

Walkthrough

Device-add and device-list network models are migrated from AddDeviceRequest/DevicesResponse to new CreateDeviceRequest/ListDevicesResponse/DeviceResponse types, with a Moshi PushProvider adapter, updated domain mapping, endpoint signatures, and corresponding test helpers/fixtures updated across the client module.

Changes

Device Model Migration

Layer / File(s) Summary
New device network models
.../network/models/CreateDeviceRequest.kt, .../network/models/DeviceResponse.kt, .../network/models/ListDevicesResponse.kt, .../network/infrastructure/Serializer.kt
Adds CreateDeviceRequest with a PushProvider sealed class and Moshi adapter, adds DeviceResponse, updates ListDevicesResponse to include duration and List<DeviceResponse>, and registers the PushProvider adapter in the Moshi builder.
Domain mapping and API wiring
.../mapping/DomainMapping.kt, .../endpoint/DeviceApi.kt, .../MoshiChatApi.kt
Adds DeviceResponse.toDomain() mapper, updates DeviceApi signatures to use ListDevicesResponse/CreateDeviceRequest, and updates MoshiChatApi.addDevice to build a CreateDeviceRequest.
Tests and fixtures
.../client/Mother.kt, .../api2/MoshiChatApiTest*.kt, .../mapping/DomainMappingTest.kt, .../parser2/DeviceParsingTest.kt, .../parser2/testdata/*.kt
Adds randomDeviceResponse test helper and updates test assertions, arguments, and JSON fixtures (adding created_at/user_id) to match the new device model types.

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

Sequence Diagram(s)

sequenceDiagram
  participant MoshiChatApi
  participant DeviceApi
  participant Serializer

  MoshiChatApi->>DeviceApi: addDevices(CreateDeviceRequest)
  DeviceApi->>Serializer: serialize PushProvider field
  Serializer-->>DeviceApi: JSON payload
  DeviceApi-->>MoshiChatApi: RetrofitCall<Unit> response

  MoshiChatApi->>DeviceApi: getDevices()
  DeviceApi-->>MoshiChatApi: RetrofitCall<ListDevicesResponse>
  MoshiChatApi->>MoshiChatApi: map DeviceResponse to Device (toDomain)
Loading

Suggested labels: pr:new-feature

Suggested reviewers: andremion

Poem

A rabbit hops through JSON fields anew,
AddDevice retires, CreateDevice steps into view.
With push providers wrapped in tidy sealed delight,
And DeviceResponse shining, parsed just right.
🐇✨ Hop, map, and test — the burrow's snug and tight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: moving device endpoints to generated models.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/devices

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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.

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
55.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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