Module: Invoicexpress::Client::Users

Included in:
Invoicexpress::Client
Defined in:
lib/invoicexpress/client/users.rb

Instance Method Summary collapse

Instance Method Details

#accounts(options = {}) ⇒ Array<Invoicexpress::Models::Account>

This method allows you to view your accounts.

Returns:

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized



27
28
29
30
# File 'lib/invoicexpress/client/users.rb', line 27

def accounts(options = {})
  params = { :klass => Invoicexpress::Models::Account }
  get("users/accounts.xml", params.merge(options))
end

#change_account(account_id, options = {}) ⇒ Object

Changes the current account to the account id submitte

Parameters:

  • account_id (String)

    The account ID to change to

Raises:

  • Invoicexpress::Unauthorized When the client is unauthorized

  • Invoicexpress::NotFound When the account doesn’t exist



37
38
39
40
41
42
43
44
# File 'lib/invoicexpress/client/users.rb', line 37

def (, options={})
   = Invoicexpress::Models::ChangeAccountTo.new(
    :id => 
  )

  params = { :klass => Invoicexpress::Models::Account, :body =>  }
  put("users/change-account.xml", params.merge(options))
end

#login(login, password, options = {}) ⇒ Array<Invoicexpress::Models::Account>

This endpoint does not require an API KEY to be acessible. Instead it requires your current login and password. Upon successful login it will return all the accounts which belong to you

Parameters:

  • login (String)

    Login email

  • password (String)

    Your password

Returns:

Raises:

  • Invoicexpress::Unauthorized When the login/password combination is wrong



13
14
15
16
17
18
19
20
21
# File 'lib/invoicexpress/client/users.rb', line 13

def (, password, options={})
  credentials = Invoicexpress::Models::Credentials.new(
    :login => ,
    :password => password
  )

  params = { :klass => Invoicexpress::Models::Account, :body => credentials }
  post("login.xml", params.merge(options))
end