GeniePlus
extends AbstractAPI
in package
GeniePlus API driver
Tags
Table of Contents
- $availableStatuses : array<string|int, string>
- Status messages indicating available items
- $config : array<string|int, mixed>
- Driver configuration
- $sessionCache : Container
- Session cache
- $sessionFactory : callable
- Factory function for constructing the SessionContainer.
- $token : string
- Access token
- __construct() : mixed
- Constructor
- getConfig() : array<string|int, mixed>
- Public Function which retrieves feature-specific settings from the driver ini file.
- getHolding() : mixed
- Get Holding
- getMyProfile() : array<string|int, mixed>
- Get Patron Profile
- getMyTransactions() : mixed
- Get Patron Transactions
- getPurchaseHistory() : mixed
- Get Purchase History
- getStatus() : mixed
- Get Status
- getStatuses() : mixed
- Get Statuses
- init() : void
- Initialize the driver.
- makeRequest() : Response
- Make requests
- patronLogin() : mixed
- Patron Login
- setConfig() : void
- Set configuration.
- apiStatusRecordToArray() : array<string|int, mixed>
- Extract holdings data from an API response. Return an array of arrays representing 852 fields (indexed by subfield code).
- callApiWithToken() : Response
- Call the API, with an access token added to the headers; renew token as needed.
- debug() : void
- Log a debug message.
- debugRequest() : void
- Function that obscures and logs debug data
- extractDisplayValues() : array<string|int, mixed>
- Extract display values from an API response field.
- failureCodeIsAllowed() : bool
- Does $code match the setting for allowed failure codes?
- getFieldFromApiRecord() : array<string|int, mixed>
- Extract a field from an API response.
- getTemplateQueryPath() : string
- Get the search path to query a template.
- log() : void
- Send a message to the logger.
- logError() : void
- Log an error message.
- logWarning() : void
- Log a warning message.
- preRequest() : array<string|int, mixed>
- Allow default corrections to all requests
- renewAccessToken() : void
- Renew the OAuth access token needed by the API.
- sanitizeQueryParam() : string
- Sanitize a value for inclusion as a single-quoted value in a query string.
- shouldRetryAfterUnexpectedStatusCode() : bool
- Support method for makeRequest to process an unexpected status code. Can return true to trigger a retry of the API call or false to throw an exception.
- throwAsIlsException() : never
- Rethrow the provided exception as an ILS exception.
- validateConfiguration() : void
- Support method for init(): make sure we have a valid configuration.
Properties
$availableStatuses
Status messages indicating available items
protected
array<string|int, string>
$availableStatuses
$config
Driver configuration
protected
array<string|int, mixed>
$config
= []
$sessionCache
Session cache
protected
Container
$sessionCache
$sessionFactory
Factory function for constructing the SessionContainer.
protected
callable
$sessionFactory
$token
Access token
protected
string
$token
= null
Methods
__construct()
Constructor
public
__construct(callable $sessionFactory) : mixed
Parameters
- $sessionFactory : callable
-
Factory function returning SessionContainer object
Return values
mixed —getConfig()
Public Function which retrieves feature-specific settings from the driver ini file.
public
getConfig(string $function[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $function : string
-
The name of the feature to be checked
- $params : array<string|int, mixed> = []
-
Optional feature-specific parameters (array)
Tags
Return values
array<string|int, mixed> —An array with key-value pairs.
getHolding()
Get Holding
public
getHolding(string $id[, array<string|int, mixed> $patron = null ][, array<string|int, mixed> $options = [] ]) : mixed
This is responsible for retrieving the holding information of a certain record.
Parameters
- $id : string
-
The record id to retrieve the holdings for
- $patron : array<string|int, mixed> = null
-
Patron data
- $options : array<string|int, mixed> = []
-
Extra options (not currently used)
Tags
Return values
mixed —On success, an associative array with the following keys: id, availability (boolean), status, location, reserve, callnumber, duedate, number, barcode.
getMyProfile()
Get Patron Profile
public
getMyProfile(array<string|int, mixed> $patron) : array<string|int, mixed>
This is responsible for retrieving the profile for a specific patron.
Parameters
- $patron : array<string|int, mixed>
-
The patron array
Return values
array<string|int, mixed> —Array of the patron's profile data on success.
getMyTransactions()
Get Patron Transactions
public
getMyTransactions(array<string|int, mixed> $patron[, array<string|int, mixed> $params = [] ]) : mixed
This is responsible for retrieving all transactions (i.e. checked out items) by a specific patron.
Parameters
- $patron : array<string|int, mixed>
-
The patron array from patronLogin
- $params : array<string|int, mixed> = []
-
Parameters
Return values
mixed —Array of the patron's transactions on success.
getPurchaseHistory()
Get Purchase History
public
getPurchaseHistory(string $id) : mixed
This is responsible for retrieving the acquisitions history data for the specific record (usually recently received issues of a serial).
Parameters
- $id : string
-
The record id to retrieve the info for
Tags
Return values
mixed —An array with the acquisitions data on success.
getStatus()
Get Status
public
getStatus(string $id) : mixed
This is responsible for retrieving the status information of a certain record.
Parameters
- $id : string
-
The record id to retrieve the holdings for
Return values
mixed —On success, an associative array with the following keys: id, availability (boolean), status, location, reserve, callnumber.
getStatuses()
Get Statuses
public
getStatuses(array<string|int, mixed> $ids) : mixed
This is responsible for retrieving the status information for a collection of records.
Parameters
- $ids : array<string|int, mixed>
-
The array of record ids to retrieve the status for
Return values
mixed —An array of getStatus() return values on success.
init()
Initialize the driver.
public
init() : void
Validate configuration and perform all resource-intensive tasks needed to make the driver active.
Return values
void —makeRequest()
Make requests
public
makeRequest([string $method = 'GET' ][, string $path = '/' ][, string|array<string|int, mixed> $params = [] ][, array<string|int, mixed> $headers = [] ][, true|array<string|int, int>|string $allowedFailureCodes = [] ][, string|array<string|int, mixed> $debugParams = null ][, int $attemptNumber = 1 ]) : Response
Parameters
- $method : string = 'GET'
-
GET/POST/PUT/DELETE/etc
- $path : string = '/'
-
API path (with a leading /)
- $params : string|array<string|int, mixed> = []
-
Query parameters
- $headers : array<string|int, mixed> = []
-
Additional headers
- $allowedFailureCodes : true|array<string|int, int>|string = []
-
HTTP failure codes that should NOT cause an ILSException to be thrown. May be an array of integers, a regular expression, or boolean true to allow all codes.
- $debugParams : string|array<string|int, mixed> = null
-
Value to use in place of $params in debug messages (useful for concealing sensitive data, etc.)
- $attemptNumber : int = 1
-
Counter to keep track of attempts (starts at 1 for the first attempt)
Tags
Return values
Response —patronLogin()
Patron Login
public
patronLogin(string $username, string $password) : mixed
This is responsible for authenticating a patron against the catalog.
Parameters
- $username : string
-
The patron username
- $password : string
-
The patron password
Tags
Return values
mixed —Associative array of patron info on successful login, null on unsuccessful login.
setConfig()
Set configuration.
public
setConfig(array<string|int, mixed> $config) : void
Set the configuration for the driver.
Parameters
- $config : array<string|int, mixed>
-
Configuration array (usually loaded from a VuFind .ini file whose name corresponds with the driver class name).
Return values
void —apiStatusRecordToArray()
Extract holdings data from an API response. Return an array of arrays representing 852 fields (indexed by subfield code).
protected
apiStatusRecordToArray(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
-
Record from API response
Return values
array<string|int, mixed> —callApiWithToken()
Call the API, with an access token added to the headers; renew token as needed.
protected
callApiWithToken([string $method = 'GET' ][, string $path = '/' ][, array<string|int, mixed> $params = [] ][, array<string|int, mixed> $headers = [] ]) : Response
Parameters
- $method : string = 'GET'
-
GET/POST/PUT/DELETE/etc
- $path : string = '/'
-
API path (with a leading /)
- $params : array<string|int, mixed> = []
-
Parameters object to be sent as data
- $headers : array<string|int, mixed> = []
-
Additional headers
Return values
Response —debug()
Log a debug message.
protected
debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —debugRequest()
Function that obscures and logs debug data
protected
debugRequest(string $method, string $path, array<string|int, mixed> $params, Headers $req_headers) : void
Parameters
- $method : string
-
Request method (GET/POST/PUT/DELETE/etc.)
- $path : string
-
Request URL
- $params : array<string|int, mixed>
-
Request parameters
- $req_headers : Headers
-
Headers object
Return values
void —extractDisplayValues()
Extract display values from an API response field.
protected
extractDisplayValues(array<string|int, mixed> $field) : array<string|int, mixed>
Parameters
- $field : array<string|int, mixed>
-
Array of values from API
Return values
array<string|int, mixed> —failureCodeIsAllowed()
Does $code match the setting for allowed failure codes?
protected
failureCodeIsAllowed(int $code, true|array<string|int, int>|string $allowedFailureCodes) : bool
Parameters
- $code : int
-
Code to check.
- $allowedFailureCodes : true|array<string|int, int>|string
-
HTTP failure codes that should NOT cause an ILSException to be thrown. May be an array of integers, a regular expression, or boolean true to allow all codes.
Return values
bool —getFieldFromApiRecord()
Extract a field from an API response.
protected
getFieldFromApiRecord(array<string|int, mixed> $record, string $field[, string $type = 'Item' ]) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
-
Record containing field
- $field : string
-
Name of field to extract
- $type : string = 'Item'
-
Type of field being looked up (e.g. Item, Patron)
Return values
array<string|int, mixed> —getTemplateQueryPath()
Get the search path to query a template.
protected
getTemplateQueryPath(string $template) : string
Parameters
- $template : string
-
Name of template to query
Return values
string —log()
Send a message to the logger.
protected
log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
- $level : string
-
Log level
- $message : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = false
-
Prepend class name to message?
Return values
void —logError()
Log an error message.
protected
logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —logWarning()
Log a warning message.
protected
logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
- $msg : string
-
Log message
- $context : array<string|int, mixed> = []
-
Log context
- $prependClass : bool = true
-
Prepend class name to message?
Return values
void —preRequest()
Allow default corrections to all requests
protected
preRequest(Headers $headers, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $headers : Headers
-
the request headers
- $params : array<string|int, mixed>
-
the parameters object
Return values
array<string|int, mixed> —renewAccessToken()
Renew the OAuth access token needed by the API.
protected
renewAccessToken() : void
Tags
Return values
void —sanitizeQueryParam()
Sanitize a value for inclusion as a single-quoted value in a query string.
protected
sanitizeQueryParam(string $value) : string
Parameters
- $value : string
-
Value to sanitize
Return values
string —Sanitized value
shouldRetryAfterUnexpectedStatusCode()
Support method for makeRequest to process an unexpected status code. Can return true to trigger a retry of the API call or false to throw an exception.
protected
shouldRetryAfterUnexpectedStatusCode(Response $response, int $attemptNumber) : bool
Parameters
- $response : Response
-
HTTP response
- $attemptNumber : int
-
Counter to keep track of attempts (starts at 1 for the first attempt)
Tags
Return values
bool —throwAsIlsException()
Rethrow the provided exception as an ILS exception.
protected
throwAsIlsException(Throwable $exception[, string $msg = null ]) : never
Parameters
- $exception : Throwable
-
Exception to rethrow
- $msg : string = null
-
Override exception message (optional)
Tags
Return values
never —validateConfiguration()
Support method for init(): make sure we have a valid configuration.
protected
validateConfiguration() : void