Global

Methods

jsPAPI()

Source:

module:_buildSignature(method, url, pass) → {object}

Build polaris signature for authentication request header
Parameters:
Name Type Description
method string 'get' 'post' etc
url string endpoint being requested
pass string the user password or staff access secret
Source:
Requires:
  • module:crypto-js/hmac-sha1
  • module:crypto-js/enc-base64
Returns:
- with structure: { sig : 'generated signature', date: 'A RFC 1123 GMT Date' }
Type
object

module:_init(cfg) → {boolean}

Do initial setup stuff, for example reading config from .env and merging with custom params
Parameters:
Name Type Description
cfg object pass in any config values you want to override defaults
Source:
Returns:
- true for success, false for failure
Type
boolean

module:_log(dump) → {boolean}

Dumps input to console
Parameters:
Name Type Description
dump anything whatever you want to dump
Source:
Returns:
true if logging enabled, otherwise false
Type
boolean
Example
myPapi.bibSearchKW('dogs', 'KW').then(function(response){ });

module:_polarisDate() → {string}

Get date formated to RFC-1123.
Source:
Returns:
- RFC-1123 formatted date string
Type
string

module:authenticatePatron(barcode, password) → {promise}

Authenticates and returns an access token for a patron
Parameters:
Name Type Description
barcode string
password string
Source:
Returns:
Type
promise
Example
myPapi.authenticatePatron('1234567890', 'patron-password')
     .then(function(response) {
         console.log(response.data);
     });

module:authenticateStaff(user, pass, domainopt) → {promise}

Authenticates staff credentials
Parameters:
Name Type Attributes Default Description
user string your staff user's username
pass string your staff user's password
domain string <optional>
config.domain hint: your domain is listed when signing into polaris via staff client
Source:
Returns:
Type
promise
Example
myPapi.authenticateStaff('vance', 'my-password')
     .then(function(response) {
         console.log(response.data);
     });

module:bibGet(id) → {promise}

Authenticates staff credentials
Parameters:
Name Type Description
id integer The bibligraphic ID you want to load
Source:
Returns:
Type
promise
Example
myPapi.bibGet('1314713')
     .then(function(response) {
         console.log(response.data);
     });

module:bibHoldingsGet(id) → {promise}

Returns holdings information for a specified bibliographic record.
Parameters:
Name Type Description
id integer The bibligraphic ID you want to load
Source:
Returns:
Type
promise
Example
myPapi.bibHoldingsGet('123456')
     .then(function(response) {
         console.log(response.data);
     });

module:bibSearch(terms, page, per, limitopt, cclopt) → {promise}

A more robust search method
Parameters:
Name Type Attributes Description
terms string | array either a literal string or an array of the form [[bool, filter, value],['AND', 'AU', 'Tolkien'], ...]
page int | string the search result page to return
per int | string number of results per page
limit string | array <optional>
ccl string | array <optional>
Source:
Returns:
Type
promise
Examples
myPapi.bibSearch('KW=dogs')
     .then(function(response) {
         console.log(response.data);
     });
myPapi.bibSearch([['AND','AU','Tolkien'],['NOT','TI','Hobbits']])
     .then(function(response) {
         console.log(response.data);
     });

module:bibSearchKW(search, kw, page, per) → {promise}

A simplified search interface accepting a Type:Value pair
Parameters:
Name Type Description
search string The search term
kw string KW|TI|AU|SU|NOTE|PUB|GENRE|SE|ISBN|ISSN|LCCN|PN|LC|DD|LOCAL|SUDOC|CODEN|STRN|CN|BC
page int | string the search result page to return
per int | string number of results per page
Source:
Returns:
Type
promise
Example
myPapi.bibSearchKW('dogs', 'KW')
     .then(function(response) {
         console.log(response.data);
     });

module:call(url, paramsopt, dataopt) → {promise}

Send a call to the polaris API This function does most of the heavy lifting of talking to the API. It will load default values for most things but you can override by passing params
Parameters:
Name Type Attributes Description
url string the endpoint being requested
params object <optional>
you can override default options & env settings by passing options in params
Properties
Name Type Attributes Description
scheme string <optional>
ex: https://
server string <optional>
ex: polaris.mylibrary.org
path string <optional>
ex: PAPIService/REST
version string <optional>
ex: v1
appid string <optional>
ex: 100
orgid string <optional>
ex: 1
method string <optional>
ex: GET
auth string <optional>
ex: public
pass string <optional>
ex: myPassword
token string <optional>
Generated Staff Authorization Token
lang string <optional>
ex: 1033
encode string <optional>
ex: application/json
accept string <optional>
ex: application/json
data object <optional>
required for POST/PUT methods, accepts basically anything Javascript can stringify
Source:
Requires:
  • module:axios
  • module:es6-promise
Returns:
- an Axios Promise
Type
promise
Example
myPapi.call('bib/979127', { lang: '3082' })
        .then(function(response){
            console.log(response.data);
        })
        .catch(function(error) {
            console.log(error);
        };

module:collectionsGet(idopt) → {promise}

Returns a list of collections based on the organization ID. Branches utilize a subset of collection information maintained at the system level in Polaris. To retrieve a list of all collections in the system, pass in an organization ID of 1. To retrieve a list of collections for a specific branch, pass in the branch ID.
Parameters:
Name Type Attributes Default Description
id integer <optional>
1 all|system|library|branch
Source:
Returns:
Type
promise
Examples
myPapi.collectionsGet()
     .then(function(response) {
         console.log(response.data);
     });
myPapi.collectionsGet('3')
     .then(function(response) {
         console.log(response.data);
     });

module:configGet(key) → {object}

Returns value of root config with given key
Parameters:
Name Type Description
key string the key to lookup, or 'all' to return all values
Source:
Returns:
- the value or object of all values, or null if object not found
Type
object
Examples
myPapi.configGet('all');
myPapi.configGet('lang');

module:configSet(cfg)

Updates root config with given key:values
Parameters:
Name Type Description
cfg object {{key:value},{key2:value2}}
Source:
Examples
myPapi.configSet( {{lang:'1033'}} );
myPapi.configSet( { {lang:'1033'} , {orgid:'6'} } );

module:limitFiltersGet() → {promise}

Returns the limit filters that this Polaris API understands This method does not appear to be very useful to me, there are tons of other filters that seem to work
Source:
Returns:
Type
promise
Example
myPapi.limitFiltersGet()
     .then(function(response) {
         console.log(response.data);
     });

module:organizationsGet(typeopt) → {promise}

Returns list of system, library and branch level organizations.
Parameters:
Name Type Attributes Default Description
type string <optional>
all all|system|library|branch
Source:
Returns:
Type
promise
Example
myPapi.organizationsGet('branch')
     .then(function(response) {
         console.log(response.data);
     });