tm-service-api
v2.0.4
Published
Common tm microservice api methods
Downloads
112
Readme
TM Micro Service API Prototype class
This class provide fetch wrapper, token and Service URL setter mainly. Just to avoid code duplication.
Requirements
Possibly you will need babel-polyfill to use it.
Documentation
ErrorBadRequest
Extends Error
Custom error message for Bad Request server response
Parameters
message
(string | null) error details (optional, defaultnull
)
constructor
Constructor generates errorinstance
Parameters
message
(string | null) error details (optional, defaultnull
)
Returns ErrorBadRequest current instance
ErrorNotFound
Extends Error
Custom error message for Not Found server response
Parameters
message
(string | null) error details (optional, defaultnull
)
constructor
Constructor generates error instance
Parameters
message
(string | null) error details (optional, defaultnull
)
Returns ErrorNotFound current instance
ErrorServerResponse
Extends Error
Custom error message for abstract server response
Parameters
statusCode
number http status codestatusText
string http status code textmessage
(string | null) error details (optional, defaultnull
)
constructor
Constructor generates error instance
Parameters
statusCode
number http status codestatusText
string http status code textmessage
(string | null) error details (optional, defaultnull
)
Returns ErrorServerResponse current instance
TMMicroServiceAPI
TM Micro Service Proto API
Parameters
url
string service urltoken
(string | null) user access tocken if available (optional, defaultnull
)
url
Service URL
Properties
service
string url
token
User access token
Properties
token
(string | null)? user access tocken if available
constructor
Constructor saves service url
Parameters
url
string service urltoken
(string | null) user access tocken if available (optional, defaultnull
)version
string service version (optional, default'v1'
)
Returns TMMicroServiceAPI current instance
messages
Object with class service messages
setToken
Set access token
Parameters
token
string access token
setVersion
Set service version
Parameters
version
string service version
checkUrl
Validagte URL
Parameters
Returns string url - service URL
checkVersion
Validate service version
Parameters
Returns string version - service version
request
Fetch remote resource
Parameters
Returns Promise Promise with server Response
tmpVersion
Service version
Properties
version
string? service version