Skip to content

Latest commit

 

History

History
122 lines (89 loc) · 5.13 KB

usage.md

File metadata and controls

122 lines (89 loc) · 5.13 KB

Classes

Client

Typedefs

ClientConstructorOptions : Object

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.

RequestOptions : Object

Client

Kind: global class

new Client(options)

Param Type Description
options ClientConstructorOptions A hash of options

client.get(path, options) ⇒ Promise

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.

client.post(path, body, options) ⇒ Promise

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.

client.patch(path, body, options) ⇒ Promise

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.

client.dangerouslyCallDelete(path, body, options) ⇒ Promise

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.

ClientConstructorOptions : Object

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'

RequestOptions : Object

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