Class: Outreach::Service::Prospect

Inherits:
Object
  • Object
show all
Defined in:
lib/outreach/service/prospect.rb

Instance Method Summary collapse

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