Skip to content

Commit

Permalink
Fixed find_by_email to match documentation, implemented batch results…
Browse files Browse the repository at this point in the history
… too.
  • Loading branch information
srgoldman committed Nov 23, 2015
1 parent fe9d7dc commit 5fcfcab
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/hubspot/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ def find_by_email(emails)
else raise Hubspot::InvalidParams, 'expecting String or Array of Strings parameter'
end

response = Hubspot::Connection.get_json(path, params)
if batch_mode
#TODO: transform response
response
else
new(response)
begin
response = Hubspot::Connection.get_json(path, params)
if batch_mode
response.map{|_, contact| new(contact)}
else
new(response)
end
rescue => e
raise e unless e.message =~ /not exist/ # 404 / handle the error and kindly return nil
nil
end
end

Expand Down

0 comments on commit 5fcfcab

Please sign in to comment.