Class: Trolley::Utils::ResponseMapper
- Inherits:
-
Object
- Object
- Trolley::Utils::ResponseMapper
- Defined in:
- lib/trolley/utils/ResponseMapper.rb
Constant Summary collapse
- KLASS_TO_RESOURCE_KEY_MAPPERS =
{ 'Trolley::Batch' => { resource: 'batch', collection: 'batches' }, 'Trolley::Invoice' => { resource: 'invoice', collection: 'invoices' }, 'Trolley::InvoicePayment' => { resource: 'invoicePayment', collection: 'invoicePayments' }, 'Trolley::OfflinePayment' => { resource: 'offlinePayment', collection: 'offlinePayments' }, 'Trolley::Payment' => { resource: 'payment', collection: 'payments' }, 'Trolley::RecipientAccount' => { resource: 'account', collection: 'accounts' }, 'Trolley::Recipient' => { resource: 'recipient', collection: 'recipients' }, 'Trolley::BatchSummary' => { resource: 'batchSummary' } }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(response, klass) ⇒ ResponseMapper
constructor
A new instance of ResponseMapper.
Constructor Details
#initialize(response, klass) ⇒ ResponseMapper
Returns a new instance of ResponseMapper.
21 22 23 24 25 |
# File 'lib/trolley/utils/ResponseMapper.rb', line 21 def initialize(response, klass) @response = response @klass = klass @data = JSON.parse(response) end |
Class Method Details
.build(response, klass) ⇒ Object
17 18 19 |
# File 'lib/trolley/utils/ResponseMapper.rb', line 17 def self.build(response, klass) new(response, klass).build end |
Instance Method Details
#build ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/trolley/utils/ResponseMapper.rb', line 27 def build if collection? build_collection else build_resource end end |