Module: FidorApi::Model::BeneficiaryHelper

Included in:
ScheduledTransfer, StandingOrder, Transfer::Generic
Defined in:
lib/fidor_api/model/beneficiary_helper.rb

Constant Summary collapse

SUPPORTED_ROUTING_TYPES =
{
  'SEPA'                   => %w[remote_iban remote_bic instant],
  'FOS_P2P_EMAIL'          => %w[email],
  'FOS_P2P_PHONE'          => %w[mobile_phone_number],
  'FOS_P2P_ACCOUNT_NUMBER' => %w[account_number],
  'FOS_P2P_USERNAME'       => %w[username],
  'FPS'                    => %w[remote_account_number remote_sort_code instant]
}.freeze

Instance Method Summary collapse

Instance Method Details

#define_methods_for(properties) ⇒ Object

rubocop:disable Metrics/MethodLength



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fidor_api/model/beneficiary_helper.rb', line 13

def define_methods_for(properties) # rubocop:disable Metrics/MethodLength
  properties.each do |name|
    next if respond_to?(name)

    self.class.define_method name do
      @beneficiary ||= {}
      @beneficiary.dig('routing_info', name)
    end

    self.class.define_method "#{name}=" do |value|
      @beneficiary ||= {}
      @beneficiary['routing_info'] ||= {}
      @beneficiary['routing_info'][name] = value
    end
  end
end

#parse_errors(body) ⇒ Object



30
31
32
33
34
35
# File 'lib/fidor_api/model/beneficiary_helper.rb', line 30

def parse_errors(body)
  body['errors'].each do |hash|
    hash['field'].sub!('beneficiary.routing_info.', '')
  end
  super(body)
end