Class: Harvest::API::InvoicePayments
- Inherits:
-
Base
- Object
- Base
- Harvest::API::InvoicePayments
show all
- Includes:
- Behavior::Crud
- Defined in:
- lib/harvest/api/invoice_payments.rb
Instance Attribute Summary
Attributes inherited from Base
#credentials
Instance Method Summary
(collapse)
#update
Methods inherited from Base
api_model, #initialize
Instance Method Details
- (Object) all(invoice)
7
8
9
10
|
# File 'lib/harvest/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
|
- (Object) create(payment)
17
18
19
20
21
22
|
# File 'lib/harvest/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.["location"].match(/\/.*\/(\d+)\/.*\/(\d+)/)[2]
find(payment.invoice_id, id)
end
|
- (Object) delete(payment)
24
25
26
27
|
# File 'lib/harvest/api/invoice_payments.rb', line 24
def delete(payment)
request(:delete, credentials, "/invoices/#{payment.invoice_id}/payments/#{payment.to_i}")
payment.id
end
|
- (Object) find(invoice, payment)
12
13
14
15
|
# File 'lib/harvest/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
|