Class: module:ApiClient

module:ApiClient()

new module:ApiClient()

Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an application to use this class directly - the *Api and model classes provide the public API for the service. The contents of this file should be regarded as internal but are documented for completeness.

Source:

Members

(static, readonly) CollectionFormatEnum :String

Enumeration of collection format separator strategies.

Type:
  • String
Properties:
Name Type Description
CSV String

Comma-separated values. Value: csv

SSV String

Space-separated values. Value: ssv

TSV String

Tab-separated values. Value: tsv

PIPES String

Pipe(|)-separated values. Value: pipes

MULTI String

Native array. Value: multi

Source:

(static) instance :module:ApiClient

The default API client implementation.

Type:
Source:

basePath :String

The base URL against which to resolve every API call's (relative) path.

Type:
  • String
Default Value:
  • https://developer.api.autodesk.com
Source:

defaultHeaders :Array.<String>

The default HTTP headers to be included for all API calls.

Type:
  • Array.<String>
Default Value:
  • {}
Source:

timeout :Number

The default HTTP timeout for all API calls.

Type:
  • Number
Default Value:
  • 60000
Source:

Methods

(static) convertToType(data, type) → {Object}

Converts a value to the specified type.

Parameters:
Name Type Description
data String | Object

The data to convert, as a string or object.

type String | Array.<String> | Object.<String, Object> | function

The type to return. Pass a string for simple types or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type: all properties on data will be converted to this type.

Source:
Returns:

An instance of the specified type.

Type
Object

(static) isReadableStream()

Is this obj a readable stream

Source:

(static) isWritableStream()

Is this obj a writable stream

Source:

(static) parseDate(str) → {Date}

Parses an ISO-8601 string representation of a date value.

Parameters:
Name Type Description
str String

The date value as a string.

Source:
Returns:

The parsed date object.

Type
Date

applyAuthToRequest(requestParams, headers, oauth2client, credentials)

Applies authentication header to the request.

Parameters:
Name Type Description
requestParams Object

The requestParams object created by a axios() call.

headers Object

The headers that passed to this method

oauth2client Object

OAuth2 client that has a credentials object

credentials Object

The credentials object

Source:

buildCollectionParam(param, collectionFormat) → {String|Array}

Builds a string representation of an array-type actual parameter, according to the given collection format.

Parameters:
Name Type Description
param Array

An array parameter.

collectionFormat module:ApiClient.CollectionFormatEnum

The array element separator strategy.

Source:
Returns:

A string representation of the supplied collection, using the specified delimiter. Returns param as is if collectionFormat is multi.

Type
String | Array

buildUrl(path, pathParams) → {String}

Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values. NOTE: query parameters are not handled here.

Parameters:
Name Type Description
path String

The path to append to the base URL.

pathParams Object

The parameter values to append.

Source:
Returns:

The encoded path with parameter values substituted.

Type
String

callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, contentTypes, accepts, returnType, oauth2client, credentials) → {Object}

Invokes the REST service using the supplied settings and parameters.

Parameters:
Name Type Description
path String

The base URL to invoke.

httpMethod String

The HTTP method to use.

pathParams Object.<String, String>

A map of path parameters and their values.

queryParams Object.<String, Object>

A map of query parameters and their values.

headerParams Object.<String, Object>

A map of header parameters and their values.

formParams Object.<String, Object>

A map of form parameters and their values.

bodyParam Object

The value to pass as the request body.

contentTypes Array.<String>

An array of request MIME types.

accepts Array.<String>

An array of acceptable response MIME types.

returnType String | Array | Object | function

The required type to return; can be a string for simple types or the constructor for a complex type.

oauth2client Object

oauth2client for the call

credentials Object

credentials for the call

Source:
Returns:

A Promise object.

Type
Object

debug()

Enable working in debug mode To activate, simple set ForgeSdk.setDebug(true);

Source:

isFileParam(param) → {Boolean}

Checks whether the given parameter value represents file-like content.

Parameters:
Name Type Description
param

The parameter to check.

Source:
Returns:

true if param represents a file.

Type
Boolean

isJsonMime(contentType) → {Boolean}

Checks whether the given content type represents JSON.
JSON content type examples:

  • application/json
  • application/json; charset=UTF8
  • APPLICATION/JSON
Parameters:
Name Type Description
contentType String

The MIME content type to check.

Source:
Returns:

true if contentType represents JSON, otherwise false.

Type
Boolean

jsonPreferredMime(contentTypes) → {String}

Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.

Parameters:
Name Type Description
contentTypes Array.<String>
Source:
Returns:

The chosen content type, preferring JSON.

Type
String

normalizeParams(params) → {Object.<String, Object>}

Normalizes parameter values:

  • remove nils
  • keep files and arrays
  • format to string with `paramToString` for other cases
Parameters:
Name Type Description
params Object.<String, Object>

The parameters as object properties.

Source:
Returns:

normalized parameters.

Type
Object.<String, Object>

paramToString(param) → {String}

Returns a string representation for an actual parameter.

Parameters:
Name Type Description
param

The actual parameter.

Source:
Returns:

The string representation of param.

Type
String