Class ApiKeys
-
Model
-
AppModel
uses
Blesta\Core\Util\Common\Traits\Container
-
ApiKeys
Methods summary
public
|
#
__construct( )
Initialize the API Keys
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
- The API user
- $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 = ['date_created' => 'desc'] )
Returns a list of API keys
Returns a list of API keys
Parameters
- $page
- The page to fetch results on
- $order_by
- $order_by The sort and order conditions (e.g. ['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
- The ID of the key to fetch
Returns
mixed A stdClass object representing the API key, false if no such key exists
|
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
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
- The ID of the API key to edit
- $vars
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
- 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
- The variable to set the key into
- $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
- The user to be validated against the given company
- $company_id
- The company ID to validate uniqueness across
- $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
|
Methods inherited from AppModel
_(),
boolToInt(),
currencyToDecimal(),
dateToUtc(),
errors(),
getPerPage(),
ifSet(),
loadCrypto(),
setDefaultIfEmpty(),
setPerPage(),
setRulesIfSet(),
strToBool(),
systemDecrypt(),
systemEncrypt(),
systemHash(),
truncateDecimal(),
validateExists(),
validateStateCountry()
|