Sha256: 2fb928d24de5e5f06e7c634641d94a65cc4f04136524595b5924f516b233bb4e
Contents?: true
Size: 1015 Bytes
Versions: 1
Compression:
Stored size: 1015 Bytes
Contents
# frozen_string_literal: true # Following the API description here: https://staging.youlendapi.com/prequalification/index.html module Youlend class Quote def self.pre_qualification(params) response = Youlend.connection.post('/prequalification/Requests', :prequalification, params) # If we got back a response but all the funded amounts are 0.0 it means that the load was # actually rejected! We'll replace the response body with an error message instead and change # the success code. if loan_accepted?(response.body) response else response.http_response.env.status = 422 response.http_response.env.body = { error: 'Rejected', error_description: 'Loan was rejected' } response end end def self.loan_accepted?(data) return false unless data[:loanOptions] options = data[:loanOptions] funded_amounts = options.map { |option| option[:fundedAmount] } funded_amounts.any?(&:positive?) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
youlend-1.0.0 | lib/youlend/quote.rb |