Class: Account

cox-chapi.Account

new Account(api_keyopt)

Parameters:
Name Type Attributes Description
api_key string <optional>
Source:

Methods

create(account, cb)

Creates an account from the json object
Parameters:
Name Type Description
account object an object specifying fields for the new account
cb objectCallback called with the new account
Source:

destroy(id, cb)

Deletes the account with the specified id
Parameters:
Name Type Description
id number the id of the account
cb stringCallback called with a success message
Source:

find_by(field, value, listopt, cb)

gets accounts such that field matches the value
Parameters:
Name Type Attributes Description
field string the name of the field to search by
value string the value to match
list Array <optional>
an optional array of accounts to search (if given, the search will not make http requests, improving speed)
cb arrayCallback called with an array containing the matching accounts
Source:

get(id, cb)

gets a JSON object containing data for a single account
Parameters:
Name Type Description
id number the id of the account
cb objectCallback called with the account
Source:

list(flagsopt, cb)

gets a JSON object containing all the accounts
Parameters:
Name Type Attributes Description
flags object <optional>
an object specifying the following options
Properties
Name Type Attributes Description
page number <optional>
the page number of the page to get
page_count number <optional>
the number of accounts to list per page
all boolean <optional>
if true, return complete list (all pages) but this may take longer
stats boolean <optional>
if true, the page count, number of entries per page, and number of pages will be given in an object rather than the array of accounts
cb arrayCallback called with an array of accounts
Source:

set_api_key(api_key)

sets the api key to use when making calls to CloudHealth's API
Parameters:
Name Type Description
api_key string
Source:

update(account, cb)

Updates fields for the account with the specified id to match the given object
Parameters:
Name Type Description
account object an object specifying fields with updated values
Properties
Name Type Description
id number the id of the account
cb objectCallback called with the updated account
Source: