Class: AdvisorsCommandClient::Models::ContactCollection
- Inherits:
-
Object
- Object
- AdvisorsCommandClient::Models::ContactCollection
- Defined in:
- lib/advisors_command_client/models/contact_collection.rb
Instance Method Summary collapse
- #find(contact_id) ⇒ Object
-
#initialize(args = {}) ⇒ ContactCollection
constructor
A new instance of ContactCollection.
- #search(query) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ ContactCollection
Returns a new instance of ContactCollection.
4 5 6 |
# File 'lib/advisors_command_client/models/contact_collection.rb', line 4 def initialize(args = {}) @connection = args[:connection] end |
Instance Method Details
#find(contact_id) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/advisors_command_client/models/contact_collection.rb', line 19 def find(contact_id) resp = @connection.get("contacts/#{contact_id}") if resp.success? return AdvisorsCommandClient::Models::Contact.load(resp.body, @connection) else return nil end end |
#search(query) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/advisors_command_client/models/contact_collection.rb', line 8 def search(query) response = @connection.get('search', {search: query, from: 'orocrm_contact'}) if response.success? return Parallel.map(Array(response.body['data']), in_threads: 4) do |obj| self.find(obj['record_id'].to_i) end.compact else raise ::AdvisorsCommandClient::SearchError, "Error connecting to advisors command." end end |