Class: AlfaBank::DataBuilder
- Inherits:
-
Object
- Object
- AlfaBank::DataBuilder
- Defined in:
- lib/alfa_bank/data_builder.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#request_type ⇒ Object
Returns the value of attribute request_type.
Instance Method Summary collapse
- #call ⇒ Object
-
#data_builder ⇒ Object
TODO: add depandency from config (soap|rest).
-
#initialize(request_type, opts) ⇒ DataBuilder
constructor
A new instance of DataBuilder.
- #link ⇒ Object
- #password ⇒ Object
- #user_name ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(request_type, opts) ⇒ DataBuilder
Returns a new instance of DataBuilder.
9 10 11 12 |
# File 'lib/alfa_bank/data_builder.rb', line 9 def initialize(request_type, opts) @request_type = request_type @opts = opts.symbolize_keys! end |
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts.
7 8 9 |
# File 'lib/alfa_bank/data_builder.rb', line 7 def opts @opts end |
#request_type ⇒ Object
Returns the value of attribute request_type.
7 8 9 |
# File 'lib/alfa_bank/data_builder.rb', line 7 def request_type @request_type end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 |
# 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 ⇒ Object
TODO: add depandency from config (soap|rest)
42 43 44 |
# File 'lib/alfa_bank/data_builder.rb', line 42 def data_builder AlfaBank::RestDataBuilder end |
#link ⇒ Object
29 30 31 |
# File 'lib/alfa_bank/data_builder.rb', line 29 def link "#{AlfaBank.configuration.base_link}/#{Constants::ALFA_LINKS[request_type]}" end |
#password ⇒ Object
37 38 39 |
# File 'lib/alfa_bank/data_builder.rb', line 37 def password AlfaBank.configuration.password end |
#user_name ⇒ Object
33 34 35 |
# File 'lib/alfa_bank/data_builder.rb', line 33 def user_name AlfaBank.configuration.user_name end |
#valid? ⇒ Boolean
22 23 24 25 26 27 |
# 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 |