Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
Accept record ids in the patron API functions (#2)
Browse files Browse the repository at this point in the history
* Move 'use strict' to after the copyright comment.

* Update dependencies

* Add dep on v0.2.0 of sierra-record-id.

* Update v4/patrons.js to accept record ids.

* Add getPatronFines and getPatronHolds to v4/patrons.js.

* Require Node v8 LTS.

* Release v0.2.0.
  • Loading branch information
SydneyUni-Jim authored Nov 20, 2017
1 parent f2e8135 commit 501061d
Show file tree
Hide file tree
Showing 11 changed files with 333 additions and 229 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Simplifies access to the Sierra REST APIs from Node.js.
## How to use

```
npm install 'SydneyUniLibrary/sierra-api-as-promised#v0.1'
npm install 'SydneyUniLibrary/sierra-api-as-promised#v0.2.0'
```

Set up the following variables in process's environment.
Expand Down
25 changes: 14 additions & 11 deletions about.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

/*
Copyright (C) 2017 The University of Sydney Library
Expand All @@ -17,20 +15,25 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

'use strict'


const config = require('./config')
const rp = require('request-promise-any')
const { URL } = require('url')


function about({ host, baseURL } = config) {
const aboutURL = new URL('about', baseURL)
return (
rp({ uri: aboutURL, json: true })
.catch(err => {
throw new Error(`Failed to get the Sierra API about page from ${host}: ${err}`)
})
)
async function about({ apiHost, apiPath } = {}) {
this.apiHost = apiHost || process.env['SIERRA_API_HOST']
if (!this.apiHost) {
throw new Error('The SIERRA_API_HOST environment variable is not set')
}
this.apiPath = apiPath || process.env['SIERRA_API_PATH'] || '/iii/sierra-api/'
const aboutURL = new URL(`https://${this.apiHost}${this.apiPath}about`)
try {
return await rp({ uri: aboutURL, json: true })
} catch (err) {
throw new Error(`Failed to get the Sierra API about page from ${apiHost}: ${err}`)
}
}


Expand Down
48 changes: 0 additions & 48 deletions config.js

This file was deleted.

4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

/*
Copyright (C) 2017 The University of Sydney Library
Expand All @@ -17,6 +15,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

'use strict'


module.exports = {
about: require('./about'),
Expand Down
Loading

0 comments on commit 501061d

Please sign in to comment.