Class: ForestAdminDatasourceMambuPayments::Collections::ExpectedPayment
- Inherits:
-
BaseCollection
- Object
- ForestAdminDatasourceToolkit::Collection
- BaseCollection
- ForestAdminDatasourceMambuPayments::Collections::ExpectedPayment
- Defined in:
- lib/forest_admin_datasource_mambu_payments/collections/expected_payment.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) ⇒ ExpectedPayment
constructor
A new instance of ExpectedPayment.
- #serialize(record) ⇒ Object
- #update(caller, filter, patch) ⇒ Object
Methods inherited from BaseCollection
#aggregate, client_resource, #fetch_by_ids, #list
Constructor Details
#initialize(datasource) ⇒ ExpectedPayment
Returns a new instance of ExpectedPayment.
11 12 13 14 15 16 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/expected_payment.rb', line 11 def initialize(datasource) super(datasource, 'MambuExpectedPayment') 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/expected_payment.rb', line 18 def create(_caller, data) serialize(datasource.client.create_expected_payment(build_payload(data))) end |
#delete(caller, filter) ⇒ Object
27 28 29 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/expected_payment.rb', line 27 def delete(caller, filter) ids_for(caller, filter).each { |id| datasource.client.delete_expected_payment(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 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/expected_payment.rb', line 31 def serialize(record) a = attrs_of(record) { 'id' => a['id'], 'object' => a['object'], 'idempotency_key' => a['idempotency_key'], 'connected_account_id' => a['connected_account_id'], 'internal_account_id' => a['internal_account_id'], 'external_account_id' => a['external_account_id'], 'direction' => a['direction'], 'amount_from' => a['amount_from'], 'amount_to' => a['amount_to'], 'currency' => a['currency'], 'start_date' => a['start_date'], 'end_date' => a['end_date'], 'descriptions' => a['descriptions'], 'reconciliation_status' => a['reconciliation_status'], 'reconciled_amount' => a['reconciled_amount'], 'custom_fields' => a['custom_fields'], 'metadata' => a['metadata'], 'created_at' => a['created_at'], 'updated_at' => a['updated_at'], 'canceled_at' => a['canceled_at'] } end |
#update(caller, filter, patch) ⇒ Object
22 23 24 25 |
# File 'lib/forest_admin_datasource_mambu_payments/collections/expected_payment.rb', line 22 def update(caller, filter, patch) payload = build_payload(patch) ids_for(caller, filter).each { |id| datasource.client.update_expected_payment(id, payload) } end |