Module: Invoicexpress::Client::Clients
- Included in:
- Invoicexpress::Client
- Defined in:
- lib/invoicexpress/client/clients.rb
Instance Method Summary collapse
-
#client(client_id, options = {}) ⇒ Invoicexpress::Models::Client
Returns a specific client.
-
#client_by_code(client_code, options = {}) ⇒ Invoicexpress::Models::Client
Use this method to obtain a client by your code.
-
#client_by_name(client_name, options = {}) ⇒ Invoicexpress::Models::Client
Use this method to obtain a client by name.
-
#client_create_cash_invoice(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::CashInvoice
This method allows you to create a new cash invoice for a specific client.
-
#client_create_credit_note(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::CreditNote
This method allows you to create a new Credit Note for a specific client.
-
#client_create_debit_note(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::DebitNote
This method allows you to create a new Debit Note for a specific client.
-
#client_create_invoice(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::Invoice
This method allows you to create a new invoice for a specific client.
-
#client_invoices(client_id, filter = Invoicexpress::Models::Filter.new, options = {}) ⇒ Invoicexpress::Models::ClientInvoices
This method allows you to obtain the invoices for a specific client.
-
#clients(options = {}) ⇒ Array<Invoicexpress::Models::Client>
Returns all your clients.
-
#create_client(client, options = {}) ⇒ Invoicexpress::Models::Client
Creates a new client.
-
#update_client(client, options = {}) ⇒ Invoicexpress::Models::Client
Updates a client.
Instance Method Details
#client(client_id, options = {}) ⇒ Invoicexpress::Models::Client
Returns a specific client
66 67 68 69 70 |
# File 'lib/invoicexpress/client/clients.rb', line 66 def client(client_id, ={}) params = { :klass => Invoicexpress::Models::Client } get("clients/#{client_id.to_s}.xml", params.merge()) end |
#client_by_code(client_code, options = {}) ⇒ Invoicexpress::Models::Client
Use this method to obtain a client by your code. Partial searches are not supported
116 117 118 119 120 121 122 123 |
# File 'lib/invoicexpress/client/clients.rb', line 116 def client_by_code(client_code, ={}) params = { :klass => Invoicexpress::Models::Client, :client_code => client_code } get("clients/find-by-code.xml", params.merge()) end |
#client_by_name(client_name, options = {}) ⇒ Invoicexpress::Models::Client
Use this method to obtain a client by name. Partial searches are not supported
101 102 103 104 105 106 107 108 |
# File 'lib/invoicexpress/client/clients.rb', line 101 def client_by_name(client_name, ={}) params = { :klass => Invoicexpress::Models::Client, :client_name => client_name } get("clients/find-by-name.xml", params.merge()) end |
#client_create_cash_invoice(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::CashInvoice
This method allows you to create a new cash invoice for a specific client. When creating the invoice:
-
If items do not exist with the given names, new ones will be created.
-
If item name already exists, the item is updated with the new values.
Regarding item taxes, if the tax name is not found, no tax is applied to that item.
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/invoicexpress/client/clients.rb', line 158 def client_create_cash_invoice(client_id, invoice, ={}) raise(ArgumentError, "invoice has the wrong type") unless invoice.is_a?(Invoicexpress::Models::CashInvoice) params = { :klass => Invoicexpress::Models::CashInvoice, :body => invoice } post("clients/#{client_id}/create/cash-invoice.xml", params.merge()) end |
#client_create_credit_note(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::CreditNote
This method allows you to create a new Credit Note for a specific client. When creating the invoice:
-
If items do not exist with the given names, new ones will be created.
-
If item name already exists, the item is updated with the new values.
Regarding item taxes, if the tax name is not found, no tax is applied to that item.
180 181 182 183 184 185 186 187 188 189 |
# File 'lib/invoicexpress/client/clients.rb', line 180 def client_create_credit_note(client_id, invoice, ={}) raise(ArgumentError, "credit note has the wrong type") unless invoice.is_a?(Invoicexpress::Models::CreditNote) params = { :klass => Invoicexpress::Models::CreditNote, :body => invoice } post("clients/#{client_id}/create/credit-note.xml", params.merge()) end |
#client_create_debit_note(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::DebitNote
This method allows you to create a new Debit Note for a specific client. When creating the invoice:
-
If items do not exist with the given names, new ones will be created.
-
If item name already exists, the item is updated with the new values.
Regarding item taxes, if the tax name is not found, no tax is applied to that item.
202 203 204 205 206 207 208 209 210 211 |
# File 'lib/invoicexpress/client/clients.rb', line 202 def client_create_debit_note(client_id, invoice, ={}) raise(ArgumentError, "debit note has the wrong type") unless invoice.is_a?(Invoicexpress::Models::DebitNote) params = { :klass => Invoicexpress::Models::DebitNote, :body => invoice } post("clients/#{client_id}/create/debit-note.xml", params.merge()) end |
#client_create_invoice(client_id, invoice, options = {}) ⇒ Invoicexpress::Models::Invoice
This method allows you to create a new invoice for a specific client. When creating the invoice:
-
If items do not exist with the given names, new ones will be created.
-
If item name already exists, the item is updated with the new values.
Regarding item taxes, if the tax name is not found, no tax is applied to that item.
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/invoicexpress/client/clients.rb', line 136 def client_create_invoice(client_id, invoice, ={}) raise(ArgumentError, "invoice has the wrong type") unless invoice.is_a?(Invoicexpress::Models::Invoice) params = { :klass => Invoicexpress::Models::Invoice, :body => invoice } post("clients/#{client_id}/create/invoice.xml", params.merge()) end |
#client_invoices(client_id, filter = Invoicexpress::Models::Filter.new, options = {}) ⇒ Invoicexpress::Models::ClientInvoices
This method allows you to obtain the invoices for a specific client. Allowing filtering aswell.
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/invoicexpress/client/clients.rb', line 82 def client_invoices(client_id, filter=Invoicexpress::Models::Filter.new, ={}) raise(ArgumentError, "filter has the wrong type") unless filter.is_a?(Invoicexpress::Models::Filter) params = { :klass => Invoicexpress::Models::ClientInvoices, :per_page => 10, :page => 1, :body => filter } post("clients/#{client_id.to_s}/invoices.xml", params.merge()) end |
#clients(options = {}) ⇒ Array<Invoicexpress::Models::Client>
Returns all your clients
14 15 16 17 18 |
# File 'lib/invoicexpress/client/clients.rb', line 14 def clients(={}) params = { :per_page => 30, :page => 1, :klass => Invoicexpress::Models::Client } get("clients.xml", params.merge()) end |
#create_client(client, options = {}) ⇒ Invoicexpress::Models::Client
Creates a new client.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/invoicexpress/client/clients.rb', line 26 def create_client(client, ={}) if !client || !client.is_a?(Invoicexpress::Models::Client) raise ArgumentError, "Need a Invoicexpress::Models::Client instance" end if !client.name raise ArgumentError, "Client's name is required" end params = { :body => client, :klass => Invoicexpress::Models::Client } post("clients.xml", params.merge()) end |
#update_client(client, options = {}) ⇒ Invoicexpress::Models::Client
Updates a client.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/invoicexpress/client/clients.rb', line 46 def update_client(client, ={}) if !client || !client.is_a?(Invoicexpress::Models::Client) raise ArgumentError, "Need a Invoicexpress::Models::Client instance" end if !client.id raise ArgumentError, "Client's ID is required" end params = { :body => client, :klass => Invoicexpress::Models::Client } put("clients/#{client.id.to_s}.xml", params.merge()) end |