Class: ForestAdminDatasourceMambuPayments::Collections::PaymentOrder
- Inherits:
-
BaseCollection
- Object
- ForestAdminDatasourceToolkit::Collection
- BaseCollection
- ForestAdminDatasourceMambuPayments::Collections::PaymentOrder
- Defined in:
- lib/forest_admin_datasource_mambu_payments/collections/payment_order.rb
Constant Summary collapse
- ManyToOneSchema =
ForestAdminDatasourceToolkit::Schema::Relations::ManyToOneSchema
- ENUM_DIRECTION =
%w[debit credit].freeze
Constants inherited from BaseCollection
BaseCollection::BOOL_OPS, BaseCollection::ColumnSchema, BaseCollection::DATE_OPS, BaseCollection::ForestException, BaseCollection::ID_OPS, BaseCollection::Leaf, BaseCollection::NUMBER_OPS, BaseCollection::Operators, BaseCollection::STRING_OPS
Instance Method Summary collapse
- #create(_caller, data) ⇒ Object
- #delete(caller, filter) ⇒ Object
-
#initialize(datasource) ⇒ PaymentOrder
constructor
A new instance of PaymentOrder.
- #serialize(record) ⇒ Object
- #update(caller, filter, patch) ⇒ Object
Methods inherited from BaseCollection
#aggregate, client_resource, #fetch_by_ids, #list
Constructor Details
#initialize(datasource) ⇒ PaymentOrder
Returns a new instance of PaymentOrder.
11 12 13 14 15 16 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/payment_order.rb', line 11 def initialize(datasource) super(datasource, 'MambuPaymentOrder') define_schema define_relations reconcile_filter_operators! end |
Instance Method Details
#create(_caller, data) ⇒ Object
18 19 20 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/payment_order.rb', line 18 def create(_caller, data) serialize(datasource.client.create_payment_order(build_payload(data))) end |
#delete(caller, filter) ⇒ Object
27 28 29 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/payment_order.rb', line 27 def delete(caller, filter) ids_for(caller, filter).each { |id| datasource.client.delete_payment_order(id) } end |
#serialize(record) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/payment_order.rb', line 31 def serialize(record) a = attrs_of(record) { 'id' => a['id'], 'connected_account_id' => a['connected_account_id'], 'receiving_account_id' => a['receiving_account_id'], 'type' => a['type'], 'direction' => a['direction'], 'status' => a['status'], 'amount' => a['amount'], 'currency' => a['currency'], 'reference' => a['reference'], 'purpose' => a['purpose'], 'end_to_end_id' => a['end_to_end_id'], 'idempotency_key' => a['idempotency_key'], 'requested_execution_date' => a['requested_execution_date'], 'value_date' => a['value_date'], 'initiated_at' => a['initiated_at'], 'reconciliation_status' => a['reconciliation_status'], 'reconciled_amount' => a['reconciled_amount'], 'originating_account' => a['originating_account'], 'receiving_account' => a['receiving_account'], 'metadata' => a['metadata'], 'custom_fields' => a['custom_fields'], 'created_at' => a['created_at'] } end |
#update(caller, filter, patch) ⇒ Object
22 23 24 25 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/payment_order.rb', line 22 def update(caller, filter, patch) payload = build_payload(patch) ids_for(caller, filter).each { |id| datasource.client.update_payment_order(id, payload) } end |