VuFind API Documentation

FakeOverdriveConnector extends OverdriveConnector
in package

FakeOverdriveConnector

Class responsible for simulating the Overdrive API for test purposes.

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$cache  : StorageInterface
Cache for storing ILS data temporarily (e.g. patron blocks)
$client  : Client
HTTP Client
$ilsAuth  : ILSAuthenticator
ILS Authorization
$mainConfig  : Config
Main VuFind configuration
$recordConfig  : Config
OverDrive-specific configuration
$sessionContainer  : Container
Session Container
__construct()  : mixed
Constructor
cancelHold()  : stdClass
Cancel Hold Cancel and existing Overdrive Hold
deleteHoldSuspension()  : stdClass
Delete Suspended Hold Removes the suspension from a hold
doOverdriveCheckout()  : object
Overdrive Checkout Processes a request to checkout a title from Overdrive
editSuspendedHold()  : stdClass
Edit Suspended Hold Change the redelivery date on an already suspended hold
getAccess()  : object
Get Overdrive Access
getAuthHeader()  : object
Retrieves the auth header needed to get the Download HTML snippet
getAvailability()  : object
Get Availability
getAvailabilityBulk()  : object|bool
Get Availability (in) Bulk
getCheckout()  : object|false
Get Overdrive Checkout
getCheckouts()  : object
Get Overdrive Checkouts (or a user)
getCollectionToken()  : object|bool
Get Collection Token
getConfig()  : bool|stdClass
Get Configuration Sets up a local copy of configurations for convenience
getDownloadRedirect()  : object
Get Download Redirect for an OverDrive Resource
getFormatNames()  : array<string|int, mixed>
Returns an array of OverDrive Formats and translation tokens
getHold()  : object|false
Get Overdrive Hold
getHolds()  : stdClass
Get Overdrive Holds (or a user)
getMagazineIssues()  : object
Returns all the issues for an overdrive magazine title
getMetadata()  : array<string|int, mixed>
Returns a hash of metadata keyed on overdrive reserveID
getMetadataForTitles()  : array<string|int, mixed>
For array of titles passed in this will return the same array with metadata attached to the records with the property name of 'metadata'
getPermanentLinks()  : array<string|int, string>
Returns permanant links for Ovedrive resources
getResultObject()  : object
Get Result Object
getUser()  : array<string|int, mixed>|bool
Get (Logged-in) User
placeOverDriveHold()  : stdClass
Places a hold on an item within OverDrive
returnResource()  : object|bool
Return Resource Return a title early.
setCacheStorage()  : void
Set a cache storage object.
suspendHold()  : stdClass
Suspend Hold Suspend an existing Overdrive Hold
updateOverDriveHold()  : stdClass
Updates the email address for a hold on an item within OverDrive
callPatronUrl()  : object|bool
Call a Patron URL on the API
callUrl()  : object|bool
Call a URL on the API
connectToAPI()  : string
Connect to API
connectToPatronAPI()  : object|bool
Connect to Patron API
debug()  : void
Log a debug message.
getCachedData()  : mixed|null
Helper function for fetching cached data.
getCacheKey()  : string
Method to ensure uniform cache keys for cached VuFind objects.
getHttpClient()  : Client
Get an HTTP client
getSessionContainer()  : Container
Loads the session container
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
putCachedData()  : void
Helper function for storing cached data.
removeCachedData()  : void
Helper function for removing cached data.

Properties

$cache

Cache for storing ILS data temporarily (e.g. patron blocks)

protected StorageInterface $cache = null

$client

HTTP Client

protected Client $client

Client for making calls to the API

Methods

__construct()

Constructor

public __construct(Config $mainConfig, Config $recordConfig) : mixed
Parameters
$mainConfig : Config

VuFind main conf

$recordConfig : Config

Record-specific conf file

Return values
mixed

cancelHold()

Cancel Hold Cancel and existing Overdrive Hold

