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
- #list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object
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(sales_receipt) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/quickeebooks/windows/service/sales_receipt.rb', line 19 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 = <<-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::SalesReceipt, xml) end |
#list(filters = [], page = 1, per_page = 20, sort = nil, options = {}) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/quickeebooks/windows/service/sales_receipt.rb', line 11 def list(filters = [], page = 1, per_page = 20, sort = nil, = {}) custom_field_query = '<?xml version="1.0" encoding="utf-8"?>' custom_field_query += '<SalesReceiptQuery xmlns="http://www.intuit.com/sb/cdm/v2">' custom_field_query += "<StartPage>#{page}</StartPage><ChunkSize>#{per_page}</ChunkSize>" custom_field_query += '<CustomFieldEnable>true</CustomFieldEnable></SalesReceiptQuery>' fetch_collection(Quickeebooks::Windows::Model::SalesReceipt, custom_field_query.strip, filters, page, per_page, sort, ) end |