UNPKG

bc-node-sdk

Version:

BetterCommerce's NodeJS SDK encapsulates the base framework for all the Next.js applications.

59 lines (58 loc) 2.9 kB
import { AxiosRequestConfig, AxiosResponse } from "axios"; /** * Interface {@link IApiService} encapsulates the abstract behavior of a service for making HTTP requests. * * Provides methods for sending HTTP requests using various HTTP methods. * Each method returns a promise that resolves to an Axios response containing * the response data. */ export default interface IApiService { /** * Sends a GET request to the specified URL. * * @param {string} url - The URL of the request. * @param {AxiosRequestConfig} [config] - The config of the request. * @returns {Promise<AxiosResponse<T>>} The promise that resolves to the response data. */ get<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; /** * Sends a POST request to the specified URL. * * @template T - The expected response data type. * @param {string} url - The URL of the request. * @param {any} [data] - The data to be sent as the request body. * @param {AxiosRequestConfig} [config] - The config of the request. * @returns {Promise<AxiosResponse<T>>} The promise that resolves to the response data. */ post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; /** * Sends a PUT request to the specified URL. * * @template T - The expected response data type. * @param {string} url - The URL of the request. * @param {any} [data] - The data to be sent as the request body. * @param {AxiosRequestConfig} [config] - The config of the request. * @returns {Promise<AxiosResponse<T>>} The promise that resolves to the response data. */ put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; /** * Sends a PATCH request to the specified URL. * * @template T - The expected response data type. * @param {string} url - The URL of the request. * @param {any} [data] - The data to be sent as the request body. Defaults to `undefined`. * @param {AxiosRequestConfig} [config] - The config of the request. Defaults to an empty object. * @returns {Promise<AxiosResponse<T>>} The promise that resolves to the response data. */ patch<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; /** * Sends a PATCH request to the specified URL. * * @template T - The expected response data type. * @param {string} url - The URL of the request. * @param {any} [data] - The data to be sent as the request body. * @param {AxiosRequestConfig} [config] - The config of the request. * @returns {Promise<AxiosResponse<T>>} The promise that resolves to the response data. */ delete<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>; }