Class: Outreach::Service::Prospect
- Inherits:
-
Object
- Object
- Outreach::Service::Prospect
- Defined in:
- lib/outreach/service/prospect.rb
Instance Method Summary collapse
- #find(id) ⇒ Object
- #find_all(attrs = {}) ⇒ Object
-
#initialize(client) ⇒ Prospect
constructor
A new instance of Prospect.
- #update(id, attrs) ⇒ Object
Constructor Details
#initialize(client) ⇒ Prospect
Returns a new instance of Prospect.
4 5 6 |
# File 'lib/outreach/service/prospect.rb', line 4 def initialize(client) @request = client.request end |
Instance Method Details
#find(id) ⇒ Object
8 9 10 11 |
# File 'lib/outreach/service/prospect.rb', line 8 def find(id) response = @request.get("#{api_url}/#{id}") collection_class.build_from_attributes_hash(response['data']) end |
#find_all(attrs = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/outreach/service/prospect.rb', line 13 def find_all(attrs={}) response = @request.get(api_url, filter_attribute_mapping(attrs)) response['data'].map do |attrs| collection_class.build_from_attributes_hash(attrs) end end |
#update(id, attrs) ⇒ Object
20 21 22 23 |
# File 'lib/outreach/service/prospect.rb', line 20 def update(id, attrs) mapped_attrs = update_attribute_mapping(attrs) @request.patch(api_url + "/" + id.to_s, mapped_attrs) end |