Class: AutotaskApi::Query
- Inherits:
-
Object
- Object
- AutotaskApi::Query
- Defined in:
- lib/autotask_api/query.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#entity ⇒ Object
Returns the value of attribute entity.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(entity, condition = nil, client = AutotaskApi.client) ⇒ Query
constructor
A new instance of Query.
- #query_string ⇒ Object
Constructor Details
#initialize(entity, condition = nil, client = AutotaskApi.client) ⇒ Query
Returns a new instance of Query.
5 6 7 8 9 |
# File 'lib/autotask_api/query.rb', line 5 def initialize(entity, condition = nil, client = AutotaskApi.client) @entity = entity @client = client @condition = condition end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
3 4 5 |
# File 'lib/autotask_api/query.rb', line 3 def client @client end |
#condition ⇒ Object
Returns the value of attribute condition.
3 4 5 |
# File 'lib/autotask_api/query.rb', line 3 def condition @condition end |
#entity ⇒ Object
Returns the value of attribute entity.
3 4 5 |
# File 'lib/autotask_api/query.rb', line 3 def entity @entity end |
Instance Method Details
#fetch ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/autotask_api/query.rb', line 11 def fetch response = client.call :query, query_string result = response.body[:query_response][:query_result] if result[:return_code].to_i == -1 raise result[:errors][:atws_error][:message] else return result end end |
#query_string ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/autotask_api/query.rb', line 23 def query_string Nokogiri::XML::Builder.new do sXML do cdata( Nokogiri::XML::Builder.new do |xml| xml.queryxml do xml.entity entity xml.query do condition.to_xml(xml) end end end.doc.root ) end end.doc.root.to_s end |