Class: Harvest::API::InvoiceMessages
- Includes:
- Behavior::Crud
- Defined in:
- lib/harvest/api/invoice_messages.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #all(invoice) ⇒ Object
- #create(message) ⇒ Object
- #delete(message) ⇒ Object
- #find(invoice, message) ⇒ Object
-
#mark_as_closed(message) ⇒ Harvest::InvoiceMessage
Create a message and mark an open invoice as closed (writing an invoice off).
-
#mark_as_draft(message) ⇒ Harvest::InvoiceMessage
Create a message for marking an open invoice as draft.
-
#mark_as_sent(message) ⇒ Harvest::InvoiceMessage
Create a message for marking an invoice as sent.
-
#re_open(message) ⇒ Harvest::InvoiceMessage
Create a message and mark a closed (written-off) invoice as open.
Methods included from Behavior::Crud
Methods inherited from Base
Constructor Details
This class inherits a constructor from Harvest::API::Base
Instance Method Details
#all(invoice) ⇒ Object
7 8 9 10 |
# File 'lib/harvest/api/invoice_messages.rb', line 7 def all(invoice) response = request(:get, credentials, "/invoices/#{invoice.to_i}/messages") api_model.parse(response.parsed_response) end |
#create(message) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/harvest/api/invoice_messages.rb', line 17 def create() = api_model.wrap() response = request(:post, credentials, "/invoices/#{message.invoice_id}/messages", :body => .to_json) id = response.headers["location"].match(/\/.*\/(\d+)\/.*\/(\d+)/)[2] find(.invoice_id, id) end |
#delete(message) ⇒ Object
24 25 26 27 |
# File 'lib/harvest/api/invoice_messages.rb', line 24 def delete() request(:delete, credentials, "/invoices/#{message.invoice_id}/messages/#{message.to_i}") .id end |
#find(invoice, message) ⇒ Object
12 13 14 15 |
# File 'lib/harvest/api/invoice_messages.rb', line 12 def find(invoice, ) response = request(:get, credentials, "/invoices/#{invoice.to_i}/messages/#{message.to_i}") api_model.parse(response.parsed_response).first end |
#mark_as_closed(message) ⇒ Harvest::InvoiceMessage
Create a message and mark an open invoice as closed (writing an invoice off)
41 42 43 |
# File 'lib/harvest/api/invoice_messages.rb', line 41 def mark_as_closed() (, 'mark_as_closed') end |
#mark_as_draft(message) ⇒ Harvest::InvoiceMessage
Create a message for marking an open invoice as draft
57 58 59 |
# File 'lib/harvest/api/invoice_messages.rb', line 57 def mark_as_draft() (, 'mark_as_draft') end |
#mark_as_sent(message) ⇒ Harvest::InvoiceMessage
Create a message for marking an invoice as sent.
33 34 35 |
# File 'lib/harvest/api/invoice_messages.rb', line 33 def mark_as_sent() (, 'mark_as_sent') end |
#re_open(message) ⇒ Harvest::InvoiceMessage
Create a message and mark a closed (written-off) invoice as open
49 50 51 |
# File 'lib/harvest/api/invoice_messages.rb', line 49 def re_open() (, 're_open') end |