Class: ForestAdminDatasourceMambuPayments::Collections::ExternalAccount

Inherits:
BaseCollection
  • Object
show all
Defined in:
lib/forest_admin_datasource_mambu_payments/collections/external_account.rb

Constant Summary collapse

ManyToOneSchema =
ForestAdminDatasourceToolkit::Schema::Relations::ManyToOneSchema

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

Methods inherited from BaseCollection

#aggregate, client_resource, #fetch_by_ids, #list

Constructor Details

#initialize(datasource) ⇒ ExternalAccount

Returns a new instance of ExternalAccount.



9
10
11
12
13
14
# File 'lib/forest_admin_datasource_mambu_payments/collections/external_account.rb', line 9

def initialize(datasource)
  super(datasource, 'MambuExternalAccount')
  define_schema
  define_relations
  reconcile_filter_operators!
end

Instance Method Details

#create(_caller, data) ⇒ Object



16
17
18
# File 'lib/forest_admin_datasource_mambu_payments/collections/external_account.rb', line 16

def create(_caller, data)
  serialize(datasource.client.(build_payload(data)))
end

#delete(caller, filter) ⇒ Object



25
26
27
# File 'lib/forest_admin_datasource_mambu_payments/collections/external_account.rb', line 25

def delete(caller, filter)
  ids_for(caller, filter).each { |id| datasource.client.(id) }
end

#serialize(record) ⇒ Object



29
30
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/external_account.rb', line 29

def serialize(record)
  a = attrs_of(record)
  {
    'id' => a['id'],
    'object' => a['object'],
    'type' => a['type'],
    'status' => a['status'],
    'status_details' => a['status_details'],
    'name' => a['name'],
    'holder_name' => a['holder_name'],
    'holder_address' => a['holder_address'],
    'account_number' => a['account_number'],
    'account_number_format' => a['account_number_format'],
    'bank_code' => a['bank_code'],
    'bank_name' => a['bank_name'],
    'bank_address' => a['bank_address'],
    'bank_code_format' => a['bank_code_format'],
    'account_holder_id' => a['account_holder_id'],
    'organization_identification' => a['organization_identification'],
    'company_registration_number' => a['company_registration_number'],
    'company_registration_number_type' => a['company_registration_number_type'],
    'metadata' => a['metadata'],
    'custom_fields' => a['custom_fields'],
    'account_verification' => a['account_verification'],
    'idempotency_key' => a['idempotency_key'],
    'created_at' => a['created_at'],
    'disabled_at' => a['disabled_at']
  }
end

#update(caller, filter, patch) ⇒ Object



20
21
22
23
# File 'lib/forest_admin_datasource_mambu_payments/collections/external_account.rb', line 20

def update(caller, filter, patch)
  payload = build_payload(patch)
  ids_for(caller, filter).each { |id| datasource.client.(id, payload) }
end