class AlfaBank::DataBuilder
Attributes
opts[RW]
request_type[RW]
Public Class Methods
new(request_type, opts)
click to toggle source
# File lib/alfa_bank/data_builder.rb, line 9 def initialize(request_type, opts) @request_type = request_type @opts = opts.symbolize_keys! end
Public Instance Methods
call()
click to toggle source
# File lib/alfa_bank/data_builder.rb, line 14 def call unless valid? raise_custom_error end opts.merge!(user_name: user_name, password: password) data_builder.build_params(request_type, opts) end
data_builder()
click to toggle source
TODO: add depandency from config (soap|rest)
# File lib/alfa_bank/data_builder.rb, line 42 def data_builder AlfaBank::RestDataBuilder end
link()
click to toggle source
# File lib/alfa_bank/data_builder.rb, line 29 def link "#{AlfaBank.configuration.base_link}/#{Constants::ALFA_LINKS[request_type]}" end
password()
click to toggle source
# File lib/alfa_bank/data_builder.rb, line 37 def password AlfaBank.configuration.password end
user_name()
click to toggle source
# File lib/alfa_bank/data_builder.rb, line 33 def user_name AlfaBank.configuration.user_name end
valid?()
click to toggle source
# File lib/alfa_bank/data_builder.rb, line 22 def valid? fields = Constants::REQUIRED_FIELDS[request_type] opts.values_at(*fields).compact.size == fields.size rescue raise_custom_error end
Private Instance Methods
raise_custom_error()
click to toggle source
# File lib/alfa_bank/data_builder.rb, line 47 def raise_custom_error raise StandardError, 'Please check that params are correct' end