This class handles all api and token requests, and should be extended by the app.
Extends
- EventEmitter
Properties
API_URL
API_URL: stringType
- string
AUTHORIZATION_URL
AUTHORIZATION_URL: stringType
- string
CLIENT_ID
CLIENT_ID: Array.<string>Type
- Array.<string>
CLIENT_SECRET
CLIENT_SECRET: Array.<string>Type
- Array.<string>
REDIRECT_URL
REDIRECT_URL: stringType
- string
SCOPES
SCOPES: Array.<string>Type
- Array.<string>
TOKEN
TOKEN: OAuth2TokenType
TOKEN_URL
TOKEN_URL: stringType
- string
Methods
debug
debug(…props)Helper function
Parameters
Name | Type | Description |
---|---|---|
props
|
<repeatable> |
delete
(async) delete(args): Promise.<*>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
path
|
string | |
query
|
string | |
headers
|
object | |
|
Returns
Promise.<*>
destroy
destroy()Helper function
error
error(…props)Helper function
Parameters
Name | Type | Description |
---|---|---|
props
|
<repeatable> |
get
(async) get(args): Promise.<*>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
path
|
string | |
query
|
string | |
headers
|
object | |
|
Returns
Promise.<*>
getAuthorizationUrl
getAuthorizationUrl(args): stringParameters
Name | Type | Description |
---|---|---|
args
|
object | |
scopes
|
array | |
state
|
string | |
|
Returns
string
getTitle
getTitle(): stringReturns
string
getToken
getToken(): string|nullReturns
string
|
null
getTokenByCode
(async) getTokenByCode(args): Promise.<null>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
code
|
string | |
|
Returns
Promise.<null>
getTokenByCredentials
(async) getTokenByCredentials(args): Promise.<null>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
username
|
string | |
password
|
string | |
|
Returns
Promise.<null>
init
(async) init(): Promise.<void>Helper function
Returns
Promise.<void>
log
log(…props)Helper function
Parameters
Name | Type | Description |
---|---|---|
props
|
<repeatable> |
onBuildRequest
(async) onBuildRequest(args): Promise.<{opts: object, url: string}>Can be extended
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
method
|
string | |
path
|
string | |
json
|
object | |
body
|
object | |
query
|
object | |
headers
|
object | |
|
Returns
Promise.<{opts: object, url: string}>
onGetOAuth2SessionInformation
(async) onGetOAuth2SessionInformation(): Promise.<{id: *, title: null}>This method returns data that can identify the session
Returns
Promise.<{id: *, title: null}>
onGetTokenByCode
(async) onGetTokenByCode(args): Promise.<OAuth2Token>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
code
|
string | |
|
Returns
Promise.<OAuth2Token>
onGetTokenByCredentials
(async) onGetTokenByCredentials(args): Promise.<OAuth2Token>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
username
|
string | |
password
|
string | |
|
Returns
Promise.<OAuth2Token>
onHandleAuthorizationURL
onHandleAuthorizationURL(args): stringParameters
Name | Type | Description |
---|---|---|
args
|
object | |
scopes
|
array.<string> | |
state
|
string | |
|
Returns
string
onHandleAuthorizationURLScopes
onHandleAuthorizationURLScopes(args): *Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
scopes
|
array | |
|
Returns
*
onHandleGetTokenByCodeError
(async) onHandleGetTokenByCodeError(args): Promise.<void>Can be extended
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
response
|
object | |
|
Returns
Promise.<void>
onHandleGetTokenByCodeResponse
(async) onHandleGetTokenByCodeResponse(args): Promise.<void>Can be extended
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
response
|
object | |
|
Returns
Promise.<void>
onHandleNotOK
(async) onHandleNotOK(args): Promise.<Error>This method handles a response that is not OK (400 <= statuscode <= 599)
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
body
|
||
status
|
number | |
statusText
|
string | |
headers
|
object | |
|
Returns
Promise.<Error>
onHandleRefreshTokenError
(async) onHandleRefreshTokenError(args): Promise.<void>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
response
|
object | |
|
Returns
Promise.<void>
onHandleRefreshTokenResponse
(async) onHandleRefreshTokenResponse(args): Promise.<OAuth2Token>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
response
|
object | |
|
Returns
Promise.<OAuth2Token>
onHandleResponse
(async) onHandleResponse(args): Promise.<(*|undefined)>This method handles a response and downloads the body
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
response
|
object | |
status
|
number | |
statusText
|
string | |
headers
|
object | |
ok
|
boolean | |
|
Returns
Promise.<(*|undefined)>
onHandleResult
(async) onHandleResult(args): Promise.<*>This method handles a response that is OK
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
result
|
||
status
|
number | |
statusText
|
string | |
headers
|
object | |
|
Returns
Promise.<*>
onInit
(async) onInit(): Promise.<void>Can be extended
Returns
Promise.<void>
onIsRateLimited
(async) onIsRateLimited(args): Promise.<boolean>This method returns a boolean if the response is rate limited
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
status
|
number | |
headers
|
object | |
|
Returns
Promise.<boolean>
onRefreshToken
(async) onRefreshToken(): Promise.<OAuth2Token>Returns
Promise.<OAuth2Token>
onRequestError
(async) onRequestError(arg): Promise.<void>Parameters
Name | Type | Description |
---|---|---|
arg
|
object | |
err
|
object | |
|
Returns
Promise.<void>
onRequestHeaders
(async) onRequestHeaders(args): Promise.<Object>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
headers
|
object | |
|
Returns
Promise.<Object>
onRequestQuery
(async) onRequestQuery(args): Promise.<Object>Can be extended
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
query
|
string | |
|
Returns
Promise.<Object>
onRequestResponse
(async) onRequestResponse(args): Promise.<(void|*)>This method returns a boolean if the response is rate limited
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
req
|
||
url
|
string | |
opts
|
object | |
response
|
||
didRefreshToken
|
||
|
Returns
Promise.<(void|*)>
onShouldRefreshToken
(async) onShouldRefreshToken(args): Promise.<boolean>This method returns a boolean if the token should be refreshed
Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
status
|
||
|
Returns
Promise.<boolean>
onUninit
(async) onUninit(): Promise.<void>Can be extended
Returns
Promise.<void>
patch
(async) patch(args): Promise.<*>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
path
|
string | |
query
|
string | |
json
|
object | |
body
|
object | |
headers
|
object | |
|
Returns
Promise.<*>
post
(async) post(args): Promise.<*>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
path
|
string | |
query
|
string | |
json
|
object | |
body
|
object | |
headers
|
object | |
|
Returns
Promise.<*>
put
(async) put(args): Promise.<*>Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
path
|
string | |
query
|
string | |
json
|
object | |
body
|
object | |
headers
|
object | |
|
Returns
Promise.<*>
refreshToken
(async) refreshToken(…args): Promise.<(undefined|void|null)>Parameters
Name | Type | Description |
---|---|---|
args
|
object
<repeatable> |
Returns
Promise.<(undefined|void|null)>
save
save()Helper function
setTitle
setTitle(title)Parameters
Name | Type | Description |
---|---|---|
title
|
string |
setToken
setToken(args)Parameters
Name | Type | Description |
---|---|---|
args
|
object | |
token
|
string | |
|