Class: InstantQuote::AdapterFinder
- Inherits:
-
Object
- Object
- InstantQuote::AdapterFinder
- Defined in:
- lib/instant_quote/adapter_finder.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#decision_parser ⇒ Object
readonly
Returns the value of attribute decision_parser.
-
#translator ⇒ Object
readonly
Returns the value of attribute translator.
Class Method Summary collapse
Instance Method Summary collapse
- #accept_offer(offer_id) ⇒ Object
- #additional_fields ⇒ Object
- #get_approval ⇒ Object
- #get_link ⇒ Object
- #get_preapproval ⇒ Object
- #get_quote ⇒ Object
- #get_status ⇒ Object
-
#initialize(connection) ⇒ AdapterFinder
constructor
A new instance of AdapterFinder.
- #parse_decision ⇒ Object
Constructor Details
#initialize(connection) ⇒ AdapterFinder
Returns a new instance of AdapterFinder.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/instant_quote/adapter_finder.rb', line 22 def initialize(connection) @connection = connection @adapter_name = connection.adapter validate_adapter_name! @adapter = Object.const_get("InstantQuote::Adapters::#{adapter_class}") @translator = Object.const_get("InstantQuote::ConnectionTranslators::#{adapter_class}") @decision_parser = Object.const_get("InstantQuote::DecisionParsers::#{adapter_class}") end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
20 21 22 |
# File 'lib/instant_quote/adapter_finder.rb', line 20 def adapter @adapter end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
20 21 22 |
# File 'lib/instant_quote/adapter_finder.rb', line 20 def connection @connection end |
#decision_parser ⇒ Object (readonly)
Returns the value of attribute decision_parser.
20 21 22 |
# File 'lib/instant_quote/adapter_finder.rb', line 20 def decision_parser @decision_parser end |
#translator ⇒ Object (readonly)
Returns the value of attribute translator.
20 21 22 |
# File 'lib/instant_quote/adapter_finder.rb', line 20 def translator @translator end |
Class Method Details
.available_adapters ⇒ Object
33 34 35 36 |
# File 'lib/instant_quote/adapter_finder.rb', line 33 def self.available_adapters Dir.glob('*.rb', base: File.('adapters', __dir__)) .map { |adapter| adapter.sub('.rb', '') } end |
Instance Method Details
#accept_offer(offer_id) ⇒ Object
62 63 64 |
# File 'lib/instant_quote/adapter_finder.rb', line 62 def accept_offer(offer_id) adapter.accept_offer(connection.external_id, connection, offer_id) end |
#additional_fields ⇒ Object
66 67 68 |
# File 'lib/instant_quote/adapter_finder.rb', line 66 def additional_fields adapter.additional_fields end |
#get_approval ⇒ Object
58 59 60 |
# File 'lib/instant_quote/adapter_finder.rb', line 58 def get_approval adapter.get_approval(connection.external_id, connection) end |
#get_link ⇒ Object
38 39 40 |
# File 'lib/instant_quote/adapter_finder.rb', line 38 def get_link adapter.get_link(connection) end |
#get_preapproval ⇒ Object
52 53 54 55 56 |
# File 'lib/instant_quote/adapter_finder.rb', line 52 def get_preapproval params = translator.translate(connection) adapter.get_preapproval(params, connection) end |
#get_quote ⇒ Object
42 43 44 45 46 |
# File 'lib/instant_quote/adapter_finder.rb', line 42 def get_quote params = translator.translate(connection) adapter.get_quote(params, connection) end |
#get_status ⇒ Object
48 49 50 |
# File 'lib/instant_quote/adapter_finder.rb', line 48 def get_status adapter.get_status(connection.external_id, connection) end |
#parse_decision ⇒ Object
70 71 72 |
# File 'lib/instant_quote/adapter_finder.rb', line 70 def parse_decision decision_parser.new(connection.approval_decision_info) end |