Skip to content

Commit 5ad1f1a

Browse files
committed
Merge branch 'master' into pb/fix-schema-post
2 parents 2c80b79 + e08d419 commit 5ad1f1a

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ npm i @nypl/nypl-data-api-client --save
1212

1313
## Usage
1414

15-
Initialization
15+
Initialize a client (see [ClientConstructorOptions](/usage.md#ClientConstructorOptions)):
1616

1717
```js
1818
const NyplClient = require('@nypl/nypl-data-api-client')
19-
var client = new NyplClient({ base_url: 'http://[FQDN].com/api/v0.1/' })
19+
var client = new NyplClient({
20+
base_url: 'http://[FQDN].com/api/v0.1/',
21+
oauth_key: 'oauth-key',
22+
oauth_secret 'top-secret-oauth-secret',
23+
oauth_url: 'https://[fqdn]/'
24+
})
2025
```
2126

2227
### Docs

lib/client.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ const log = loglevel.getLogger('nypl-data-api-client')
1919
class Client {
2020

2121
/**
22+
*
23+
* Note that `oauth_url` is expected to be a *base* URL, from which authorization & token endpoints are derived internally. As such, the `oauth_url` should end in ".org/" in most cases.
24+
*
2225
* @typedef {Object} ClientConstructorOptions
2326
* @property {string} base_url - Base URL for API (e.g. 'https://[FQDN]/api/v0.1/').
2427
* If missing, client will check process.env.NYPL_API_BASE_URL
2528
* @property {string} oauth_key - OAUTH key. (If missing, client will use
2629
* process.env.NYPL_OAUTH_KEY)
2730
* @property {string} oauth_secret - OAUTH secret. (If missing, client will use
2831
* process.env.NYPL_OAUTH_SECRET)
29-
* @property {string} oauth_url - OAUTH URL. (If missing, client will use
32+
* @property {string} oauth_url - OAUTH base URL. This is used to build token
33+
* endpoints. Normally, should end in ".org/" (If missing, client will use
3034
* process.env.NYPL_OAUTH_URL)
3135
* @property {string} log_level - Set [log level](https://github.com/pimterry/loglevel)
3236
* (i.e. info, error, warn, debug). Default env.LOG_LEVEL or 'error'

usage.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
<dl>
1111
<dt><a href="#ClientConstructorOptions">ClientConstructorOptions</a> : <code>Object</code></dt>
12-
<dd></dd>
12+
<dd><p>Note that <code>oauth_url</code> is expected to be a <em>base</em> URL, from which authorization &amp; token endpoints are derived internally. As such, the <code>oauth_url</code> should end in &quot;.org/&quot; in most cases.</p>
13+
</dd>
1314
<dt><a href="#RequestOptions">RequestOptions</a> : <code>Object</code></dt>
1415
<dd></dd>
1516
</dl>
@@ -77,6 +78,8 @@ DELETE an object from an api endpoint
7778
<a name="ClientConstructorOptions"></a>
7879

7980
## ClientConstructorOptions : <code>Object</code>
81+
Note that `oauth_url` is expected to be a *base* URL, from which authorization & token endpoints are derived internally. As such, the `oauth_url` should end in ".org/" in most cases.
82+
8083
**Kind**: global typedef
8184
**Properties**
8285

@@ -85,7 +88,7 @@ DELETE an object from an api endpoint
8588
| base_url | <code>string</code> | Base URL for API (e.g. 'https://[FQDN]/api/v0.1/'). If missing, client will check process.env.NYPL_API_BASE_URL |
8689
| oauth_key | <code>string</code> | OAUTH key. (If missing, client will use process.env.NYPL_OAUTH_KEY) |
8790
| oauth_secret | <code>string</code> | OAUTH secret. (If missing, client will use process.env.NYPL_OAUTH_SECRET) |
88-
| oauth_url | <code>string</code> | OAUTH URL. (If missing, client will use process.env.NYPL_OAUTH_URL) |
91+
| oauth_url | <code>string</code> | OAUTH base URL. This is used to build token endpoints. Normally, should end in ".org/" (If missing, client will use process.env.NYPL_OAUTH_URL) |
8992
| log_level | <code>string</code> | Set [log level](https://github.com/pimterry/loglevel) (i.e. info, error, warn, debug). Default env.LOG_LEVEL or 'error' |
9093

9194
<a name="RequestOptions"></a>

0 commit comments

Comments
 (0)