Class: PipeRocket::PersonService
- Defined in:
- lib/pipe_rocket/person_service.rb
Constant Summary collapse
- HOST =
'https://api.pipedrive.com/v1'
Constants inherited from Service
Service::RESOURCES_WITH_CUSTOM_FIELDS
Instance Method Summary collapse
-
#find_by_email(email) ⇒ Object
Find person by email.
Methods inherited from Service
#all, #build_entity, #build_uri, #create, #find, #first, #initialize, #update
Constructor Details
This class inherits a constructor from PipeRocket::Service
Instance Method Details
#find_by_email(email) ⇒ Object
Find person by email
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pipe_rocket/person_service.rb', line 6 def find_by_email(email) uri = build_uri({term: email, search_by_email: true }, 'find') response = HTTP.get(uri) case response.code when 200 json_array = ::JSON.parse(response)['data'] return [] unless json_array json_array.map{|raw|build_entity(raw)} else raise PipeRocket::Error.new(response.code) end rescue HTTP::ConnectionError raise PipeRocket::Error.new(408) end |