@spreeloop/orange_money
Version:
A orange money api integration package
77 lines • 3 kB
TypeScript
import { LoggerInterface } from './logging_interface';
export declare enum RequestStatusCode {
unauthorized = 401,
expectationFailed = 417
}
export declare type RequestResponse<T> = {
response?: {
data: T;
status: number;
};
error?: unknown;
};
/**
* Posts an http request to the given route.
* @param {Record<string, string | undefined> | string} data The data to be posted.
* @param {string} route The end point url.
* @param {Record<string, string>} headers The type content of request.
* @param {LoggerInterface} logger The logger to use when posting data.
* @return {Promise<unknown | undefined>} The server response.
*/
export declare function postRequest<T>({ data, route, headers, logger, rejectUnauthorized, }: {
data?: Record<string, unknown> | string | null;
route: string;
logger: LoggerInterface;
headers?: Record<string, string>;
rejectUnauthorized?: boolean;
}): Promise<RequestResponse<T>>;
/**
* Gets an http request to the given route.
* @param {Record<string, string | undefined> | string} data The data to be posted.
* @param {string} route The end point url.
* @param {Record<string, string>} headers The type content of request.
* @param {LoggerInterface} logger The logger to use when getting data.
* @return {Promise<unknown | undefined>} The server response.
*/
export declare function getRequest<T>({ data, route, headers, logger, rejectUnauthorized, }: {
data?: Record<string, string | undefined> | string;
route: string;
headers?: Record<string, string>;
logger: LoggerInterface;
rejectUnauthorized?: boolean;
}): Promise<RequestResponse<T>>;
/**
* Parses an Axios error and returns a modified error object.
*
* @param {unknown} error - The error object to be parsed.
* @return {unknown} The modified error object.
*/
export declare function parseAxiosError(error: unknown): unknown;
/**
* Generates a hash using the given key and secret.
*
* @param {string} key - The key to be hashed.
* @param {string} secret - The secret to be hashed.
* @return {string} - The generated hash.
*/
export declare function hash(key: string, secret: string): string;
/**
* Encode the body of the request.
* @param {Record<string, string>} bodyRequest the body request.
* @return {string} the encoded body request result.
*/
export declare function encodeTheBodyOfRequest(bodyRequest: Record<string, string>): string;
export declare const encodeToBase64: (apiUsername: string, apiPassword: string) => string;
/**
* Encode the data to w3 x form encoded url.
* @param {Record<string, string>} data the data to encode.
* @return {string} the encoded value.
*/
export declare function encodeDataToXFormUrl(data: Record<string, string>): string;
/**
* Checks if the code is a successful code response.
* @param {num} code .
* @return {boolean} true if the code is valid.
*/
export declare const isSuccessfulCodeResponse: (code: number) => boolean;
//# sourceMappingURL=https.d.ts.map