Class: Pipedrive::SearchResult
- Defined in:
- lib/pipedrive/search-result.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .field(term, field_type, field_key, opts = {}) ⇒ Object
- .search(term, start = 0, limit = nil) ⇒ Object
Methods inherited from Base
all, authenticate, bad_response, create, find, find_by_name, #initialize, new_list, resource_path, #update
Constructor Details
This class inherits a constructor from Pipedrive::Base
Class Method Details
.field(term, field_type, field_key, opts = {}) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/pipedrive/search-result.rb', line 16 def field(term, field_type, field_key, opts={}) res = get("#{resource_path}/field", :query => opts.merge(:term => term, :field_type => field_type, :field_key => field_key) ) if res.ok? res['data'].nil? ? [] : res['data'].map{|obj| new(obj)} else bad_response(res,{:term=>term,:field_type=>field_type,:field_key=>field_key}.merge(opts)) end end |
.search(term, start = 0, limit = nil) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/pipedrive/search-result.rb', line 7 def search(term, start=0, limit=nil) res = get(resource_path, :query => { :term => term, :start => start, :limit => limit}) if res.ok? res['data'].nil? ? [] : res['data'].map{|obj| new(obj)} else bad_response(res,{:term=>term,:start=>start,:limit=>limit}) end end |