Class: Invoiced::Invoice
- Defined in:
- lib/invoiced/invoice.rb
Instance Attribute Summary
Attributes inherited from Object
Instance Method Summary collapse
Methods included from Operations::Delete
Methods included from Operations::Update
Methods included from Operations::Create
Methods included from Operations::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
Constructor Details
This class inherits a constructor from Invoiced::Object
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 (opts={}) response = @client.request(:get, "#{self.endpoint()}/attachments", opts) # ensure each attachment has an ID body = response[:body] body.each do || if !.has_key?(:id) [:id] = [:file][:id] end end # build objects = Attachment.new(@client) = Util.build_objects(, body) # store the metadata from the list operation = Invoiced::List.new(response[:headers][:link], response[:headers][:x_total_count]) return , end |
#pay ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/invoiced/invoice.rb', line 16 def pay response = @client.request(:post, "#{self.endpoint()}/pay") # update the local values with the response refresh_from(response[:body].dup.merge({:id => self.id})) return response[:code] == 200 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) # build email objects email = Email.new(@client) Util.build_objects(email, response[:body]) end |