-
Notifications
You must be signed in to change notification settings - Fork 0
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
Change API for setting the request environment #11
base: main
Are you sure you want to change the base?
Conversation
44b5e35
to
aad2853
Compare
Clarify some the test descriptions, and add a test case for a missed edge case, when the test mode setting is not explicitly set.
aad2853
to
c855590
Compare
:test_mode
configurationc855590
to
6d9510c
Compare
This is done for a generally safer library that requires explicit configuration to access the production environment.
6d9510c
to
2c8bb51
Compare
This is an override argument, which will allow overriding the static environment configuration.
2c8bb51
to
17540bb
Compare
ENVIRONMENTS = { | ||
sandbox: :sandbox, | ||
production: :production, | ||
}.freeze |
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.
There are only two available environments, which correspond with two different URL's.
def self.test_mode=(test_mode) | ||
configuration.test_mode = test_mode | ||
def self.environment=(environment) | ||
configuration.environment = environment |
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.
Changing the configuration setter from .test_mode=
to .environment=
.
url = Payrix.configuration.url | ||
url = Payrix.configuration.url(options[:environment]) |
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.
Support passing in the :environment
per-request.
def environment=(environment) | ||
validate_environment!(environment) | ||
|
||
@environment = environment.to_sym | ||
end |
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.
Here I am defining an explicit setter so that we can raise an appropriate developer error when it is set incorrectly.
@test_mode = false | ||
@environment = Payrix::ENVIRONMENTS.fetch(:sandbox) |
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.
Change the default environment setting to sandbox. This is done to foster more safety when using the library, and prevent making accidental mutations in the production environment.
Description
This PR changes the API for setting the request environment. It is now set through
Payrix.environment=
instead ofPayrix.test_mode=
.Without explicit configuration, the default environment is sandbox now instead of production.
Additionally, support has been added for passing an
:environment
parameter into theoptions
hash for all CRUD operations.