Class: Invoiced::Customer

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

Constant Summary collapse

OBJECT_NAME =
'customer'

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, #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

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



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

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

    response[:body]
end

#consolidate_invoices(params = {}) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/invoiced/customer.rb', line 68

def consolidate_invoices(params={})
    response = @client.request(:post, "#{self.endpoint()}/consolidate_invoices", params)

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

#contactsObject



40
41
42
43
# File 'lib/invoiced/customer.rb', line 40

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

#invoice(params = {}, opts = {}) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/invoiced/customer.rb', line 60

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

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

#line_itemsObject



50
51
52
53
# File 'lib/invoiced/customer.rb', line 50

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

#list_notesObject



55
56
57
58
# File 'lib/invoiced/customer.rb', line 55

def list_notes()
    note = Note.new(@client)
    note.set_endpoint_base(self.endpoint())
end

#payment_sourcesObject



45
46
47
48
# File 'lib/invoiced/customer.rb', line 45

def payment_sources()
    source = PaymentSource.new(@client)
    source.set_endpoint_base(self.endpoint())
end

#send_statement(params = {}, opts = {}) ⇒ Object



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

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

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

#send_statement_letter(params = {}, opts = {}) ⇒ Object



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

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

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

#send_statement_sms(params = {}, opts = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/invoiced/customer.rb', line 18

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

    # build text message objects
    text_message = TextMessage.new(@client)
    Util.build_objects(text_message, response[:body])
end