Class: Invoiced::Estimate
Constant Summary
collapse
- OBJECT_NAME =
'estimate'
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/invoiced/estimate.rb', line 26
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
|
#generate_invoice(params = {}, opts = {}) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/invoiced/estimate.rb', line 18
def generate_invoice(params={}, opts={})
response = @client.request(:post, "#{self.endpoint()}/invoice", params, opts)
invoice = Invoice.new(@client)
Util.convert_to_object(invoice, response[:body])
end
|
#send(params = {}, opts = {}) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/invoiced/estimate.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
|
47
48
49
50
51
52
53
|
# File 'lib/invoiced/estimate.rb', line 47
def void()
response = @client.request(:post, "#{self.endpoint()}/void", {})
refresh_from(response[:body].dup.merge({:id => self.id}))
return response[:code] == 200
end
|