Sha256: 5bd52ce52e0bb03abf4c3cc554188442c2091a4567e7f491e05f3dab537d52d6

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

require "consumer_score_naj/version"
require "unirest"


module Consumer
  class Score
    attr_accessor :income, :zipcode, :age

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

    def self.get_score(query_hash)
      search_string = convert_query_hash_to_string(query_hash)
      response = Unirest.get("http://localhost:3000/customer_scoring.json?#{search_string}").body
    end

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
consumer_score_naj-0.3.0 lib/consumer_score_naj.rb