class Harvest::API::InvoicePayments

Public Instance Methods

all(invoice) click to toggle source
# File lib/forecast/api/invoice_payments.rb, line 7
def all(invoice)
  response = request(:get, credentials, "/invoices/#{invoice.to_i}/payments")
  api_model.parse(response.parsed_response)
end
create(payment) click to toggle source
# File lib/forecast/api/invoice_payments.rb, line 17
def create(payment)
  payment = api_model.wrap(payment)
  response = request(:post, credentials, "/invoices/#{payment.invoice_id}/payments", :body => payment.to_json)
  id = response.headers["location"].match(/\/.*\/(\d+)\/.*\/(\d+)/)[2]
  find(payment.invoice_id, id)
end
delete(payment) click to toggle source
# File lib/forecast/api/invoice_payments.rb, line 24
def delete(payment)
  request(:delete, credentials, "/invoices/#{payment.invoice_id}/payments/#{payment.to_i}")
  payment.id
end
find(invoice, payment) click to toggle source
# File lib/forecast/api/invoice_payments.rb, line 12
def find(invoice, payment)
  response = request(:get, credentials, "/invoices/#{invoice.to_i}/payments/#{payment.to_i}")
  api_model.parse(response.parsed_response).first
end