class FreeAgent::InvoicesResource
Public Instance Methods
convert_to_credit_note(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 78 def convert_to_credit_note(id:) response = put_request("invoices/#{id}/transitions/convert_to_credit_note", body: {}) response.success? end
create(contact:, dated_on:, payment_terms_in_days: 0, **params)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 30 def create(contact:, dated_on:, payment_terms_in_days: 0, **params) attributes = {contact: contact, dated_on: dated_on, payment_terms_in_days: payment_terms_in_days} response = post_request("invoices", body: {invoice: attributes.merge(params)}) Invoice.new(response.body["invoice"]) if response.success? end
delete(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 47 def delete(id:) response = delete_request("invoices/#{id}") response.success? end
direct_debit(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 83 def direct_debit(id:) response = post_request("invoices/#{id}/direct_debit", body: {}) response.success? end
duplicate(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 37 def duplicate(id:) response = post_request("invoices/#{id}/duplicate", body: {}) Invoice.new(response.body["invoice"]) if response.success? end
email(id:, to:, **params)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 52 def email(id:, to:, **params) attributes = {to: to} response = post_request("invoices/#{id}/send_email", body: {invoice: {email: attributes.merge(params)}}) response.success? end
list(**params)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 4 def list(**params) response = get_request("invoices", params: params) Collection.from_response(response, type: Invoice, key: "invoices") end
list_for_contact(contact:, **params)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 9 def list_for_contact(contact:, **params) response = get_request("invoices?contact=#{contact}", params: params) Collection.from_response(response, type: Invoice, key: "invoices") end
list_for_project(project:, **params)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 14 def list_for_project(project:, **params) response = get_request("invoices?project=#{project}", params: params) Collection.from_response(response, type: Invoice, key: "invoices") end
mark_as_cancelled(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 73 def mark_as_cancelled(id:) response = put_request("invoices/#{id}/transitions/mark_as_cancelled", body: {}) response.success? end
mark_as_draft(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 68 def mark_as_draft(id:) response = put_request("invoices/#{id}/transitions/mark_as_draft", body: {}) response.success? end
mark_as_scheduled(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 63 def mark_as_scheduled(id:) response = put_request("invoices/#{id}/transitions/mark_as_scheduled", body: {}) response.success? end
mark_as_sent(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 58 def mark_as_sent(id:) response = put_request("invoices/#{id}/transitions/mark_as_sent", body: {}) response.success? end
retrieve(id:)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 19 def retrieve(id:) response = get_request("invoices/#{id}") Invoice.new(response.body["invoice"]) end
retrieve_pdf(id:)
click to toggle source
Returns a Base64-encoded PDF
# File lib/free_agent/resources/invoices.rb, line 25 def retrieve_pdf(id:) response = get_request("invoices/#{id}/pdf") response.body["pdf"]["content"] if response.success? end
update(id:, **params)
click to toggle source
# File lib/free_agent/resources/invoices.rb, line 42 def update(id:, **params) response = put_request("invoices/#{id}", body: {invoice: params}) Invoice.new(response.body["invoice"]) if response.success? end