lib/cheetahmails.rb in cheetahmails-0.0.3 vs lib/cheetahmails.rb in cheetahmails-0.1.0
- old
+ new
@@ -61,11 +61,11 @@
else
raise e
end
end
- def self.find_list_member(email)
+ def self.find_list_member(email, prop='')
tries ||= 2
faraday = Faraday.new(:url => @base_uri) do |faraday|
faraday.request :url_encoded # form-encode POST params
#faraday.response :logger # log requests to STDOUT
@@ -76,27 +76,29 @@
faraday.headers["Content-Type"] = "application/json"
faraday.headers["Accept"] = "application/json"
params = {
"viewName" => Cheetahmails.configuration.view_name,
- "prop" => '', #first_name,last_name
+ "prop" => prop, #first_name,last_name
"columnName" => "email_address",
"operation" => "=",
"param" => email
}
response = faraday.get '/services2/api/SearchRecords', params
begin
jsonresponse = JSON.parse(response.body)
rescue JSON::ParserError => error
- raise response.status.to_s + " " + response.body
+ raise response.statzus.to_s + " " + response.body
end
raise RetryException, jsonresponse["message"] if response.status == 401
+ return false if response.status == 404
+
begin
- id = jsonresponse[0]["id"]
+ return jsonresponse[0]
rescue => error
return false
end
rescue RetryException => e