Class: Quickeebooks::Windows::Service::Item
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- Quickeebooks::Windows::Service::Item
- Defined in:
- lib/quickeebooks/windows/service/item.rb
Constant Summary
Constants inherited from ServiceBase
Instance Attribute Summary
Attributes inherited from ServiceBase
#base_uri, #last_response_body, #last_response_xml, #oauth, #realm_id
Instance Method Summary collapse
- #create(item) ⇒ Object
- #fetch_by_id(id, idDomain = 'QB', options = {}) ⇒ Object
- #list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object
Methods inherited from ServiceBase
#access_token=, #enforce_filter_order, #initialize, #url_for_base, #url_for_resource
Methods included from Logging
Constructor Details
This class inherits a constructor from Quickeebooks::Windows::Service::ServiceBase
Instance Method Details
#create(item) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/quickeebooks/windows/service/item.rb', line 24 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 = Quickeebooks::Shared::Service::OperationNode.new.add do |content| content << "<ExternalRealmId>#{self.realm_id}</ExternalRealmId>#{xml_node}" end perform_write(Quickeebooks::Windows::Model::Item, xml) end |
#fetch_by_id(id, idDomain = 'QB', options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/quickeebooks/windows/service/item.rb', line 19 def fetch_by_id(id, idDomain = 'QB', = {}) url = "#{url_for_resource(Quickeebooks::Windows::Model::Item::REST_RESOURCE)}/#{id}" fetch_object(Quickeebooks::Windows::Model::Item, url, {:idDomain => idDomain}) end |
#list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/quickeebooks/windows/service/item.rb', line 9 def list(filters = [], page = 1, per_page = 20, sort = nil, = {}) filters << Quickeebooks::Shared::Service::Filter.new(:boolean, :field => 'CustomFieldEnable', :value => true) if [:custom_field_query] custom_field_query = [:custom_field_query] else custom_field_query = nil end fetch_collection(Quickeebooks::Windows::Model::Item, custom_field_query, filters, page, per_page, sort, ) end |