This PR stores the connection as an instance variable so that the Faraday middleware can be edited (before first use of the connection). In my case it was to add the :retry middleware, and custom middleware to sleep and retry when QboApi::TooManyRequests is encountered.
As far as I could tell, there is no reason for the connection to be instantiated on each request, hence the minimal change. It seems that even when doing a successful #reconnect, the tokens, keys, and secrets are not swapped out, and a new QboApi instance must be created because there is not attr_writer for those variables. Please let me know if there's some necessary case for re-instantiated connections and I will accomodate.
This PR stores the connection as an instance variable so that the Faraday middleware can be edited (before first use of the connection). In my case it was to add the
:retry
middleware, and custom middleware to sleep and retry when QboApi::TooManyRequests is encountered.As far as I could tell, there is no reason for the connection to be instantiated on each request, hence the minimal change. It seems that even when doing a successful
#reconnect
, the tokens, keys, and secrets are not swapped out, and a new QboApi instance must be created because there is not attr_writer for those variables. Please let me know if there's some necessary case for re-instantiated connections and I will accomodate.