Class: Hypofriend::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/hypofriend/client.rb

Constant Summary collapse

BASE_URI =
'https://offer-v3.hypofriend.de'

Instance Method Summary collapse

Instance Method Details

#new_offer(loan_amount:, property_value:, repayment:, years_fixed:) ⇒ Object

Raises:



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