Skip to content

Add getDefaultOffer to PlatformClient#187

Merged
kasemj merged 1 commit into
mainfrom
default-offer
Mar 5, 2026
Merged

Add getDefaultOffer to PlatformClient#187
kasemj merged 1 commit into
mainfrom
default-offer

Conversation

@kasemj

@kasemj kasemj commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@kasemj kasemj requested a review from Copilot March 5, 2026 01:35
@kasemj kasemj merged commit 3a44fd5 into main Mar 5, 2026
3 checks passed
@kasemj kasemj deleted the default-offer branch March 5, 2026 01:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _parseResponse fallback behavior for non-“classic” response bodies.
  • Bump package version to 3.5.0 and 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.

Comment on lines 1594 to 1601
} else if (json['response']?['errorMessage'] != null) {
throw PlatformLocalizedException(
json['response']?['errorCode'],
json['response']['errorMessage'],
);
} else {
throw PlatformUnknownException(
'Platform returned unexpected body: $body',
);
return json;
}

Copilot AI Mar 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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.

Copilot uses AI. Check for mistakes.
Comment on lines +785 to +791
Future<AccessOfferDetails> getDefaultOffer() async {
_verifyIsLoggedIn();

Map<String, dynamic> response =
await _httpGet('/api/user/$_userId/access/default');
return AccessOfferDetails.fromJson(response);
}

Copilot AI Mar 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread CHANGELOG.md
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

Copilot AI Mar 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
## [3.5.0] - 2026-03-4
## [3.5.0] - 2026-03-04

Copilot uses AI. Check for mistakes.
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