Permalink
Browse files

Merge pull request #5 from newzealandpaul/master

Added Rapleaf's Utilities API to the ruby gem.
  • Loading branch information...
2 parents 4345fa9 + 2b376f8 commit 05dccf44c937abe4fbce27d3b5456dcdc62960be @seancarr seancarr committed Apr 30, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 ruby/lib/rapleaf_api.rb
View
@@ -31,6 +31,7 @@ def initialize(api_key, options = {})
@API_KEY = api_key
@BASE_PATH = "/v4/dr?api_key=#{@API_KEY}"
@BULK_PATH = "/v4/bulk?api_key=#{@API_KEY}"
+ @UTIL_PATH = "/v4/util"
@TIMEOUT = options[:timeout] || 2
@BULK_TIMEOUT = options[:bulk_timeout] || 30
@CA_FILE = options[:ca_file] # set to your system-wide root ca cert file
@@ -99,6 +100,21 @@ def query_by_naz(first, last, zip4, options = {})
get_json_response(url, options[:show_available])
end
+ # Takes a name and returns a hash which maps attribute fields onto attributes
+ def util_name_to_gender(name)
+ get_json_response("#{@UTIL_PATH}/name_to_gender/#{url_encode(name.strip)}?api_key=#{@API_KEY}")
+ end
+
+ # Takes an e-mail or username and returns a hash which maps attribute fields onto attributes
+ def util_name_deducer(email_or_username)
+ get_json_response("#{@UTIL_PATH}/name_deducer/#{url_encode(email_or_username.strip)}?api_key=#{@API_KEY}")
+ end
+
+ # Takes a name and returns a hash which maps attribute fields onto attributes
+ def util_name_normalizer(name)
+ get_json_response("#{@UTIL_PATH}/name_normalizer/#{url_encode(name.strip)}?api_key=#{@API_KEY}")
+ end
+
def bulk_query(set, show_available = false)
path = @BULK_PATH
path += "&show_available=true" if show_available

0 comments on commit 05dccf4

Please sign in to comment.