/**
* Adapted to TypeScript by David A. Ball. (c) 2024.
*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
import superagent from 'superagent';
export interface Stringifiable {
toString(): string;
}
/**
* @module ApiClient
* @version 1.0.0
*/
/**
* Enumeration of collection format separator strategies.
* @enum {String}
* @readonly
*/
export declare enum CollectionFormatEnum {
/**
* Comma-separated values. Value: csv
* @const
*/
CSV = ",",
/**
* Space-separated values. Value: ssv
* @const
*/
SSV = " ",
/**
* Tab-separated values. Value: tsv
* @const
*/
TSV = "\t",
/**
* Pipe(|)-separated values. Value: pipes
* @const
*/
PIPES = "|",
/**
* Native array. Value: multi
* @const
*/
MULTI = "multi"
}
export interface ApiResponse {
data: T;
response: any;
}
/**
* 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.
* @alias module:ApiClient
* @class
*/
export declare class ApiClient {
/**
* The default API client implementation.
* @type {module:ApiClient}
*/
static instance: ApiClient;
/**
* The base URL against which to resolve every API call's (relative) path.
* @type {String}
* @default https://webservices.amazon.com
*/
basePath: string;
/**
* The Access Key ID which uniquely identifies you.
* @type {String}
*/
accessKey: string | null;
/**
* A key that is used in conjunction with the Access Key ID to cryptographically
* sign an API request.
* @type string
*/
secretKey: string | null;
/**
* The host that receives the Amazon Product Advertising API GenNext request.
* @type string
* @default 'webservices.amazon.com'
*/
host: string;
/**
* The service's region where the request is targeted.
* @type string
* @default 'us-east-1'
*/
region: string;
/**
* The authentication methods to be included for all API calls.
* @type {Array.}
*/
authentications: {};
/**
* The default HTTP headers to be included for all API calls.
* @type {Array.}
* @default {}
*/
defaultHeaders: {};
/**
* The default HTTP timeout for all API calls.
* @type {Number}
* @default 60000
*/
timeout: number;
/**
* If set to false an additional timestamp parameter is added to all API GET calls to
* prevent browser caching
* @type {Boolean}
* @default true
*/
cache: boolean;
/**
* If set to true, the client will save the cookies from each server
* response, and return them in the next request.
* @default false
*/
enableCookies: boolean;
requestAgent: {
'User-Agent': string;
};
agent: any;
/**
* Returns a string representation for an actual parameter.
* @param param The actual parameter.
* @returns {String} The string representation of param.
*/
paramToString(param: string | Stringifiable | Date | undefined | null): 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.
* @param {String} path The path to append to the base URL.
* @param {Object} pathParams The parameter values to append.
* @returns {String} The encoded path with parameter values substituted.
*/
buildUrl(path: string, pathParams: Record): string;
/**
* Checks whether the given content type represents JSON.
* JSON content type examples:
*
* - application/json
* - application/json; charset=UTF8
* - APPLICATION/JSON
*
* @param {String} contentType The MIME content type to check.
* @returns {Boolean} true if contentType represents JSON, otherwise false.
*/
isJsonMime(contentType: string): boolean;
/**
* Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
* @param {Array.} contentTypes
* @returns {String} The chosen content type, preferring JSON.
*/
jsonPreferredMime(contentTypes: string[]): string;
/**
* Checks whether the given parameter value represents file-like content.
* @param param The parameter to check.
* @returns {Boolean} true if param represents a file.
*/
isFileParam(param: any): boolean;
/**
* Normalizes parameter values:
*
* - remove nils
* - keep files and arrays
* - format to string with `paramToString` for other cases
*
* @param {Object.} params The parameters as object properties.
* @returns {Object.} normalized parameters.
*/
normalizeParams(params: Record): Record;
/**
* Builds a string representation of an array-type actual parameter, according to the given collection format.
* @param {Array} param An array parameter.
* @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
* param as is if collectionFormat is multi.
*/
buildCollectionParam(param: any[], collectionFormat: CollectionFormatEnum): string | string[] | null;
/**
* Deserializes an HTTP response body into a value of the specified type.
* @param {Object} response A SuperAgent response object.
* @param {(String|Array.|Object.|Function)} returnType 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.
* @returns A value of the specified type.
*/
deserialize(response: superagent.Response, returnType: string | string[] | any | any[]): any;
/**
* Invokes the REST service using the supplied settings and parameters.
* @param {String} path The base URL to invoke.
* @param {String} httpMethod The HTTP method to use.
* @param {String} apiName
* @param {Object.} pathParams A map of path parameters and their values.
* @param {Object.} queryParams A map of query parameters and their values.
* @param {Object.} collectionQueryParams A map of collection query parameters and their values.
* @param {Object.} headerParams A map of header parameters and their values.
* @param {Object.} formParams A map of form parameters and their values.
* @param {Object} bodyParam The value to pass as the request body.
* @param {Array.} authNames An array of authentication type names.
* @param {Array.} contentTypes An array of request MIME types.
* @param {Array.} accepts An array of acceptable response MIME types.
* @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
* constructor for a complex type.
* @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
*/
callApi(path: string, httpMethod: string, apiName: string, pathParams: Record, queryParams: Record, collectionQueryParams: Record, headerParams: Record, formParams: Record, bodyParam: any, authNames: string[], contentTypes: string[], accepts: string[], returnType: string | string[] | any | any[]): Promise>;
/**
* Parses an ISO-8601 string representation of a date value.
* @param {String} str The date value as a string.
* @returns {Date} The parsed date object.
*/
static parseDate(str: string): Date;
/**
* Converts a value to the specified type.
* @param {(String|Object)} data The data to convert, as a string or object.
* @param {(String|Array.|Object.|Function)} type 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.
* @returns An instance of the specified type or null or undefined if data is null or undefined.
*/
static convertToType(data: string | any | any[], type: string | string[] | any | any[]): any;
/**
* Constructs a new map or array model from REST data.
* @param data {Object|Array} The REST data.
* @param obj {Object|Array} The target object or array.
*/
static constructFromObject(data: any | any[], obj: any | any[], itemType: string | string[] | any | any[]): void;
}