public cancelHold(string $overDriveId) : stdClass
Parameters
$overDriveId : string

The overdrive id for the title

Return values
stdClass

Object with result

deleteHoldSuspension()

Delete Suspended Hold Removes the suspension from a hold

public deleteHoldSuspension(string $overDriveId) : stdClass
Parameters
$overDriveId : string

The overdrive id for the title

Return values
stdClass

Object with result

doOverdriveCheckout()

Overdrive Checkout Processes a request to checkout a title from Overdrive

public doOverdriveCheckout(string $overDriveId) : object
Parameters
$overDriveId : string

The overdrive id for the title

Return values
object

$result Results of the call.

editSuspendedHold()

Edit Suspended Hold Change the redelivery date on an already suspended hold

public editSuspendedHold(string $overDriveId, string $email[, string $suspensionType = 'indefinite' ][, int $numberOfDays = 7 ]) : stdClass
Parameters
$overDriveId : string

The overdrive id for the title

$email : string

The email overdrive should use for notif

$suspensionType : string = 'indefinite'

indefinite or limited

$numberOfDays : int = 7

number of days to suspend the hold

Return values
stdClass

Object with result

getAccess()

Get Overdrive Access

public getAccess([bool $refresh = false ]) : object

Whether the patron has access to overdrive actions (hold, checkout etc.). This is stored and retrieved from the session.

Parameters
$refresh : bool = false

Force a check instead of checking cache

Return values
object

getAuthHeader()

Retrieves the auth header needed to get the Download HTML snippet

public getAuthHeader() : object
Return values
object

Object containing the auth header in the data property

getAvailability()

Get Availability

public getAvailability(string $overDriveId) : object

Retrieves the availability for a single resource from Overdrive API with information like copiesOwned, copiesAvailable, numberOfHolds et.

Parameters
$overDriveId : string

The Overdrive ID (reserve ID) of the eResource

Tags
link
https://developer.overdrive.com/apis/library-availability-new
Return values
object

Standard object with availability info

getAvailabilityBulk()

Get Availability (in) Bulk

public getAvailabilityBulk([array<string|int, mixed> $overDriveIds = [] ]) : object|bool

Gets availability for up to 25 titles at once. This is used by the the ajax availability system

Parameters
$overDriveIds : array<string|int, mixed> = []

The Overdrive ID (reserve IDs) of the eResources

Return values
object|bool

see getAvailability

getCheckout()

Get Overdrive Checkout

public getCheckout(string $overDriveId[, bool $refresh = true ]) : object|false

Get the overdrive checkout object for an overdrive title for the current user

Parameters
$overDriveId : string

Overdrive resource id

$refresh : bool = true

Whether or not to ignore cache and get latest

Return values
object|false

PHP object that represents the checkout or false the checkout is not in the current list of checkouts for the current user.

getCheckouts()

Get Overdrive Checkouts (or a user)

public getCheckouts([bool $refresh = true ]) : object
Parameters
$refresh : bool = true

Whether or not to ignore cache and get latest

Return values
object

Results of the call

getCollectionToken()

Get Collection Token

public getCollectionToken() : object|bool

Gets the collection token for the Overdrive collection. The collection token doesn't change much but according to the OD API docs it could change and should be retrieved each session. Also, the collection token depends on the user if the user is in a consortium. If consortium support is turned on then the user collection token will override the library collection token. The token itself is returned but it's also saved in the session and automatically returned.

Return values
object|bool

A collection token for the library's collection.

getConfig()

Get Configuration Sets up a local copy of configurations for convenience

public getConfig() : bool|stdClass
Return values
bool|stdClass

getDownloadRedirect()

Get Download Redirect for an OverDrive Resource

public getDownloadRedirect(string $overDriveId) : object
Parameters
$overDriveId : string

OverDrive ID

Return values
object

Object with result. If successful, then data will have the download URI ($result->data->downloadRedirect)

