Class: Invoiced::Invoice
Instance Attribute Summary
Attributes inherited from Object
#client
Instance Method Summary
collapse
#delete
#save
#create
#list
Methods inherited from Object
#[], #[]=, #add_accessors, #each, #endpoint, #endpoint_base, #initialize, #inspect, #keys, #load, #metaclass, #method_missing, #refresh_from, #remove_accessors, #retrieve, #set_endpoint_base, #to_hash, #to_json, #to_s, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Invoiced::Object
Instance Method Details
#attachments(opts = {}) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/invoiced/invoice.rb', line 25
def attachments(opts={})
response = @client.request(:get, "#{self.endpoint()}/attachments", opts)
body = response[:body]
body.each do |attachment|
if !attachment.has_key?(:id)
attachment[:id] = attachment[:file][:id]
end
end
attachment = Attachment.new(@client)
attachments = Util.build_objects(attachment, body)
metadata = Invoiced::List.new(response[:headers][:link], response[:headers][:x_total_count])
return attachments, metadata
end
|
16
17
18
19
20
21
22
23
|
# File 'lib/invoiced/invoice.rb', line 16
def pay
response = @client.request(:post, "#{self.endpoint()}/pay")
refresh_from(response[:body].dup.merge({:id => self.id}))
return response[:code] == 200
end
|
#payment_plan(opts = {}) ⇒ Object
46
47
48
49
|
# File 'lib/invoiced/invoice.rb', line 46
def payment_plan(opts={})
paymentPlan = PaymentPlan.new(@client)
paymentPlan.set_endpoint_base(self.endpoint())
end
|
#send(opts = {}) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/invoiced/invoice.rb', line 8
def send(opts={})
response = @client.request(:post, "#{self.endpoint()}/emails", opts)
email = Email.new(@client)
Util.build_objects(email, response[:body])
end
|