Class ApiKeys
-
Model
-
AppModel
-
ApiKeys
Methods summary
public
|
#
__construct( )
The main app model constructor.
The main app model constructor.
Overrides
|
public
integer
|
#
auth( string $user, string $key )
Authenticates the given credentials and returns the company ID the API user
has access to.
Authenticates the given credentials and returns the company ID the API user
has access to.
Parameters
- $user
string $user The API user
- $key
string $key The API user's key
Returns
integer The ID of the company the user belongs to, void if the credentials are invalid.
Raises Input::errors() on error.
|
public
array
|
#
getList( integer $page = 1, array $order_by = array('date_created'=>"desc") )
Returns a list of API keys
Returns a list of API keys
Parameters
- $page
integer $page The page to fetch results on
- $order_by
array $order_by $order_by The sort and order conditions (e.g.
array('sort_field'=>"ASC"))
Returns
array An array of stdClass objects
|
public
integer
|
#
getListCount( )
Returns a count of the number of results in a list of API keys
Returns a count of the number of results in a list of API keys
Returns
integer The number of results in a list of API keys
|
public
mixed
|
#
get( integer $id )
Fetches the API key information for the given user
Fetches the API key information for the given user
Parameters
- $id
integer $id The ID of the key to fetch
Returns
mixed A stdClass object representing the API key, false if no such key exists
|
private
Record
|
#
keys( )
Builds a partial query to fetch a list of API keys
Builds a partial query to fetch a list of API keys
Returns
|
public
|
#
add( array $vars )
Adds a new API key for the given company ID and user.
Adds a new API key for the given company ID and user.
Parameters
- $vars
array $vars An array of API credential information including: -company_id The ID of
the company to add the API key for -user The user to use as the API user
|
public
|
#
edit( integer $id, array $vars )
Updates an API key
Parameters
- $id
integer $id The ID of the API key to edit
- $vars
array $var An array of API key data to update including: -notes Notes about this key
-user The username of the API key -company_id The ID of the company the API key
belongs to
|
public
|
#
delete( integer $id )
Permanently removes an API key
Permanently removes an API key
Parameters
- $id
integer $id The ID of the API key to delete
|
public
string
|
#
generateKey( string & $key, integer $company_id )
Generates an API key using the company ID as a seed. Not intended to be
invoked independently. See ApiKeys::add().
Generates an API key using the company ID as a seed. Not intended to be
invoked independently. See ApiKeys::add().
Parameters
- $key
string $key The variable to set the key into
- $company_id
integer $company_id The ID of the company to generate the key for
Returns
string The generated key for the given company ID
See
|
public
boolean
|
#
validateUniqueUser( string $user, integer $company_id, integer $api_id = null )
Validates the given user is unique across all API keys for the given
company
Validates the given user is unique across all API keys for the given
company
Parameters
- $user
string $user The user to be validated against the given company
- $company_id
integer $company_id The company ID to validate uniqueness across
- $api_id
integer $api_id The ID of the API key (if given) to exclude from the uniqueness test
Returns
boolean True if the user is unique for the given company (besides this $api_id), false
otherwise
|
private
array
|
#
getRules( array $vars )
Rules to validate when adding an API key
Rules to validate when adding an API key
Returns
array Rules to validate
|
Methods inherited from AppModel
_()
,
boolToInt()
,
currencyToDecimal()
,
dateToUtc()
,
errors()
,
getPerPage()
,
ifSet()
,
loadCrypto()
,
setDefaultIfEmpty()
,
setPerPage()
,
setRulesIfSet()
,
strToBool()
,
systemDecrypt()
,
systemEncrypt()
,
systemHash()
,
truncateDecimal()
,
validateExists()
,
validateStateCountry()
Methods inherited from Model
affectedRows()
,
begin()
,
commit()
,
getConnection()
,
lastInsertId()
,
makeDSN()
,
prepare()
,
query()
,
rollBack()
,
setAttribute()
,
setFetchMode()
Magic methods summary
Properties summary
Properties inherited from AppModel
$replacement_keys