getFormatNames()

Returns an array of OverDrive Formats and translation tokens

public getFormatNames() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHold()

Get Overdrive Hold

public getHold(string $overDriveId[, bool $refresh = true ]) : object|false

Get the overdrive hold object for an overdrive title for the current user

Parameters
$overDriveId : string

Overdrive resource id

$refresh : bool = true

Whether or not to ignore cache and get latest

Return values
object|false

PHP object that represents the checkout or false the checkout is not in the current list of checkouts for the current user.

getHolds()

Get Overdrive Holds (or a user)

public getHolds([bool $refresh = true ]) : stdClass
Parameters
$refresh : bool = true

Whether or not to ignore cache and get latest

Return values
stdClass

Results of the call

getMagazineIssues()

Returns all the issues for an overdrive magazine title

public getMagazineIssues([string $overDriveId = false ][, bool $checkouts = false ][, int $limit = 100 ], int $offset) : object
Parameters
$overDriveId : string = false

Overdrive Identifier for magazine title

$checkouts : bool = false

Whether to add checkout information to each issue

$limit : int = 100

maximum number of issues to retrieve (default 100)

$offset : int

page of results (default 0)

Return values
object

results of metadata fetch

getMetadata()

Returns a hash of metadata keyed on overdrive reserveID

public getMetadata([array<string|int, mixed> $overDriveIds = [] ]) : array<string|int, mixed>
Parameters
$overDriveIds : array<string|int, mixed> = []

Set of Overdrive IDs

Return values
array<string|int, mixed>

results of metadata fetch

getMetadataForTitles()

For array of titles passed in this will return the same array with metadata attached to the records with the property name of 'metadata'

public getMetadataForTitles([array<string|int, mixed> $overDriveTitles = [] ]) : array<string|int, mixed>
Parameters
$overDriveTitles : array<string|int, mixed> = []

Assoc array of objects with OD IDs as keys (generally what you get from getCheckouts and getHolds)

Return values
array<string|int, mixed>

initial array with results of metadata attached as "metadata" property

Returns permanant links for Ovedrive resources

public getPermanentLinks([array<string|int, mixed> $overDriveIds = [] ]) : array<string|int, string>
Parameters
$overDriveIds : array<string|int, mixed> = []

An array of overdrive IDs we need links for

Return values
array<string|int, string>

getResultObject()

Get Result Object

public getResultObject([bool $status = false ][, string $msg = '' ][, string $code = '' ]) : object
Parameters
$status : bool = false

Whether it succeeded

$msg : string = ''

More information

$code : string = ''

code used for end user display/translation

Return values
object

getUser()

Get (Logged-in) User

public getUser() : array<string|int, mixed>|bool

Returns the currently logged in user or false if the user is not

Return values
array<string|int, mixed>|bool

an array of user info from the ILSAuthenticator or false if user is not logged in.

placeOverDriveHold()

Places a hold on an item within OverDrive

public placeOverDriveHold(string $overDriveId, string $email) : stdClass
Parameters
$overDriveId : string

The overdrive id for the title

$email : string

The email overdrive should use for notif

Return values
stdClass

Object with result

returnResource()

Return Resource Return a title early.

public returnResource(string $resourceID) : object|bool
Parameters
$resourceID : string

Overdrive ID of the resource

Return values
object|bool

Object with result

setCacheStorage()

Set a cache storage object.

public setCacheStorage([StorageInterface $cache = null ]) : void
Parameters
$cache : StorageInterface = null

Cache storage interface

Return values
void

suspendHold()

Suspend Hold Suspend an existing Overdrive Hold

public suspendHold(string $overDriveId, string $email[, string $suspensionType = 'indefinite' ][, int $numberOfDays = 7 ]) : stdClass
Parameters
$overDriveId : string

The overdrive id for the title

$email : string

The email overdrive should use for notif

$suspensionType : string = 'indefinite'

indefinite or limited

