@licht-77/dmm-sdk
Version:
DMM Affiliate API v3 SDK for Node.js/TypeScript
46 lines • 1.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DmmApiHelperClient = void 0;
const client_1 = require("./client");
/**
* A helper client that wraps DmmApiClient to provide additional functionalities.
*/
class DmmApiHelperClient {
client;
/**
* Creates an instance of DmmApiHelperClient.
* @param {DmmApiClientOptions} options - Options for the DMM API client.
*/
constructor(options) {
this.client = new client_1.DmmApiClient(options);
}
/**
* Gets the underlying DmmApiClient instance.
* @returns {DmmApiClient} The DmmApiClient instance.
*/
api() {
return this.client;
}
/**
* Retrieves a single item by its Content ID (cid).
* This method uses the ItemList API and returns the first item found.
* @param {string} cid - The Content ID of the item.
* @param {Omit<ItemListRequestParams, 'cid' | 'hits' | 'offset'>} [options] - Additional ItemListRequestParams (e.g., site).
* @returns {Promise<Item | null>} The item information, or null if not found.
*/
async getItemById(cid, options) {
const params = {
...options,
cid: cid,
hits: 1,
offset: 1,
};
const response = await this.client.getItemList(params);
if (response.items && response.items.length > 0) {
return response.items[0];
}
return null;
}
}
exports.DmmApiHelperClient = DmmApiHelperClient;
//# sourceMappingURL=helperClient.js.map