Method: Invoicexpress::Client::Clients#create_client

Defined in:
lib/invoicexpress/client/clients.rb

#create_client(client, options = {}) ⇒ Invoicexpress::Models::Client

Creates a new client.

Parameters:

Returns:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::UnprocessableEntity When there are errors on the submission



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/invoicexpress/client/clients.rb', line 26

def create_client(client, options={})
  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(options))
end