Add getDefaultOffer to PlatformClient#187
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new PlatformClient API for fetching a user’s default access offer, along with a package version bump and changelog update.
Changes:
- Add
PlatformClient.getDefaultOffer()that calls/api/user/{userId}/access/default. - Modify
_parseResponsefallback behavior for non-“classic” response bodies. - Bump package version to
3.5.0and update changelog / example lockfile accordingly.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pubspec.yaml | Bumps SDK version to 3.5.0. |
| lib/src/platform_client.dart | Adds getDefaultOffer; changes HTTP response parsing fallback behavior. |
| example/pubspec.lock | Aligns example lockfile version with 3.5.0. |
| CHANGELOG.md | Adds 3.5.0 entry documenting getDefaultOffer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else if (json['response']?['errorMessage'] != null) { | ||
| throw PlatformLocalizedException( | ||
| json['response']?['errorCode'], | ||
| json['response']['errorMessage'], | ||
| ); | ||
| } else { | ||
| throw PlatformUnknownException( | ||
| 'Platform returned unexpected body: $body', | ||
| ); | ||
| return json; | ||
| } |
There was a problem hiding this comment.
_parseResponse now returns the decoded JSON in the fallback branch instead of throwing. Because _httpSend doesn’t otherwise check HTTP status codes, this can silently treat non-2xx failures or malformed/unexpected responses as “success”, leading to downstream null errors and making debugging harder. Consider restoring the PlatformUnknownException (including statusCode/body), or only allowing the fallback return for 2xx responses while throwing for non-2xx / invalid bodies.
| Future<AccessOfferDetails> getDefaultOffer() async { | ||
| _verifyIsLoggedIn(); | ||
|
|
||
| Map<String, dynamic> response = | ||
| await _httpGet('/api/user/$_userId/access/default'); | ||
| return AccessOfferDetails.fromJson(response); | ||
| } |
There was a problem hiding this comment.
The new getDefaultOffer API and the relaxed _parseResponse behavior introduce new/changed response-handling paths, but there are existing PlatformClient tests (e.g., loginWithToken) and none cover these scenarios. Adding unit tests for getDefaultOffer’s request path/headers and for how unexpected (non-"classic") responses are handled would help prevent regressions.
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [3.5.0] - 2026-03-4 |
There was a problem hiding this comment.
Changelog entry date format is inconsistent with the rest of the file (YYYY-MM-DD). "2026-03-4" should be "2026-03-04" to match the other release headings.
| ## [3.5.0] - 2026-03-4 | |
| ## [3.5.0] - 2026-03-04 |
No description provided.