Class ApiKeys
	
	
		- 
			Model
			
			
			
		
- 
			 AppModel AppModel
- 
			 ApiKeys 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
						$userstring$user The API user
$keystring$key The API user's key
Returns
						integerThe 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
						$pageinteger$page The page to fetch results on
$order_byarray$order_by $order_by The sort and order conditions (e.g.
array('sort_field'=>"ASC"))
Returns
						arrayAn 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
						integerThe 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
						$idinteger$id The ID of the key to fetch
Returns
						mixedA 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
						$varsarray$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
						$idinteger$id The ID of the API key to edit
$varsarray$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
						$idinteger$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
						$keystring$key The variable to set the key into
$company_idinteger$company_id The ID of the company to generate the key for
Returns
						stringThe 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
						$userstring$user The user to be validated against the given company
$company_idinteger$company_id The company ID to validate uniqueness across
$api_idinteger$api_id The ID of the API key (if given) to exclude from the uniqueness test
Returns
						booleanTrue 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()
		
		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