Members
authentications :Array.<String>
The authentication methods to be included for all API calls.
Type:
- Array.<String>
- Source:
basePath :String
The base URL against which to resolve every API call's (relative) path.
Type:
- String
- Default Value:
- https://localhost/s/siteId/dw/shop/v20_4
- Source:
cache :Boolean
If set to false an additional timestamp parameter is added to all API GET calls to prevent browser caching
Type:
- Boolean
- Default Value:
- true
- Source:
defaultHeaders :Array.<String>
The default HTTP headers to be included for all API calls.
Type:
- Array.<String>
- Default Value:
- {}
- Source:
enableCookies
If set to true, the client will save the cookies from each server response, and return them in the next request.
- Default Value:
- false
- Source:
overrideHttpPut :Boolean
If set to true, endpoints that normally use HTTP PUT
will
be sent using POST
with an aditional header (x-dw-http-method-override: PUT
).
Please refer to the following Salesforce documentation https://documentation.demandware.com/DOC1/topic/com.demandware.dochelp/OCAPI/18.8/usage/HttpMethods.html
for more information.
Type:
- Boolean
- Default Value:
- true
- Source:
timeout :Number
The default HTTP timeout for all API calls.
Type:
- Number
- Default Value:
- 60000
- Source:
Methods
(static) constructFromObject(data, obj)
Constructs a new map or array model from REST data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Array | The REST data. |
obj |
Object | Array | The target object or array. |
- Source:
(static) convertToType(data, type)
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 |
- Source:
Returns:
An instance of the specified type or null or undefined if data is null or undefined.
(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(request, authNames)
Applies authentication headers to the request.
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | The request object created by a |
authNames |
Array.<String> | An array of authentication method names. |
- 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
buildRefineParams(refinements) → {Object}
Builds an object with refinement keys 1..n given a an array of refinements. A numbered suffix will not be applied if the number of refinements is equal to 1.
Parameters:
Name | Type | Description |
---|---|---|
refinements |
Array | Array of refinement strings |
- Source:
Returns:
An object with refinement keys numbered 1 ... n with their string representation value.
- Type
- Object
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, authNames, contentTypes, accepts, returnType) → {Promise}
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. |
authNames |
Array.<String> | An array of authentication type names. |
contentTypes |
Array.<String> | An array of request MIME types. |
accepts |
Array.<String> | An array of acceptable response MIME types. |
returnType |
String | Array | ObjectFunction | The required type to return; can be a string for simple types or the constructor for a complex type. |
- Source:
Returns:
A Promise object.
- Type
- Promise
deserialize(response, returnType)
Deserializes an HTTP response body into a value of the specified type.
Parameters:
Name | Type | Description |
---|---|---|
response |
Object | A SuperAgent response object. |
returnType |
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 |
- Source:
Returns:
A value of the specified type.
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>
paramToEncodedString(param) → {String}
Returns a encoded string representation for an actual parameter.
Parameters:
Name | Type | Description |
---|---|---|
param |
The actual parameter. |
- Source:
Returns:
The string representation of param
.
- Type
- String
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
sendApiRequest(request, returnType) → {Promise}
Sends the generated superagent request and deserializes the response.
Parameters:
Name | Type | Description |
---|---|---|
request |
module:superagent.Request | The superagent request to send. |
returnType |
String | The type to deserialize the response into. |
- Source:
Returns:
A Promise object.
- Type
- Promise