/// import { AxiosInstance, AxiosResponse } from 'axios'; import { AbstractHttpClient, Headers } from './AbstractHttpClient'; import { File } from 'node:buffer'; /** * Lists of available query parameters for the API call */ export declare enum ParameterKeys { API_KEY = "apiKey", AUTHORIZATION = "Authorization", HEADERS = "headers", IS_LOGGING = "is_logging", ORDER_BY = "order_by", PAGE = "page", PER_PAGE = "per_page", PER_PAGE_CAMEL = "perPage", SORT_BY = "sort_by", URL = "url" } export declare enum ExtraInformationFields { COLUMN_EXTRA_INFORMATION = "extraInformation" } export declare type ParametersWithPaginationType = (Parameters & { [ParameterKeys.PAGE]?: number; [ParameterKeys.PER_PAGE]?: number; }) | (Parameters & { [ParameterKeys.PAGE]?: number; [ParameterKeys.PER_PAGE_CAMEL]?: number; }); export declare type Parameters = Record; export declare enum FileUploadKeys { Fields = "fields", File = "file" } export declare type Payload = Record | Array; export interface PayloadWithFile { [FileUploadKeys.Fields]?: Record; [FileUploadKeys.File]?: File; } export declare type Options = { isAdmin?: boolean; returnAxiosData?: boolean; }; export declare type RegisterCheckReturnSyncStatusError = { error: { statusCode?: number; message?: string; }; }; export declare type RegisterCheckReturnVendorStatus = { code?: number; message?: string; }; export declare type RegisterCheckReturnSyncStatus = { syncData?: string; cost?: RegisterCheckReturnSyncStatusError; security?: RegisterCheckReturnSyncStatusError; sustainability?: RegisterCheckReturnSyncStatusError; }; export declare type RegisterCheckReturnData = { accountReference?: string; classification?: string; creationDate?: string; customerName?: string; customerReference?: string; isLocked?: boolean; marketplace?: string; processingStatus?: string; resellerName?: string; resellerReference?: string; subscriptionReference?: string; syncStatus?: RegisterCheckReturnSyncStatus; vendorCode?: string; vendorStatus?: RegisterCheckReturnVendorStatus; vendorSubscriptionId?: string; }; export declare type CheckStatusReturn = { status?: number; data?: RegisterCheckReturnData; }; export declare type ConfigurationsClient = { [ParameterKeys.API_KEY]?: string; [ParameterKeys.URL]?: string; [ParameterKeys.IS_LOGGING]?: boolean; [ParameterKeys.HEADERS]?: Headers; }; export declare type ExtraInformationType = { [ExtraInformationFields.COLUMN_EXTRA_INFORMATION]?: Record; }; export declare abstract class AbstractRestfulClient extends AbstractHttpClient { /** * Axios instance for client */ protected client: AxiosInstance; /** * ArrowSphere API key */ protected apiKey: string; /** * Current pagination page number */ protected page: number; /** * Pagination's per page result limit */ protected perPage: number; /** * Defines whether the pagination options are camel cased or not */ protected isCamelPagination: boolean; /** * AbstractClient constructor. * @returns AbstractRestfulClient */ protected constructor(configuration?: ConfigurationsClient); /** * Sets the Client ArrowSphere API key * @param key - ArrowSphere API key * @returns this */ setApiKey(key: string): this; /** * Returns the API url. * @returns string */ getUrl(): string; /** * Sets number of results per page * @param perPage - Number of results per page * @returns this */ setPerPage(perPage: number): this; /** * Sets the page number * @param page - Page number * @returns AbstractRestfulClient */ setPage(page: number): this; /** * Sends a GET request and returns the response * @param parameters - Query parameters to send * @param headers - Headers to send * @param options - Options to send * @returns Promise\ */ protected get(parameters?: Parameters, headers?: Headers, options?: Options): Promise; /** * Processes and returns the Axios response data * @param response - The AxiosResponse * @param options - options * @returns T */ private getResponse; /** * Prepare headers before sending * @param headers - Headers to include * @returns {@link Headers} */ private prepareHeaders; /** * Sends a POST request including file with header form/multipart and returns the response * @returns Promise\ * @param payload - Payload to be sent in the POST body * @param parameters - Query parameters to be sent in the request * @param headers - Headers to be sent in the request * @param options - Options to send */ protected post(payload?: Payload, parameters?: Parameters, headers?: Headers, options?: Options): Promise; /** * Sends a POST request and returns the response * @returns Promise\ * @param payload - Payload to be sent in the POST body * @param parameters - Query parameters to be sent in the request * @param headers - Headers to be sent in the request * @param options - Options to send */ protected postFile(payload: PayloadWithFile, parameters?: Parameters, headers?: Headers, options?: Options): Promise; /** * Sends a PUT request * @param payload - Payload to be sent in the POST body * @param parameters - Query parameters to be sent in the request * @param headers - Headers to be sent in the request * @param options - Options to send * @returns Promise\ */ protected put(payload?: Payload, parameters?: Parameters, headers?: Headers, options?: Options): Promise; /** * Sends a PATCH request * @param payload - Payload to be sent in the POST body * @param parameters - Query parameters to be sent in the request * @param headers - Headers to be sent in the request * @param options - Options to send * @returns Promise\ */ protected patch(payload?: Payload, parameters?: Parameters, headers?: Headers, options?: Options): Promise; /** * Sends a DELETE request * @param parameters - Query parameters to be sent in the request * @param headers - Headers to be sent in the request * @param options - Options to send * @param payload - Payload to be sent in the POST body * @returns Promise\ */ protected delete(parameters?: Parameters, headers?: Headers, options?: Options, payload?: Payload): Promise; /** * Generates the full url for request * @param parameters - Parameters to serialize * @param options - Options to send * @returns string */ protected generateUrl(parameters: Parameters, options: Options): string; /** * Generates the pagination part of the url * @returns {@link Parameters} */ private generatePagination; }