UNPKG

@zohocrm/typescript-sdk-6.0

Version:
67 lines (66 loc) 3.43 kB
import { CommonAPIHandler } from "../../routes/middlewares/common_api_handler"; /** * This class is to construct API request and response. */ export declare abstract class Converter { protected commonAPIHandler: CommonAPIHandler; /** * Creates a Converter class instance with the CommonAPIHandler class instance. * @param {CommonAPIHandler} commonAPIHandler - A CommonAPIHandler class instance. */ constructor(commonAPIHandler: CommonAPIHandler); /** * This abstract method is to process the API response. * @param {object} response - An Object containing the API response contents or response. * @param {string} pack - A String containing the expected method return type. * @returns An Object representing the class instance. * @throws {Error} */ abstract getResponse(response: any, pack: string): Promise<object | null>; /** * This method is to construct the API request. * @param {object} requestInstance - An Object containing the class instance. * @param {string} pack - A String containing the expected method return type. * @param {int} instanceNumber - An Integer containing the class instance list number. * @param {object} memberDetail - An object containing the member properties * @returns An Object representing the API request body object. * @throws {Error} */ abstract formRequest(requestInstance: object, pack: string, instanceNumber: number | null, memberDetail: object | null): Promise<object | null>; /** * This abstract method is to construct the API request body. * @param {object} requestBase * @param {object} requestObject - A Object containing the API request body object. * @throws {Error} */ abstract appendToRequest(requestBase: object): Promise<any>; /** * This abstract method is to process the API response. * @param {object} response - An Object containing the HttpResponse class instance. * @param {string} pack - A String containing the expected method return type. * @returns An Object representing the class instance. * @throws {Error} */ abstract getWrappedResponse(response: any, pack: string): Promise<object | null>; /** * This method is to validate if the input values satisfy the constraints for the respective fields. * @param {string} className - A String containing the class name. * @param {string} memberName - A String containing the member name. * @param {object} keyDetails - A JSONObject containing the key JSON details. * @param {object} value - A Object containing the key value. * @param {Map} uniqueValuesMap - A Map containing the value of constructed object's unique fields. * @param {int} instanceNumber - An Integer containing the class instance list number. * @returns A Boolean representing the key value is expected pattern, unique, length, and values. * @throws {SDKException} */ valueChecker(className: string, memberName: string, keyDetails: { [key: string]: any; }, value: any, uniqueValuesMap: Map<string, any[]>, instanceNumber: number | null): Promise<boolean>; /** * getEncodedFileName */ static getEncodedFileName(): Promise<string>; static toUTF8Array(str: string): number[]; moduleToClass(moduleName: string): Promise<string>; getFileName(name: string): Promise<string>; }