Connector
extends Base
in package
implements
LoggerAwareInterface
Uses
LoggerAwareTrait, ConnectorCacheTrait
EBSCO EDS API Connector
Tags
Interfaces, Classes, Traits and Enums
- LoggerAwareInterface
Table of Contents
- $accept : string
- Accept header
- $apiHost : string
- EDS or EPF API host.
- $authHost : string
- Auth host
- $cache : StorageInterface
- Request cache
- $client : Client
- The HTTP Request object to execute EDS API transactions
- $contentType : string
- Content type header
- $orgId : string|null
- The organization id use for authentication
- $searchHttpMethod : string
- Search HTTP method
- $sessionHost : string
- Session host.
- __construct() : mixed
- Constructor
- authenticate() : array<string|int, mixed>
- Generate an authentication token with a valid EBSCO EDS Api account
- autocomplete() : array<string|int, mixed>
- Execute an EdsApi autocomplete
- createSession() : array<string|int, mixed>
- Creates a new session
- getCachedData() : mixed
- Get a request from cache if available
- getCacheKey() : string
- Create a cache key from client's request state
- info() : array<string|int, mixed>
- Obtain edsapi search criteria and application related settings
- retrieve() : array<string|int, mixed>
- Retrieves an EDS record specified by its identifiers
- retrieveEdsItem() : array<string|int, mixed>
- Retrieves an EDS record specified by its identifiers
- retrieveEpfItem() : array<string|int, mixed>
- Retrieves an EPF record specified by its identifiers
- search() : array<string|int, mixed>
- Execute an EdsApi search
- setCache() : void
- Set the cache storage
- call() : object
- Submit REST Request
- createQSFromArray() : array<string|int, mixed>
- Convert an array of search parameters to EDS API querystring parameters
- debug() : void
- Log a debug message.
- httpRequest() : string
- Perform an HTTP request.
- log() : void
- Send a message to the logger.
- logCacheDebug() : void
- Log a debug message
- logCacheWarning() : void
- Log a warning message
- logError() : void
- Log an error message.
- logWarning() : void
- Log a warning message.
- parseAutocomplete() : array<string|int, mixed>
- Parse autocomplete response from API in an array of terms
- process() : array<string|int, mixed>
- Process EDS API response message
- putCachedData() : void
- Cache response data.
- setTokens() : array<string|int, mixed>
- Populate an associative array of session and authentication parameters to send to the EDS API
Properties
$accept
Accept header
protected
string
$accept
= 'application/json'
$apiHost
EDS or EPF API host.
protected
string
$apiHost
$authHost
Auth host
protected
string
$authHost
= 'https://eds-api.ebscohost.com/authservice/rest'
$cache
Request cache
protected
StorageInterface
$cache
= null
$client
The HTTP Request object to execute EDS API transactions
protected
Client
$client
$contentType
Content type header
protected
string
$contentType
= 'application/json'
$orgId
The organization id use for authentication
protected
string|null
$orgId
$searchHttpMethod
Search HTTP method
protected
string
$searchHttpMethod
= 'POST'
$sessionHost
Session host.
protected
string
$sessionHost
= 'https://eds-api.ebscohost.com/edsapi/rest'
Methods
__construct()
Constructor
public
__construct(array<string|int, mixed> $settings, Client $client) : mixed
Sets up the EDS API Client
Parameters
- $settings : array<string|int, mixed>
-
Associative array of setting to use in conjunction with the EDS API
- debug - boolean to control debug mode
- orgid - Organization making calls to the EDS API
- timeout - HTTP timeout value (default = 120)
- $client : Client
-
HTTP client object
Return values
mixed —authenticate()
Generate an authentication token with a valid EBSCO EDS Api account
public
authenticate([string $username = null ][, string $password = null ][, string $orgid = null ][, array<string|int, mixed> $params = null ]) : array<string|int, mixed>
Parameters
- $username : string = null
-
username associated with an EBSCO EdsApi account
- $password : string = null
-
password associated with an EBSCO EdsApi account
- $orgid : string = null
-
Organization id the request is initiated from
- $params : array<string|int, mixed> = null
-
optional params (autocomplete)
Return values
array<string|int, mixed> —autocomplete()
Execute an EdsApi autocomplete
public
autocomplete(string $query, string $type, array<string|int, mixed> $data[, bool $raw = false ]) : array<string|int, mixed>
Parameters
- $query : string
-
Search term
- $type : string
-
Autocomplete type (e.g. 'rawqueries' or 'holdings')
- $data : array<string|int, mixed>
-
Autocomplete API details (from authenticating with 'autocomplete' option set -- requires token, custid and url keys).
- $raw : bool = false
-
Should we return the results raw (true) or processed (false)?
Return values
array<string|int, mixed> —An array of autocomplete terns as returned from the api
createSession()
Creates a new session
public
createSession([string $profile = null ][, string $isGuest = null ][, string $authToken = null ]) : array<string|int, mixed>
Parameters
- $profile : string = null
-
Profile to use
- $isGuest : string = null
-
Whether or not this session will be a guest session
- $authToken : string = null
-
Authentication token
Return values
array<string|int, mixed> —getCachedData()
Get a request from cache if available
public
getCachedData(string $key) : mixed
Parameters
- $key : string
-
Cache key
Return values
mixed —getCacheKey()
Create a cache key from client's request state
public
getCacheKey(Client $client) : string
Parameters
- $client : Client
-
HTTP Client
Return values
string —info()
Obtain edsapi search criteria and application related settings
public
info([string $authenticationToken = null ][, string $sessionToken = null ]) : array<string|int, mixed>
Parameters
- $authenticationToken : string = null
-
Authentication token
- $sessionToken : string = null
-
Session token
Return values
array<string|int, mixed> —retrieve()
Retrieves an EDS record specified by its identifiers
public
retrieve(string $an, string $dbId, string $authenticationToken, string $sessionToken[, string $highlightTerms = null ][, array<string|int, mixed> $extraQueryParams = [] ]) : array<string|int, mixed>
Parameters
- $an : string
-
An of the record to retrieve from the EdsApi
- $dbId : string
-
Database identifier of the record to retrieve from the EdsApi
- $authenticationToken : string
-
Authentication token
- $sessionToken : string
-
Session token
- $highlightTerms : string = null
-
Comma separated list of terms to highlight in the retrieved record responses
- $extraQueryParams : array<string|int, mixed> = []
-
Extra query string parameters
Tags
Return values
array<string|int, mixed> —The requested record
retrieveEdsItem()
Retrieves an EDS record specified by its identifiers
public
retrieveEdsItem(string $an, string $dbId, string $authenticationToken, string $sessionToken[, string $highlightTerms = null ][, array<string|int, mixed> $extraQueryParams = [] ]) : array<string|int, mixed>
Parameters
- $an : string
-
An of the record to retrieve from the EdsApi
- $dbId : string
-
Database identifier of the record to retrieve from the EdsApi
- $authenticationToken : string
-
Authentication token
- $sessionToken : string
-
Session token
- $highlightTerms : string = null
-
Comma separated list of terms to highlight in the retrieved record responses
- $extraQueryParams : array<string|int, mixed> = []
-
Extra query string parameters
Return values
array<string|int, mixed> —The requested record
retrieveEpfItem()
Retrieves an EPF record specified by its identifiers
public
retrieveEpfItem(string $pubId, string $authenticationToken, string $sessionToken) : array<string|int, mixed>
Parameters
- $pubId : string
-
Id of the record to retrieve from the EpfApi
- $authenticationToken : string
-
Authentication token
- $sessionToken : string
-
Session token
Return values
array<string|int, mixed> —The requested record
search()
Execute an EdsApi search
public
search(SearchRequestModel $query, string $authenticationToken, string $sessionToken) : array<string|int, mixed>
Parameters
- $query : SearchRequestModel
-
Search request object
- $authenticationToken : string
-
Authentication token
- $sessionToken : string
-
Session token
Return values
array<string|int, mixed> —An array of query results as returned from the api
setCache()
Set the cache storage
public
setCache(StorageInterface $cache) : void
Parameters
- $cache : StorageInterface
-
Cache
Return values
void —call()
Submit REST Request
protected
call(string $baseUrl, array<string|int, mixed> $headerParams[, array<string|int, mixed> $params = [] ][, string $method = 'GET' ][, string $message = null ][, string $messageFormat = '' ][, bool $cacheable = true ]) : object
Parameters
- $baseUrl : string
-
URL of service
- $headerParams : array<string|int, mixed>
-
An array of headers to add to the request
- $params : array<string|int, mixed> = []
-
An array of parameters for the request
- $method : string = 'GET'
-
The HTTP Method to use
- $message : string = null
-
Message to POST if $method is POST
- $messageFormat : string = ''
-
Format of request $messageBody and responses
- $cacheable : bool = true
-
Whether the request is cacheable
Tags
Return values
object —EDS API response (or an Error object).
createQSFromArray()
Convert an array of search parameters to EDS API querystring parameters
protected
createQSFromArray(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
Parameters to convert to querystring parameters
Return values
array<string|int, mixed> —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 —httpRequest()
Perform an HTTP request.
protected
httpRequest(string $baseUrl, string $method, string $queryString, array<string|int, mixed> $headers[, string $messageBody = null ][, string $messageFormat = 'application/json; charset=utf-8' ][, bool $cacheable = true ]) : string
Parameters
- $baseUrl : string
-
Base URL for request
- $method : string
-
HTTP method for request (GET,POST, etc.)
- $queryString : string
-
Query string to append to URL
- $headers : array<string|int, mixed>
-
HTTP headers to send
- $messageBody : string = null
-
Message body to for HTTP Request
- $messageFormat : string = 'application/json; charset=utf-8'
-
Format of request $messageBody and responses
- $cacheable : bool = true
-
Whether the request is cacheable
Tags
Return values
string —HTTP response body
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 —logCacheDebug()
Log a debug message
protected
logCacheDebug(string $msg) : void
Parameters
- $msg : string
-
Message
Return values
void —logCacheWarning()
Log a warning message
protected
logCacheWarning(string $msg) : void
Parameters
- $msg : string
-
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 —parseAutocomplete()
Parse autocomplete response from API in an array of terms
protected
parseAutocomplete(array<string|int, mixed> $msg) : array<string|int, mixed>
Parameters
- $msg : array<string|int, mixed>
-
Response from API
Return values
array<string|int, mixed> —of terms
process()
Process EDS API response message
protected
process(string $input) : array<string|int, mixed>
Parameters
- $input : string
-
The raw response from EDS API
Tags
Return values
array<string|int, mixed> —The processed response from EDS API
putCachedData()
Cache response data.
protected
putCachedData(string $key, mixed $response) : void
Parameters
- $key : string
-
Cache entry key
- $response : mixed
-
Response to be cached
Return values
void —setTokens()
Populate an associative array of session and authentication parameters to send to the EDS API
protected
setTokens([string $authenticationToken = null ][, string $sessionToken = null ]) : array<string|int, mixed>
Parameters
- $authenticationToken : string = null
-
Authentication token to add
- $sessionToken : string = null
-
Session token to add
Return values
array<string|int, mixed> —Associative array of header parameters to add.