Class: Quickeebooks::Windows::Service::SalesReceipt
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- Quickeebooks::Windows::Service::SalesReceipt
- Defined in:
- lib/quickeebooks/windows/service/sales_receipt.rb
Constant Summary
Constants inherited from ServiceBase
Quickeebooks::Windows::Service::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
- #create(sales_receipt) ⇒ Object
- #fetch_by_id(id, idDomain = 'QB', options = {}) ⇒ Object
- #list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object
- #update(sales_receipt) ⇒ 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(sales_receipt) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/quickeebooks/windows/service/sales_receipt.rb', line 21 def create(sales_receipt) raise InvalidModelException unless sales_receipt.valid_for_create? # XML is a wrapped 'object' where the type is specified as an attribute # <Object xsi:type="Invoice"> xml_node = sales_receipt.to_xml(:name => 'Object') xml_node.set_attribute('xsi:type', 'SalesReceipt') xml = Quickeebooks::Shared::Service::OperationNode.new.add do |content| content << "<ExternalRealmId>#{self.realm_id}</ExternalRealmId>#{xml_node}" end perform_write(Quickeebooks::Windows::Model::SalesReceipt, xml) end |
#fetch_by_id(id, idDomain = 'QB', options = {}) ⇒ Object
16 17 18 19 |
# File 'lib/quickeebooks/windows/service/sales_receipt.rb', line 16 def fetch_by_id(id, idDomain = 'QB', = {}) url = "#{url_for_resource(Quickeebooks::Windows::Model::SalesReceipt::REST_RESOURCE)}/#{id}" fetch_object(Quickeebooks::Windows::Model::SalesReceipt, url, {:idDomain => idDomain}) end |
#list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object
11 12 13 14 |
# File 'lib/quickeebooks/windows/service/sales_receipt.rb', line 11 def list(filters = [], page = 1, per_page = 20, sort = nil, = {}) filters << Quickeebooks::Shared::Service::Filter.new(:boolean, :field => 'CustomFieldEnable', :value => true) fetch_collection(Quickeebooks::Windows::Model::SalesReceipt, nil, filters, page, per_page, sort, ) end |
#update(sales_receipt) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/quickeebooks/windows/service/sales_receipt.rb', line 34 def update(sales_receipt) # XML is a wrapped 'object' where the type is specified as an attribute # <Object xsi:type="Invoice"> # Intuit requires that some fields are unset / do not exist. sales_receipt. = nil sales_receipt.external_key = nil xml_node = sales_receipt.to_xml(:name => 'Object') xml_node.set_attribute('xsi:type', 'SalesReceipt') xml = Quickeebooks::Shared::Service::OperationNode.new.mod do |content| content << "<ExternalRealmId>#{self.realm_id}</ExternalRealmId> #{xml_node}" end perform_write(Quickeebooks::Windows::Model::SalesReceipt, xml) end |