UNPKG

@cpanel/api

Version:

cPanel API JavaScript and TypeScript interface libraries. This library provides a set of classes for calling cPanel WHM API 1 and UAPI calls. The classes hide much of the complexity of these APIs behind classes the abstract the underlying variances betwee

85 lines (84 loc) 2.64 kB
/** * Abstract argument encoder */ export interface IArgumentEncoder { /** * Name of the content type if any. May be an empty string. */ contentType: string; /** * Separator to inject at the start of the arguments. May be empty. */ separatorStart: string; /** * Separator to inject at the end of the arguments. May be empty. */ separatorEnd: string; /** * Record separator */ recordSeparator: string; /** * Encode a given value into the requested format. * * @param name Name of the field, may be empty string. * @param value Value to serialize * @param last True if this is the last argument being serialized. * @return Encoded version of the argument. */ encode(name: string, value: any, last: boolean): string; } /** * Encode parameters using urlencode. */ export declare class UrlArgumentEncoder implements IArgumentEncoder { contentType: string; separatorStart: string; separatorEnd: string; recordSeparator: string; /** * Encode a given value into query-string compatible format. * * @param name Name of the field, may be empty string. * @param value Value to serialize * @param last True if this is the last argument being serialized. * @return Encoded version of the argument. */ encode(name: string, value: any, last: boolean): string; } /** * Encode parameters using application/x-www-form-urlencoded */ export declare class WwwFormUrlArgumentEncoder implements IArgumentEncoder { contentType: string; separatorStart: string; separatorEnd: string; recordSeparator: string; /** * Encode a given value into the application/x-www-form-urlencoded. * * @param name Name of the field, may be empty string. * @param value Value to serialize * @param last True if this is the last argument being serialized. * @return Encoded version of the argument. */ encode(name: string, value: any, last: boolean): string; } /** * Encode the parameter into JSON */ export declare class JsonArgumentEncoder implements IArgumentEncoder { contentType: string; separatorStart: string; separatorEnd: string; recordSeparator: string; /** * Encode a given value into the JSON application/json body. * * @param name Name of the field. * @param value Value to serialize * @param last True if this is the last argument being serialized. * @return {string} Encoded version of the argument. */ encode(name: string, value: any, last: boolean): string; }