Class: Quickeebooks::Online::Service::Invoice
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- Quickeebooks::Online::Service::Invoice
- Includes:
- ServiceCRUD
- Defined in:
- lib/quickeebooks/online/service/invoice.rb
Constant Summary
Constants inherited from ServiceBase
ServiceBase::QB_BASE_URI, ServiceBase::XML_NS
Instance Attribute Summary
Attributes inherited from ServiceBase
Instance Method Summary collapse
-
#invoice_as_pdf(invoice_id, destination_file_name) ⇒ Object
Returns the absolute path to the PDF on disk Its left to the caller to unlink the file at some later date Returns:
String
: absolute path to file on disk or nil if couldn’t fetch PDF.
Methods included from ServiceCRUD
#action_url, #create, #delete, #fetch_by_id, #list, #model, #update
Methods inherited from ServiceBase
#access_token=, #base_url=, #initialize, #login_name, #url_for_base, #url_for_resource
Methods included from Logging
Constructor Details
This class inherits a constructor from Quickeebooks::Online::Service::ServiceBase
Instance Method Details
#invoice_as_pdf(invoice_id, destination_file_name) ⇒ Object
Returns the absolute path to the PDF on disk Its left to the caller to unlink the file at some later date Returns: String
: absolute path to file on disk or nil if couldn’t fetch PDF
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/quickeebooks/online/service/invoice.rb', line 15 def invoice_as_pdf(invoice_id, destination_file_name) response = do_http_get("#{url_for_resource("invoice-document")}/#{invoice_id}", {}, {'Content-Type' => 'application/pdf'}) File.open(destination_file_name, "wb") do |file| file.write(response.body) end destination_file_name rescue => e log "Error downloading invoice id #{invoice_id} pdf file #{destination_file_name} with #{e}" nil end |