Class: KashflowApi::Receipt
- Inherits:
-
SoapObject
- Object
- SoapObject
- KashflowApi::Receipt
- Defined in:
- lib/kashflow_api/models/receipt.rb
Instance Attribute Summary
Attributes inherited from SoapObject
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from SoapObject
build_from_soap, #initialize, #method_missing
Constructor Details
This class inherits a constructor from KashflowApi::SoapObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class KashflowApi::SoapObject
Class Method Details
.find(search) ⇒ Object
3 4 5 6 |
# File 'lib/kashflow_api/models/receipt.rb', line 3 def self.find(search) result = KashflowApi.api.get_receipt(search) self.build_from_soap(result.basic_hash["soap:Envelope"]["soap:Body"]["GetReceiptResponse"]["GetReceiptResult"]) end |
Instance Method Details
#save ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/kashflow_api/models/receipt.rb', line 8 def save if @hash["InvoiceDBID"] == "0" insert_receipt else update_receipt end end |
#to_xml ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kashflow_api/models/receipt.rb', line 16 def to_xml xml = [] id_line = "" @hash.keys.each do |key| if key == "InvoiceDBID" id_line = "<#{key}>#{@hash[key]}</#{key}>" unless @hash[key] == "0" else xml.push("<#{key}>#{@hash[key]}</#{key}>") end end [id_line, xml.join].join end |