Class: Invoiced::Customer

Inherits:
Object
  • Object
show all
Includes:
Operations::Create, Operations::Delete, Operations::List, Operations::Update
Defined in:
lib/invoiced/customer.rb

Instance Attribute Summary

Attributes inherited from Object

#client

Instance Method Summary collapse

Methods included from Operations::Delete

#delete

Methods included from Operations::Update

#save

Methods included from Operations::Create

#create

Methods included from Operations::List

#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

#balanceObject



16
17
18
19
20
# File 'lib/invoiced/customer.rb', line 16

def balance
	response = @client.request(:get, "#{self.endpoint()}/balance")

	response[:body]
end

#contacts(opts = {}) ⇒ Object



22
23
24
25
# File 'lib/invoiced/customer.rb', line 22

def contacts(opts={})
	contact = Contact.new(@client)
	contact.set_endpoint_base(self.endpoint())
end

#invoice(opts = {}) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/invoiced/customer.rb', line 32

def invoice(opts={})
	response = @client.request(:post, "#{self.endpoint()}/invoices", opts)

	# build invoice object
	invoice = Invoice.new(@client)
	Util.convert_to_object(invoice, response[:body])
end

#line_items(opts = {}) ⇒ Object



27
28
29
30
# File 'lib/invoiced/customer.rb', line 27

def line_items(opts={})
	line = LineItem.new(@client)
	line.set_endpoint_base(self.endpoint())
end

#send_statement(opts = {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/invoiced/customer.rb', line 8

def send_statement(opts={})
	response = @client.request(:post, "#{self.endpoint()}/emails", opts)

	# build email objects
	email = Email.new(@client)
	Util.build_objects(email, response[:body])
end