12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/hypofriend/client.rb', line 12
def new_offer(loan_amount:, property_value:, repayment:, years_fixed:)
response = self.class.get(
'/api/v5/new-offers',
{
query: {
loan_amount: loan_amount,
property_value: property_value,
repayment: repayment,
years_fixed: years_fixed
}
}
)
raise FetchError.new(response.body) unless response.success?
JSON.parse(response.body).dig('data', 'offers')&.map do |offer|
Offer.new(
institution_name: offer['institution_name'],
borrowing_rate: offer['borrowing_rate']
)
end
end
|