Class: Consumer::Score

Inherits:
Object
  • Object
show all
Defined in:
lib/consumer_score_naj.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_hash) ⇒ Score

Returns a new instance of Score.



9
10
11
12
13
# File 'lib/consumer_score_naj.rb', line 9

def initialize(query_hash)
  @income = query_hash["income"]
  @zipcode = query_hash["zipcode"]
  @age = query_hash["age"]
end

Instance Attribute Details

#ageObject

Returns the value of attribute age.



7
8
9
# File 'lib/consumer_score_naj.rb', line 7

def age
  @age
end

#incomeObject

Returns the value of attribute income.



7
8
9
# File 'lib/consumer_score_naj.rb', line 7

def income
  @income
end

#zipcodeObject

Returns the value of attribute zipcode.



7
8
9
# File 'lib/consumer_score_naj.rb', line 7

def zipcode
  @zipcode
end

Class Method Details

.convert_query_hash_to_string(query_hash) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/consumer_score_naj.rb', line 20

def self.convert_query_hash_to_string(query_hash)
  search_array = []
  query_hash.each do |key, value|
    search_array << "#{key}=#{value}"
  end
  search_string = search_array.join("&")
end

.get_score(query_hash) ⇒ Object



15
16
17
18
# File 'lib/consumer_score_naj.rb', line 15

def self.get_score(query_hash)
  search_string = convert_query_hash_to_string(query_hash)
  response = Unirest.get("https://consumer-api-staging.herokuapp.com/customer_scoring.json?#{search_string}").body
end