@licht-77/dmm-sdk
Version:
DMM Affiliate API v3 SDK for Node.js/TypeScript
94 lines • 4.38 kB
TypeScript
import type { ItemListRequestParams, ItemListResponse, Item, FloorListResponse, ActressSearchRequestParams, ActressSearchResponse, GenreSearchRequestParams, GenreSearchResponse, MakerSearchRequestParams, MakerSearchResponse, SeriesSearchRequestParams, SeriesSearchResponse, AuthorSearchRequestParams, AuthorSearchResponse } from './types';
/**
* Options for the DMM API client.
*/
export interface DmmApiClientOptions {
/** API ID */
apiId: string;
/** Affiliate ID */
affiliateId: string;
/** Base URL for the API (optional) */
baseUrl?: string;
}
/**
* DMM Affiliate API v3 Client.
*/
export declare class DmmApiClient {
private readonly baseUrl;
static readonly ItemListEndpoint = "/ItemList";
static readonly FloorListEndpoint = "/FloorList";
static readonly ActressSearchEndpoint = "/ActressSearch";
static readonly GenreSearchEndpoint = "/GenreSearch";
static readonly MakerSearchEndpoint = "/MakerSearch";
static readonly SeriesSearchEndpoint = "/SeriesSearch";
static readonly AuthorSearchEndpoint = "/AuthorSearch";
static readonly DefaultHitsPerPageForGetAllItems = 100;
private readonly apiId;
private readonly affiliateId;
/**
* Creates an instance of DmmApiClient.
* @param {DmmApiClientOptions} options - Client options.
* @throws {Error} if apiId or affiliateId is missing.
*/
constructor(options: DmmApiClientOptions);
/**
* Sends a request to the API endpoint.
* @protected
* @template T The expected response type.
* @param {string} endpoint - The API endpoint path (e.g., '/ItemList').
* @param {Record<string, string | number | undefined>} [params] - API parameters.
* @returns {Promise<T>} The 'result' part of the API response.
* @throws {Error} if the request fails, times out, or the response format is invalid.
*/
protected request<T>(endpoint: string, params?: Record<string, unknown>): Promise<T>;
/**
* Calls the Item List API.
* @param {Partial<ItemListRequestParams}} params - Search parameters.
* @returns {Promise<ItemListResponse>} Item search results.
*/
getItemList(params: Partial<ItemListRequestParams>): Promise<ItemListResponse>;
/**
* Calls the Floor List API.
* @returns {Promise<FloorListResponse>} Floor list.
*/
getFloorList(): Promise<FloorListResponse>;
/**
* Calls the Actress Search API.
* @param {ActressSearchRequestParams} params - Search parameters.
* @returns {Promise<ActressSearchResponse>} Actress search results.
*/
searchActress(params: ActressSearchRequestParams): Promise<ActressSearchResponse>;
/**
* Calls the Genre Search API.
* @param {GenreSearchRequestParams} params - Search parameters.
* @returns {Promise<GenreSearchResponse>} Genre search results.
*/
searchGenre(params: GenreSearchRequestParams): Promise<GenreSearchResponse>;
/**
* Calls the Maker Search API.
* @param {MakerSearchRequestParams} params - Search parameters.
* @returns {Promise<MakerSearchResponse>} Maker search results.
*/
searchMaker(params: MakerSearchRequestParams): Promise<MakerSearchResponse>;
/**
* Calls the Series Search API.
* @param {SeriesSearchRequestParams} params - Search parameters.
* @returns {Promise<SeriesSearchResponse>} Series search results.
*/
searchSeries(params: SeriesSearchRequestParams): Promise<SeriesSearchResponse>;
/**
* Calls the Author Search API.
* @param {AuthorSearchRequestParams} params - Search parameters.
* @returns {Promise<AuthorSearchResponse>} Author search results.
*/
searchAuthor(params: AuthorSearchRequestParams): Promise<AuthorSearchResponse>;
/**
* Retrieves all items matching the given criteria using the Item List API with an async generator.
* Suitable for efficiently processing a large number of items.
* @param {Omit<ItemListRequestParams, 'hits' | 'offset'>} params - Search parameters (hits and offset are managed internally and will be ignored).
* @yields {Item} Matched item information.
* @throws {Error} if an error occurs during API calls.
*/
getAllItems(params: Omit<ItemListRequestParams, 'hits' | 'offset'>): AsyncGenerator<Item, void, undefined>;
}
//# sourceMappingURL=client.d.ts.map