Skip to content

Conversation

@rmosolgo
Copy link

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 | false attributes. That way, I can have some Rails requests using sandbox credentials and others using production credentials.

I considered something like before_action { ... }, setting top-level QboApi.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 creating QboApi instances for each logged-in user anyways, so what I really want is a per-client production setting.

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 checking self.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.

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.

1 participant