Support passing production: ... to QboApi.new #146
+24
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! Thanks for your work on this gem -- I've been using it to develop a new Rails-based integration for keeping inventory.
I'm starting to get my integration in production mode, but I'd like to continue using Sandbox mode for some testing accounts. To support that, I'd like to initialize clients with their own
@production = true | falseattributes. That way, I can have some Rails requests using sandbox credentials and others using production credentials.I considered something like
before_action { ... }, setting top-levelQboApi.production = ...on a per-request basis, but I'm using a threaded Rails server and I think that configuration would leak from one request to the next, since.production = ...isn't thread-safe. In any case, I'm creatingQboApiinstances for each logged-in user anyways, so what I really want is a per-clientproductionsetting.I have added an optional
QboApi.new(production: ...)setting in this PR. When the parameter is not provided, it keeps the previous default behavior of dynamically checkingself.class.production, so instances can switch modes when the top level setting changes. I think this keeps 100% compatibility with the previous code.What do you think about this change? Let me know if you're interested and I'd be happy to make any other improvements you recommend.