Class: Quickeebooks::Windows::Service::Item

Inherits:
ServiceBase
  • Object
show all
Defined in:
lib/quickeebooks/windows/service/item.rb

Constant Summary

Constants inherited from ServiceBase

ServiceBase::XML_NS

Instance Attribute Summary

Attributes inherited from ServiceBase

#base_uri, #last_response_body, #last_response_xml, #oauth, #realm_id

Instance Method Summary collapse

Methods inherited from ServiceBase

#access_token=, #guid, #initialize, #url_for_base, #url_for_resource

Constructor Details

This class inherits a constructor from Quickeebooks::Windows::Service::ServiceBase

Instance Method Details

#create(item) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/quickeebooks/windows/service/item.rb', line 14

def create(item)
  # XML is a wrapped 'object' where the type is specified as an attribute
  #    <Object xsi:type="Item">
  xml_node = item.to_xml(:name => 'Object')
  xml_node.set_attribute('xsi:type', 'Item')
  xml = <<-XML
  <Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" RequestId="#{guid}" xmlns="http://www.intuit.com/sb/cdm/v2">
  <ExternalRealmId>#{self.realm_id}</ExternalRealmId>
  #{xml_node}
  </Add>
  XML
  perform_write(Quickeebooks::Windows::Model::Item, xml)
end

#list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object



9
10
11
12
# File 'lib/quickeebooks/windows/service/item.rb', line 9

def list(filters = [], page = 1, per_page = 20, sort = nil, options = {})
  custom_field_query = '<CustomFieldEnable>true</CustomFieldEnable>'
  fetch_collection(Quickeebooks::Windows::Model::Item, custom_field_query.strip, filters, page, per_page, sort, options)
end