Class: Harvest::API::InvoiceMessages
- Defined in:
- lib/harvest/api/invoice_messages.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #all(invoice, query = {}) ⇒ Object
- #create(invoice, invoice_message) ⇒ Object
- #delete(invoice, invoice_message) ⇒ Object
-
#mark_as_closed(invoice, invoice_message) ⇒ Harvest::InvoiceMessage
Create a message and mark an open invoice as closed (writing an invoice off).
-
#mark_as_draft(invoice_message) ⇒ Harvest::InvoiceMessage
Create a message for marking an open invoice as draft.
-
#mark_as_sent(invoice, invoice_message) ⇒ Harvest::InvoiceMessage
Create a message for marking an invoice as sent.
-
#re_open(invoice, invoice_message) ⇒ Harvest::InvoiceMessage
Create a message and mark a closed (written-off) invoice as open.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Harvest::API::Base
Instance Method Details
#all(invoice, query = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/harvest/api/invoice_messages.rb', line 6 def all(invoice, query = {}) response = request(:get, credentials, "/invoices/#{invoice.id}/messages", query: query) response_parsed = api_model.to_json(response.parsed_response) if response_parsed['total_pages'] > 1 counter = response_parsed['page'] while counter <= response_parsed['total_pages'] do counter += 1 query = { 'page' => counter } response_page = request(:get, credentials, "/invoices/#{invoice.id}/messages", query: query) = api_model.to_json(response.parsed_response) response_parsed['invoice_messages'] .concat(['invoice_messages']) end end api_model.parse(response_parsed) end |
#create(invoice, invoice_message) ⇒ Object
29 30 31 32 33 |
# File 'lib/harvest/api/invoice_messages.rb', line 29 def create(invoice, ) = api_model.wrap() response = request(:post, credentials, "/invoices/#{invoice.id}/messages", body: .to_json) find(.id) end |
#delete(invoice, invoice_message) ⇒ Object
35 36 37 38 |
# File 'lib/harvest/api/invoice_messages.rb', line 35 def delete(invoice, ) request(:delete, credentials, "/invoices/#{invoice.id}/messages/#{.id}") .id end |
#mark_as_closed(invoice, invoice_message) ⇒ Harvest::InvoiceMessage
Create a message and mark an open invoice as closed (writing an invoice off)
52 53 54 |
# File 'lib/harvest/api/invoice_messages.rb', line 52 def mark_as_closed(invoice, ) (invoice, , 'close') end |
#mark_as_draft(invoice_message) ⇒ Harvest::InvoiceMessage
Create a message for marking an open invoice as draft
68 69 70 |
# File 'lib/harvest/api/invoice_messages.rb', line 68 def mark_as_draft() (invoice, , 'draft') end |
#mark_as_sent(invoice, invoice_message) ⇒ Harvest::InvoiceMessage
Create a message for marking an invoice as sent.
44 45 46 |
# File 'lib/harvest/api/invoice_messages.rb', line 44 def mark_as_sent(invoice, ) (invoice, , 'send') end |
#re_open(invoice, invoice_message) ⇒ Harvest::InvoiceMessage
Create a message and mark a closed (written-off) invoice as open
60 61 62 |
# File 'lib/harvest/api/invoice_messages.rb', line 60 def re_open(invoice, ) (invoice, , 're-open') end |