Class: Invoiced::Invoice
Constant Summary
collapse
- OBJECT_NAME =
'invoice'
Instance Attribute Summary
Attributes inherited from Object
#client
Instance Method Summary
collapse
#delete
#save
#create
#list
Methods inherited from Object
#[], #[]=, #add_accessors, #build_endpoint, #each, #endpoint, #endpoint_base, #initialize, #inspect, #keys, #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(params = {}) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/invoiced/invoice.rb', line 44
def attachments(params={})
response = @client.request(:get, "#{self.endpoint()}/attachments", params)
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
|
70
71
72
73
|
# File 'lib/invoiced/invoice.rb', line 70
def notes()
note = Note.new(@client)
note.set_endpoint_base(self.endpoint())
end
|
#pay(opts = {}) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/invoiced/invoice.rb', line 35
def pay(opts={})
response = @client.request(:post, "#{self.endpoint()}/pay", {}, opts)
refresh_from(response[:body].dup.merge({:id => self.id}))
return response[:code] == 200
end
|
#payment_plan ⇒ Object
65
66
67
68
|
# File 'lib/invoiced/invoice.rb', line 65
def payment_plan()
paymentPlan = PaymentPlan.new(@client)
paymentPlan.set_endpoint_base(self.endpoint())
end
|
#send(params = {}, opts = {}) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/invoiced/invoice.rb', line 10
def send(params={}, opts={})
response = @client.request(:post, "#{self.endpoint()}/emails", params, opts)
email = Email.new(@client)
Util.build_objects(email, response[:body])
end
|
#send_letter(params = {}, opts = {}) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/invoiced/invoice.rb', line 26
def send_letter(params={}, opts={})
response = @client.request(:post, "#{self.endpoint()}/letters", params, opts)
letter = Letter.new(@client)
Util.build_objects(letter, response[:body])
end
|
#send_sms(params = {}, opts = {}) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/invoiced/invoice.rb', line 18
def send_sms(params={}, opts={})
response = @client.request(:post, "#{self.endpoint()}/text_messages", params, opts)
text_message = TextMessage.new(@client)
Util.build_objects(text_message, response[:body])
end
|
75
76
77
78
79
80
81
|
# File 'lib/invoiced/invoice.rb', line 75
def void()
response = @client.request(:post, "#{self.endpoint()}/void", {})
refresh_from(response[:body].dup.merge({:id => self.id}))
return response[:code] == 200
end
|