- ClientConstructorOptions :
Object
Note that
oauth_url
is expected to be a base URL, from which authorization & token endpoints are derived internally. As such, theoauth_url
should end in ".org/" in most cases.- RequestOptions :
Object
Kind: global class
- Client
- new Client(options)
- .get(path, options) ⇒
Promise
- .post(path, body, options) ⇒
Promise
- .patch(path, body, options) ⇒
Promise
- .dangerouslyCallDelete(path, body, options) ⇒
Promise
Param | Type | Description |
---|---|---|
options | ClientConstructorOptions |
A hash of options |
GET an api path
Kind: instance method of Client
Returns: Promise
- A promise that resolves the fetched data
Param | Type | Description |
---|---|---|
path | string |
The path to fetch (e.g. 'current-schema/Item') |
options | RequestOptions |
A hash of options. |
POST an object to an api endpoint
Kind: instance method of Client
Returns: Promise
- A promise that resolves the result data
Param | Type | Description |
---|---|---|
path | string |
The path to fetch (e.g. 'current-schema/Item') |
body | Object |
The object/string to pass with the request |
options | RequestOptions |
A hash of options. |
PATCH a resource at an api endpoint
Kind: instance method of Client
Returns: Promise
- A promise that resolves the result data
Param | Type | Description |
---|---|---|
path | string |
The path to fetch (e.g. 'current-schema/Item') |
body | Object |
The partial object to pass with the request |
options | RequestOptions |
A hash of options. |
DELETE an object from an api endpoint
Kind: instance method of Client
Returns: Promise
- A promise that resolves the result data
Param | Type | Description |
---|---|---|
path | string |
The path to fetch (e.g. 'current-schema/Item') |
body | Object |
The object/string to pass with the request |
options | RequestOptions |
A hash of options. |
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.
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
base_url | string |
Base URL for API (e.g. 'https://[FQDN]/api/v0.1/'). If missing, client will check process.env.NYPL_API_BASE_URL |
oauth_key | string |
OAUTH key. (If missing, client will use process.env.NYPL_OAUTH_KEY) |
oauth_secret | string |
OAUTH secret. (If missing, client will use process.env.NYPL_OAUTH_SECRET) |
oauth_url | string |
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) |
log_level | string |
Set log level (i.e. info, error, warn, debug). Default env.LOG_LEVEL or 'error' |
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
authenticate | boolean |
Whether or not to authenticate before performing request. Default true |
json | boolean |
Indicates endpoint serves and consumes json. If set to true, request will add header "Content-type: application/json" as well as automatically parse response as json. |
cache | boolean |
Whether or not to cache the result. Only allowed for GET requests. Default false |
headers | Object |
Hash of headers to pass in the request. Default {}. |
token_expiration_retries | integer |
Number of refresh attempts to make if token expired. Default 1 |