Class: LedgerSync::Adaptors::QuickBooksOnline::Request
- Defined in:
- lib/ledger_sync/adaptors/quickbooks_online/request.rb
Instance Attribute Summary collapse
-
#adaptor ⇒ Object
readonly
Returns the value of attribute adaptor.
Attributes inherited from Request
#body, #headers, #method, #response, #url
Instance Method Summary collapse
-
#initialize(*args, adaptor:, **keywords) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
- #refresh! ⇒ Object
Methods inherited from Request
delete, get, #performed?, post, put
Constructor Details
#initialize(*args, adaptor:, **keywords) ⇒ Request
Returns a new instance of Request.
9 10 11 12 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/request.rb', line 9 def initialize(*args, adaptor:, **keywords) @adaptor = adaptor super(*args, **keywords) end |
Instance Attribute Details
#adaptor ⇒ Object (readonly)
Returns the value of attribute adaptor.
7 8 9 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/request.rb', line 7 def adaptor @adaptor end |
Instance Method Details
#perform ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/request.rb', line 14 def perform raise 'Request already performed' if performed? @response = generate_response( body: body, headers: headers, method: method, url: url ) rescue OAuth2::Error => e error = parse_error(error: e) if error.is_a?(Error::AdaptorError::AuthenticationError) begin adaptor.refresh! @response = generate_response( body: body, headers: headers, method: method, url: url ) return @response rescue OAuth2::Error => e raise parse_error(error: e) end end raise error end |
#refresh! ⇒ Object
44 45 46 47 48 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/request.rb', line 44 def refresh! oauth.refresh! rescue OAuth2::Error => e raise parse_error(error: e) end |