lib/economic/invoices/booked_repo.rb in economic-rest-0.4.4 vs lib/economic/invoices/booked_repo.rb in economic-rest-0.4.6
- old
+ new
@@ -1,22 +1,23 @@
module Economic
module Invoices
class BookedRepo < Economic::Invoices::Repo
class << self
- def send(invoice)
- response = send_request(method: :post, url: URI.escape(endpoint_url), payload: payload(invoice))
+ def send(invoice, book_with_number: nil)
+ response = send_request(method: :post, url: URI.escape(endpoint_url), payload: payload(invoice, book_with_number: book_with_number))
entry_hash = JSON.parse(response.body)
invoice.class.new(entry_hash)
end
private
- def payload(invoice)
- {
- draftInvoice: invoice.to_h,
- }.to_json
+ def payload(invoice, book_with_number: nil)
+ payload = {draftInvoice: invoice.to_h}
+ payload = payload.merge({bookWithNumber: book_with_number}) unless book_with_number.nil?
+
+ payload.to_json
end
end
end
end
end