Class: InstantQuote::Adapters::Youlend
- Inherits:
-
InstantQuote::Adapter
- Object
- InstantQuote::Adapter
- InstantQuote::Adapters::Youlend
- Defined in:
- lib/instant_quote/adapters/youlend.rb
Constant Summary
Constants inherited from InstantQuote::Adapter
InstantQuote::Adapter::DEFAULT_ADDITIONAL_FIELDS
Instance Method Summary collapse
- #accept_offer(application_id, _connection, offer_id) ⇒ Object
-
#get_link(connection) ⇒ Object
Gets the URL for the given state key.
-
#get_quote(params, connection) ⇒ Object
For Youlend we first need to create a lead and then update lead since some of the fields are not available in create.
- #get_status(lead_id, connection) ⇒ Object
Methods inherited from InstantQuote::Adapter
accept_offer, additional_fields, #get_approval, get_approval, get_link, get_preapproval, #get_preapproval, get_quote, get_status
Instance Method Details
#accept_offer(application_id, _connection, offer_id) ⇒ Object
46 47 48 49 50 |
# File 'lib/instant_quote/adapters/youlend.rb', line 46 def accept_offer(application_id, _connection, offer_id) response = ::Youlend::Lead.accept_offer(application_id, offer_id) response.success? end |
#get_link(connection) ⇒ Object
Gets the URL for the given state key.
53 54 55 |
# File 'lib/instant_quote/adapters/youlend.rb', line 53 def get_link(connection) connection.link end |
#get_quote(params, connection) ⇒ Object
For Youlend we first need to create a lead and then update lead since some of the fields are not available in create
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/instant_quote/adapters/youlend.rb', line 21 def get_quote(params, connection) data = create_lead(params) update_lead(data[:leadId], params) submit_persons(data[:leadId], connection) connection.update(link: data[:signUpURL]) return data[:leadId] end |
#get_status(lead_id, connection) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/instant_quote/adapters/youlend.rb', line 32 def get_status(lead_id, connection) details = ::Youlend::Lead.details(lead_id) raise_error(details) unless details.success? offers = ::Youlend::Lead.offers(lead_id) if details.body[:onboardingState] == 'offersProvided' raise_error(offers) if offers && !offers.success? decision = connection.approval_decision_info.merge(details: details.body) decision.merge!(offers: offers&.body) if offers connection.update(approval_decision_info: decision) DecisionParsers::Youlend.new(connection.approval_decision_info) end |