$numberOfDays : int = 7

number of days to suspend the hold

Return values
stdClass

Object with result

updateOverDriveHold()

Updates the email address for a hold on an item within OverDrive

public updateOverDriveHold(string $overDriveId, string $email) : stdClass
Parameters
$overDriveId : string

The overdrive id for the title

$email : string

The email overdrive should use for notif

Return values
stdClass

Object with result

callPatronUrl()

Call a Patron URL on the API

protected callPatronUrl(string $patronBarcode, string $patronPin, string $url[, array<string|int, mixed> $params = null ][, string $requestType = 'GET' ][, string $returnType = 'json' ]) : object|bool

The patron URL is used for the circulation API's and requires a patron specific token.

Parameters
$patronBarcode : string

Patrons barcode

$patronPin : string

Patrons password

$url : string

The url to call

$params : array<string|int, mixed> = null

parameters to call

$requestType : string = 'GET'

HTTP request type (default=GET)

$returnType : string = 'json'

options are json(def),body,redirect

Return values
object|bool

The json response from the API call converted to an object. If body is specified, the raw body is returned. If redirect, then it returns the URL specified in the redirect header. If the call fails at the HTTP level then the error is logged and false is returned.

callUrl()

Call a URL on the API

protected callUrl(string $url[, array<string|int, mixed> $headers = null ][, bool $checkToken = true ][, string $requestType = 'GET' ]) : object|bool
Parameters
$url : string

The url to call

$headers : array<string|int, mixed> = null

Headers to set for the request. if null, then the auth headers are used.

$checkToken : bool = true

Whether to check and get a new token

$requestType : string = 'GET'

The request type (GET, POST etc)

Return values
object|bool

The json response from the API call converted to an object. If the call fails at the HTTP level then the error is logged and false is returned.

connectToAPI()

Connect to API

protected connectToAPI([bool $forceNewConnection = false ]) : string
Parameters
$forceNewConnection : bool = false

Force a new connection (get a new token)

Return values
string

token for the session or false if the token request failed

connectToPatronAPI()

Connect to Patron API

protected connectToPatronAPI(string $patronBarcode[, string $patronPin = '1234' ][, bool $forceNewConnection = false ]) : object|bool
Parameters
$patronBarcode : string

Patrons barcode

$patronPin : string = '1234'

Patrons password

$forceNewConnection : bool = false

force a new connection (get a new token)

Return values
object|bool

token for the session

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

getCachedData()

Helper function for fetching cached data.

protected getCachedData(string $key) : mixed|null

Data is cached for up to $this->cacheLifetime seconds so that it would be faster to process e.g. requests where multiple calls to the backend are made.

Parameters
$key : string

Cache entry key

Return values
mixed|null

Cached entry or null if not cached or expired

getCacheKey()

Method to ensure uniform cache keys for cached VuFind objects.

protected getCacheKey([string|null $suffix = null ]) : string
Parameters
$suffix : string|null = null

Optional suffix that will get appended to the object class name calling getCacheKey()

Return values
string

getHttpClient()

Get an HTTP client

protected getHttpClient([string $url = null ][, bool $allowRedirects = true ]) : Client
Parameters
$url : string = null

URL for client to use

$allowRedirects : bool = true

Whether to allow the client to follow redirects

Tags
throws
Exception
Return values
Client

getSessionContainer()

Loads the session container

protected getSessionContainer() : Container
Return values
Container

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

putCachedData()

Helper function for storing cached data.

protected putCachedData(string $key, mixed $entry) : void

Data is cached for up to $this->cacheLifetime seconds so that it would be faster to process e.g. requests where multiple calls to the backend are made.

Parameters
$key : string

Cache entry key

$entry : mixed

Entry to be cached

Return values
void

removeCachedData()

Helper function for removing cached data.

protected removeCachedData(string $key) : void
Parameters
$key : string

Cache entry key

Return values
void

Search results