Class: GatorjuiceCreditRating::Assessment
- Inherits:
-
Object
- Object
- GatorjuiceCreditRating::Assessment
- Defined in:
- lib/gatorjuice_credit_rating.rb
Instance Attribute Summary collapse
-
#propensity ⇒ Object
readonly
Returns the value of attribute propensity.
-
#ranking ⇒ Object
readonly
Returns the value of attribute ranking.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input_hash) ⇒ Assessment
constructor
A new instance of Assessment.
Constructor Details
#initialize(input_hash) ⇒ Assessment
Returns a new instance of Assessment.
8 9 10 11 |
# File 'lib/gatorjuice_credit_rating.rb', line 8 def initialize(input_hash) @propensity = input_hash["propensity"].to_f @ranking = input_hash["ranking"] end |
Instance Attribute Details
#propensity ⇒ Object (readonly)
Returns the value of attribute propensity.
6 7 8 |
# File 'lib/gatorjuice_credit_rating.rb', line 6 def propensity @propensity end |
#ranking ⇒ Object (readonly)
Returns the value of attribute ranking.
6 7 8 |
# File 'lib/gatorjuice_credit_rating.rb', line 6 def ranking @ranking end |
Class Method Details
.inquiry(input_options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gatorjuice_credit_rating.rb', line 13 def self.inquiry() if [:age] && [:age].to_i >= 18 && !!Integer([:age]) && [:income] && [:income].to_i > 0 && !!Integer([:income]) && [:zipcode] && [:zipcode].to_s.length == 5 && !!Integer([:zipcode]) && .class == Hash response = Unirest.get( "https://pacific-stream-61271.herokuapp.com/api/v1/inquiries", headers: { "Accept" => "application/json" }, parameters: { age: [:age].to_s, income: [:income].to_s, zipcode: [:zipcode], api_token: "ABCDEFG1234567" # ENV[API_TOKEN] } ).body response["response"] ? response["response"] : Assessment.new(response) else raise ArgumentError, "#inquiry takes one hash as an argument and must have keys and numeric values for: age, income, zipcode" end end |