ebay-api
Version:
eBay API for Node and Browser
110 lines (109 loc) • 3.24 kB
TypeScript
import { XMLBuilder } from 'fast-xml-parser';
import { IEBayApiRequest } from '../../request.js';
import { ApiRequestConfig, Headers } from '../../types/index.js';
import { Fields } from './fields.js';
export declare const defaultJSON2XMLOptions: {
attributeNamePrefix: string;
textNodeName: string;
ignoreAttributes: boolean;
cdataTagName: string;
cdataPositionChar: string;
format: boolean;
indentBy: string;
suppressEmptyNode: boolean;
cdataPropName: string;
};
export declare const defaultXML2JSONParseOptions: {
attributeNamePrefix: string;
textNodeName: string;
ignoreAttributes: boolean;
parseAttributeValue: boolean;
parseNodeValue: boolean;
numberParseOptions: {
hex: boolean;
leadingZeros: boolean;
};
removeNSPrefix: boolean;
isArray: (name: string, jpath: string) => boolean;
};
export type BodyHeaders = {
body: any;
headers: Headers;
};
export type TraditionalApiConfig = {
raw?: boolean;
parseOptions?: object;
useIaf?: boolean;
sign?: boolean;
hook?: (xml: string) => BodyHeaders;
} & ApiRequestConfig;
export type XMLReqConfig = TraditionalApiConfig & {
endpoint: string;
xmlns: string;
eBayAuthToken?: string | null;
digitalSignatureHeaders?: (payload: any) => Headers;
};
export declare const defaultApiConfig: Required<Omit<TraditionalApiConfig, 'hook'>>;
export declare const defaultHeaders: {
'Content-Type': string;
};
/**
* XML request for making eBay API call.
*/
export default class XMLRequest {
private readonly callName;
private readonly fields;
private readonly config;
private readonly req;
static j2x: XMLBuilder;
/**
* Creates the new Request object
*
* @private
* @param {string} callName the callname
* @param {Object} fields the fields
* @param {Object} req the request
* @param {XMLReqConfig} config
*/
constructor(callName: string, fields: Fields | null, config: XMLReqConfig, req: IEBayApiRequest);
/**
* returns the expected name of XML node of a Request
*
* @private
* @return {String} callnameReponse
*/
private getResponseWrapper;
/**
* returns the XML structure for the SOAP auth
*
* @private
* @return {Object} the RequesterCredentials
*/
private getCredentials;
private getParseOptions;
private getHeaders;
/**
* Converts an XML response to JSON
*
* @param {string} xml the xml
* @return {JSON} resolves to a JSON representation of the HTML
*/
toJSON(xml: string): any;
/**
* returns the XML document for the request
*
* @private
* @param {Fields} fields the fields
* @return {String} The XML string of the Request
*/
toXML(fields: Fields): string;
/**
* Call the xml api endpoint.
*
* @private
* @return {Promise} resolves to the response
*
*/
request(): Promise<any>;
xml2JSON(xml: string): any;
}