-
Notifications
You must be signed in to change notification settings - Fork 14
[WIP] Feature/add netlify #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,7 @@ | |||
<component name="ProjectRunConfigurationManager"> | |||
<configuration default="false" name="main_netlify.dart" type="FlutterRunConfigurationType" factoryName="Flutter" nameIsGenerated="true"> | |||
<option name="additionalArgs" value="--dart-define="CLIENT_KEY=test_O3LEH54C3JDPREE3QOEPOCRG4QGEICBQ" --dart-define="APPLE_PAY_MERCHANT_ID_KEY=demo"" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client key is already public on the MyStoreDemo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @Robert-SD, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a new Netlify environment setup alongside the existing example setup. It involves refactoring the main entry point to allow for different service implementations, creating separate entry points for each environment, and implementing a new service for Netlify. The changes also include updating project configurations and removing unnecessary fields from the session request body.
Highlights
- Project Configuration: Added a new run configuration for
main_netlify.dart
and updated the existingmain_example.dart
configuration to reflect the file rename. - Entry Point Refactor: Refactored the
main
function inmain_common.dart
tomainCommon
to allow different entry points for different environments (example and netlify). - New Entry Points: Created new entry point files
main_example.dart
andmain_netlify.dart
to use different service implementations. - Service Implementations: Introduced
CheckoutService
andNetlifyService
to handle API calls for different environments. - Service Interface: Refactored
Service
from a class to an abstract interface to allow for different implementations. - Session Request Body: Removed unnecessary fields from the session request body in
AdyenDropInRepository
. - Widget Test: Updated widget test to import
main_common.dart
instead ofmain.dart
.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
LCOV of commit
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for a Netlify-based backend by refactoring the Service
layer into an interface and providing two implementations (CheckoutService
for the existing logic and NetlifyService
for the new backend). It also updates main entry points and run configurations accordingly.
Key feedback points include a critical security issue with hardcoded API keys in a new run configuration, the need to implement several core methods in NetlifyService
, considerations for a hardcoded base URL in NetlifyService
, and a request for clarification on significant changes to the session request body. A minor point involves suggesting the use of a proper logger instead of print
statements for better practice, even in an example application.
// TODO: implement deleteStoredPaymentMethod | ||
throw UnimplementedError(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method deleteStoredPaymentMethod
(and several other methods in this NetlifyService
class such as fetchPaymentMethods
, postPayments
, etc.) are currently stubbed out with // TODO: implement ...
and throw an UnimplementedError
.
While this is acceptable for work-in-progress, these methods represent core functionalities of the Service
interface. For the NetlifyService
to be fully functional and usable as an alternative backend, these methods will need to be implemented. Please ensure there's a plan or tracking issues to address these unimplemented parts.
final baseUrl = "https://www.mystoredemo.io"; | ||
|
||
@override | ||
Future<Map<String, dynamic>> createSession(Map<String, dynamic> body) async { | ||
final http.Response response = await http.post( | ||
Uri.parse('$baseUrl/.netlify/functions/sessions'), | ||
body: jsonEncode(body), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The baseUrl
is currently hardcoded. If this URL might change (e.g., for different deployment environments like development, staging, or production, or if the service endpoint itself changes), it would be more maintainable and flexible to make this configurable.
Consider moving it to a central configuration file (like config.dart
, similar to Config.baseUrl
) or sourcing it from environment variables. The suggestion below makes it a static const
for now, which is slightly better if it's truly fixed for this service, but external configuration is generally preferred for URLs.
// Consider moving this to a central configuration if it can vary by environment.
// For now, making it a private static const if it's fixed for this service.
static const String _baseUrl = "https://www.mystoredemo.io";
@override
Future<Map<String, dynamic>> createSession(Map<String, dynamic> body) async {
final http.Response response = await http.post(
Uri.parse('$_baseUrl/.netlify/functions/sessions'), // Use the static const
body: jsonEncode(body),
);
LCOV of commit
|
LCOV of commit
|
2dd02c3
to
06600b1
Compare
LCOV of commit
|
LCOV of commit
|
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the example app to support multiple backend services by introducing a Service
interface, with implementations for the existing backend and a new Netlify-based one. It also adds the ability to configure the app via launch arguments, which is a great improvement for testing and flexibility. The changes are well-structured, but I've identified a few issues that need attention. A test API key is hardcoded in a run configuration, which is a security concern. There are also some leftover debug print
statements that should be removed. Finally, as this is a work-in-progress, several methods in the new NetlifyService
are unimplemented and will need to be completed.
@@ -0,0 +1,7 @@ | |||
<component name="ProjectRunConfigurationManager"> | |||
<configuration default="false" name="main_netlify.dart" type="FlutterRunConfigurationType" factoryName="Flutter" nameIsGenerated="true"> | |||
<option name="additionalArgs" value="--dart-define="CLIENT_KEY=test_O3LEH54C3JDPREE3QOEPOCRG4QGEICBQ" --dart-define="APPLE_PAY_MERCHANT_ID_KEY=demo"" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Committing secrets to the repository, even if they are test keys, is a security risk. The hardcoded CLIENT_KEY
should be removed from this run configuration. Please consider using a method that doesn't involve checking keys into version control, such as environment variables or a local configuration file that is ignored by git.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intended. It is our public client key from mystoredemo.io.
Future.microtask(() async { | ||
final String config = | ||
await FlutterLaunchArguments().getString("config") ?? | ||
"FAILED TO FETCH CONFIG"; | ||
print("**** CONFIG FETCHED ****"); | ||
print(config); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers: _createHeaders(), | ||
body: jsonEncode(body), | ||
); | ||
print("PspReference: ${response.headers["pspreference"]}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future<bool> deleteStoredPaymentMethod( | ||
String storedPaymentMethodId, Map<String, dynamic> queryParameters) { | ||
// TODO: implement deleteStoredPaymentMethod | ||
throw UnimplementedError(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.