Class: Clearbit::Person
- Defined in:
- lib/clearbit/person.rb
Direct Known Subclasses
Class Method Summary collapse
- .find(values, old_options = nil) ⇒ Object (also: [])
Instance Method Summary collapse
Methods inherited from Base
Methods inherited from Resource
delete, endpoint, get, options, path, post, put, request, uri, #uri, url
Methods inherited from Mash
#custom_reader, #custom_writer, #deep_merge, #deep_update, #delete, #dup, #fetch, #id, #initialize, #initializing_reader, #key?, #method_missing, new, #regular_dup, #replace, #respond_to?, #shallow_merge, #shallow_update, #type, #underbang_reader
Constructor Details
This class inherits a constructor from Clearbit::Mash
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Clearbit::Mash
Class Method Details
.find(values, old_options = nil) ⇒ Object Also known as: []
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/clearbit/person.rb', line 6 def self.find(values, = nil) unless values.is_a?(Hash) values = {:id => values} end if # Deprecated API warn '[DEPRECATION] passing multiple args to find() is deprecated' (values[:request] ||= {}).merge!() end = values.delete(:request) || {} params = values.delete(:params) || {} if webhook_id = values.delete(:webhook_id) params.merge!(webhook_id: webhook_id) end if webhook_url = values.delete(:webhook_url) params.merge!(webhook_url: webhook_url) end if subscribe = values.delete(:subscribe) params.merge!(subscribe: subscribe) end if email = values[:email] response = get(uri(:email, email), params, ) elsif twitter = values[:twitter] response = get(uri(:twitter, twitter), params, ) elsif github = values[:github] response = get(uri(:github, github), params, ) elsif id = values[:id] response = get(id, params, ) else raise ArgumentError, 'Invalid values' end if response.status == 202 self.new(pending: true) else self.new(response) end rescue Nestful::ResourceNotFound end |
Instance Method Details
#flag!(attrs = {}) ⇒ Object
61 62 63 |
# File 'lib/clearbit/person.rb', line 61 def flag!(attrs = {}) self.class.post(uri('flag'), attrs) end |