Module: AutotaskRuby::Query
- Included in:
- AccountToDo, Resource, ServiceCall, Ticket
- Defined in:
- lib/autotask_ruby/query.rb
Instance Method Summary collapse
-
#find(entity, field = 'id', id) ⇒ Object
Returns a single Entity if a match was found.
- #query(entity_type, field = 'id', op = 'equals', value) ⇒ Object
Instance Method Details
#find(entity, field = 'id', id) ⇒ Object
Returns a single Entity if a match was found. Returns nil if no match is found.
15 16 17 18 19 20 |
# File 'lib/autotask_ruby/query.rb', line 15 def find(entity, field = 'id', id) response = query(entity, field, id) return nil if response.entities.empty? response.entities.first end |
#query(entity_type, field = 'id', op = 'equals', value) ⇒ Object
5 6 7 8 |
# File 'lib/autotask_ruby/query.rb', line 5 def query(entity_type, field = 'id', op = 'equals', value) result = @client.soap_client.call(:query, message: "<sXML><![CDATA[<queryxml><entity>#{entity_type}</entity><query><field>#{field}<expression op=\"#{op}\">#{value}</expression></field></query></queryxml>]]></sXML>") AutotaskRuby::QueryResponse.new(@client, result) end |