Class: Hopo::Rater

Inherits:
API show all
Includes:
Utils::Calculator, Utils::Sorter
Defined in:
lib/hopo/rater.rb

Direct Known Subclasses

AutoRater, HomeRater

Constant Summary collapse

BASE_URL =

BASE_URL = ‘integral.dev/api

'https://integral.honestpolicy.com/api'
API_VERSION =
2
API_PATH =
'rates'

Instance Attribute Summary collapse

Attributes inherited from API

#default_params, #http, #path, #ssl, #uri, #url

Instance Method Summary collapse

Methods included from Utils::Sorter

#sort_rates

Methods included from Utils::Calculator

#factor_rates

Methods inherited from API

#full_path, #params, #params=

Methods included from Connections::Response

included

Methods included from Connections::Request

#delete, #get, included, #patch, #post, #put

Constructor Details

#initialize(line, premium_mode = 'annually', sorter = 'premium-asc') ⇒ Rater

Returns a new instance of Rater.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/hopo/rater.rb', line 13

def initialize(line, premium_mode='annually', sorter='premium-asc')
  unless Hopo.api_key
    raise AuthenticationError, 'No API key provided.  Set your API key using "Hopo.api_key = <API-KEY>".'
  end

  super(BASE_URL, "/v#{API_VERSION}/#{API_PATH}", true)

  @premium_mode = premium_mode
  @sorter = sorter

  @default_params = {
    :key => Hopo.api_key,
    :line => line
  }

end

Instance Attribute Details

#lineObject

Returns the value of attribute line.



6
7
8
# File 'lib/hopo/rater.rb', line 6

def line
  @line
end

#premium_modeObject

Returns the value of attribute premium_mode.



6
7
8
# File 'lib/hopo/rater.rb', line 6

def premium_mode
  @premium_mode
end

#sorterObject

Returns the value of attribute sorter.



6
7
8
# File 'lib/hopo/rater.rb', line 6

def sorter
  @sorter
end