Module: LedgerSync::Adaptors::QuickBooksOnline::Operation::Mixin::InstanceMethods
- Defined in:
- lib/ledger_sync/adaptors/quickbooks_online/operation.rb
Instance Method Summary collapse
- #deserialized_resource(response:) ⇒ Object
- #ledger_resource_path ⇒ Object
- #ledger_resource_type_for_path ⇒ Object
- #perform ⇒ Object
- #quickbooks_online_resource_type ⇒ Object
- #response_to_operation_result(response:) ⇒ Object
Instance Method Details
#deserialized_resource(response:) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/operation.rb', line 14 def deserialized_resource(response:) ledger_serializer.deserialize( hash: response.body.dig( quickbooks_online_resource_type.to_s.camelize ) ) end |
#ledger_resource_path ⇒ Object
22 23 24 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/operation.rb', line 22 def ledger_resource_path @ledger_resource_path ||= "#{ledger_resource_type_for_path}/#{resource.ledger_id}" end |
#ledger_resource_type_for_path ⇒ Object
26 27 28 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/operation.rb', line 26 def ledger_resource_type_for_path quickbooks_online_resource_type.tr('_', '') end |
#perform ⇒ Object
46 47 48 49 50 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/operation.rb', line 46 def perform super rescue LedgerSync::Error::OperationError, OAuth2::Error => e failure(e) end |
#quickbooks_online_resource_type ⇒ Object
52 53 54 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/operation.rb', line 52 def quickbooks_online_resource_type @quickbooks_online_resource_type ||= ledger_serializer.class.quickbooks_online_resource_type end |
#response_to_operation_result(response:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ledger_sync/adaptors/quickbooks_online/operation.rb', line 30 def response_to_operation_result(response:) if response.success? success( resource: deserialized_resource(response: response), response: response ) else failure( Error::OperationError.new( operation: self, response: response ) ) end end |