@dgks/core
Version:
Core implementation for @dgks packages
40 lines (39 loc) • 1.27 kB
TypeScript
import { Got } from 'got';
import { BaseServiceOptions, KeyOption } from './interfaces';
import { Response } from './response';
/**
* Abstract service for dgks
*
* @template S
*/
export declare abstract class Service<S> {
protected readonly got: Got;
constructor(options: KeyOption & BaseServiceOptions);
/**
* Parse search params (query params) to specific format
*
* @param {S} searchParams
*/
protected abstract parseSearchParams(searchParams: S): Record<string, string | number | boolean | null | undefined> | undefined;
/**
* Sends GET request to url with options
*
* @param {url} url - suffix of url
* @param {S} searchParams - search params for requesting
*/
protected get<T>(url: string, searchParams: S): Promise<Response<T>>;
/**
* Zeropad number or string with length
*
* @param {string | number} i - Value to zeropad
* @param {number} [width=4] - Length of zeropad
*/
protected zeropad(i: string | number, width?: number): string;
/**
* Formats date to YYYYMMDD format.
* If date is passed as string it will not format
*
* @param {string | Date} date - date to format
*/
protected formatDate(date: string | Date): string;
}