Class: LedgerSync::Ledgers::QuickBooksOnline::Request
- Defined in:
- lib/ledger_sync/ledgers/quickbooks_online/request.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Attributes inherited from Request
#body, #headers, #method, #params, #response, #url
Instance Method Summary collapse
-
#initialize(*args, client:, **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, client:, **keywords) ⇒ Request
Returns a new instance of Request.
9 10 11 12 |
# File 'lib/ledger_sync/ledgers/quickbooks_online/request.rb', line 9 def initialize(*args, client:, **keywords) @client = client super(*args, **keywords) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/ledger_sync/ledgers/quickbooks_online/request.rb', line 7 def client @client 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/ledgers/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::LedgerError::AuthenticationError) begin client.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/ledgers/quickbooks_online/request.rb', line 44 def refresh! oauth.refresh! rescue OAuth2::Error => e raise parse_error(error: e) end |