OpenVeoClient
Summary
Creates a client to connect to OpenVeo web service.
It aims to facilitate the interaction with OpenVeo web service. All authentication aspects are managed by the client and are transparent to the user. Requesting an end point, without being authenticated, will automatically authenticate first before calling the end point. If token expired, a new authentication is made automatically.
Constructor
OpenVeoClient
Syntax
OpenVeoClient
(
-
webServiceUrl
-
clientId
-
clientSecret
-
[certificate]
Summary
Parameters:
Example:
const OpenVeoClient = require('@openveo/rest-nodejs-client').OpenVeoClient;
const client = new OpenVeoClient(
'https://www.openveo-web-service:443',
'client id',
'client secret',
'/absolute/path/to/fullchain/certificate.crt'
);
Item Index
Methods
Methods
authenticate
Syntax
Summary
Authenticates the client to the web service.Returns:
Promise:
Promise resolving when the client is authenticated, promise is rejected if authentication
failed
buildRequest
Syntax
buildRequest
(
Request
private
-
[options]
-
[body]
-
[timeout=10000]
-
[multiparted=false]
-
resolve
-
reject
Summary
Builds a request.Parameters:
-
[options]
Object optionalThe list of http(s) options as described by NodeJS http.request documentation -
[body]
Object | String optionalThe request body -
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits -
[multiparted=false]
Boolean optionaltrue to send body as multipart/form-data -
resolve
FunctionThe function to call with request's result -
reject
FunctionThe function to call if request fails
Returns:
Request:
The request, ready to be executed
delete
Syntax
Summary
Executes a DELETE request. If client is not authenticated or access token has expired, a new authentication is automatically performed.Parameters:
-
endPoint
StringThe web service end point to reach with query parameters -
[options]
Object optionalThe list of http(s) options as described by NodeJS http.request documentation -
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits
Returns:
Promise:
Promise resolving with results as an Object
executeRequest
Syntax
executeRequest
(
Promise
private
async
-
method
-
endPoint
-
[options]
-
[body]
-
[timeout=10000]
-
[multiparted=false]
Summary
Executes a REST request after making sure the client is authenticated. If client is not authenticated or access token has expired, a new authentication is automatically performed and request is retried.Parameters:
-
method
StringThe HTTP method to use (either get, post, delete or put) -
endPoint
StringThe web service end point to reach with query parameters -
[options]
Object optionalThe list of http(s) options as described by NodeJS http.request documentation -
[body]
Object | String optionalThe request body -
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits -
[multiparted=false]
Boolean optionaltrue to send body as multipart/form-data
Returns:
Promise:
Promise resolving with request's response
get
Syntax
Summary
Executes a GET request. If client is not authenticated or access token has expired, a new authentication is automatically performed.Parameters:
-
endPoint
StringThe web service end point to reach with query parameters -
[options]
Object optionalThe list of http(s) options as described by NodeJS http.request documentation -
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits
Returns:
Promise:
Promise resolving with result as an Object
getAuthenticationHeaders
Syntax
Summary
Gets the list of headers to send with each request.
Returns:
Object:
The list of headers to add to all requests sent to the server
getRequestHeaders
Syntax
Summary
Gets the list of headers to send with each request.Returns:
Object:
The list of headers to add to all requests sent to the server
isAuthenticated
Syntax
Summary
Indicates if the client is authenticated to the web service or not.Returns:
Boolean:
true if the client is authenticated, false otherwise
patch
Syntax
Summary
Executes a PATCH request. If client is not authenticated or access token has expired, a new authentication is automatically performed.Parameters:
-
endPoint
StringThe web service end point to reach with query parameters -
[body]
Object | String optionalThe request body -
[options]
Object optionalThe list of http(s) options as described by NodeJS http.request documentation -
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits -
[multiparted=false]
Boolean optionaltrue to send body as multipart/form-data
Returns:
Promise:
Promise resolving with results as an Object
post
Syntax
Summary
Executes a POST request. If client is not authenticated or access token has expired, a new authentication is automatically performed.Parameters:
-
endPoint
StringThe web service end point to reach with query parameters -
[body]
Object | String optionalThe request body -
[options]
Object optionalThe list of http(s) options as described by NodeJS http.request documentation -
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits -
[multiparted=false]
Boolean optionaltrue to send body as multipart/form-data
Returns:
Promise:
Promise resolving with results as an Object
put
Syntax
Summary
Executes a PUT request. If client is not authenticated or access token has expired, a new authentication is automatically performed.Parameters:
-
endPoint
StringThe web service end point to reach with query parameters -
[body]
Object | String optionalThe request body -
[options]
Object optionalThe list of http(s) options as described by NodeJS http.request documentation -
[timeout=10000]
Number optionalMaximum execution time for the request (in ms), set it to Infinity for a request without limits -
[multiparted=false]
Boolean optionaltrue to send body as multipart/form-data
Returns:
Promise:
Promise resolving with results as an Object
Properties
authenticateRequest
Syntax
Summary
The authenticate request to get an access token.
certificate
Syntax
Summary
Path to the web service server certificate file.credentials
Syntax
Summary
Encoded credentials ready for OAuth authentication.
maxAuthenticationAttempts
Syntax
maxAuthenticationAttempts
Number
Summary
Maximum number of authentication attempts to perform on a request in case of an invalid or expired token.Default: 1