@neynar/nodejs-sdk
Version:
SDK to interact with Neynar APIs (https://docs.neynar.com/reference/quickstart)
180 lines (179 loc) • 9.11 kB
JavaScript
;
/* tslint:disable */
/* eslint-disable */
/**
* Neynar API
* The Neynar API allows you to interact with the Farcaster protocol among other things. See the [Neynar docs](https://docs.neynar.com/reference) for more details.
*
* The version of the OpenAPI document: 3.34.0
* Contact: team@neynar.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchCastMetricsIntervalEnum = exports.MetricsApi = exports.MetricsApiFactory = exports.MetricsApiFp = exports.MetricsApiAxiosParamCreator = void 0;
const axios_1 = __importDefault(require("axios"));
// Some imports not used depending on template conditions
// @ts-ignore
const common_1 = require("../common");
// @ts-ignore
const base_1 = require("../base");
/**
* MetricsApi - axios parameter creator
* @export
*/
const MetricsApiAxiosParamCreator = function (configuration) {
return {
/**
* Fetches metrics casts matching a query
* @summary Metrics for casts
* @param {string} q Query string to search for casts
* @param {boolean} [xNeynarExperimental] Enables experimental features including filtering based on the Neynar score. See [docs](https://neynar.notion.site/Experimental-Features-1d2655195a8b80eb98b4d4ae7b76ae4a) for more details.
* @param {FetchCastMetricsIntervalEnum} [interval] Interval of time for which to fetch metrics. Default is 30d.
* @param {number} [authorFid] Fid of the user whose casts you want to search
* @param {string} [channelId] Channel ID of the casts you want to search
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<CastsMetricsResponse>} A promise that resolves to a `CastsMetricsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-metrics)
*
*/
fetchCastMetrics: async (q, xNeynarExperimental, interval, authorFid, channelId, options = {}) => {
// verify required parameter 'q' is not null or undefined
(0, common_1.assertParamExists)('fetchCastMetrics', 'q', q);
const localVarPath = `/v2/farcaster/cast/metrics/`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
const localVarHeaderParameter = {};
const localVarQueryParameter = {};
// authentication ApiKeyAuth required
await (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "x-api-key", configuration);
if (q !== undefined) {
localVarQueryParameter['q'] = q;
}
if (interval !== undefined) {
localVarQueryParameter['interval'] = interval;
}
if (authorFid !== undefined) {
localVarQueryParameter['author_fid'] = authorFid;
}
if (channelId !== undefined) {
localVarQueryParameter['channel_id'] = channelId;
}
if (xNeynarExperimental != null) {
localVarHeaderParameter['x-neynar-experimental'] = typeof xNeynarExperimental === 'string'
? xNeynarExperimental
: JSON.stringify(xNeynarExperimental);
}
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
},
};
};
exports.MetricsApiAxiosParamCreator = MetricsApiAxiosParamCreator;
/**
* MetricsApi - functional programming interface
* @export
*/
const MetricsApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.MetricsApiAxiosParamCreator)(configuration);
return {
/**
* Fetches metrics casts matching a query
* @summary Metrics for casts
* @param {string} q Query string to search for casts
* @param {boolean} [xNeynarExperimental] Enables experimental features including filtering based on the Neynar score. See [docs](https://neynar.notion.site/Experimental-Features-1d2655195a8b80eb98b4d4ae7b76ae4a) for more details.
* @param {FetchCastMetricsIntervalEnum} [interval] Interval of time for which to fetch metrics. Default is 30d.
* @param {number} [authorFid] Fid of the user whose casts you want to search
* @param {string} [channelId] Channel ID of the casts you want to search
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<CastsMetricsResponse>} A promise that resolves to a `CastsMetricsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-metrics)
*
*/
async fetchCastMetrics(q, xNeynarExperimental, interval, authorFid, channelId, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchCastMetrics(q, xNeynarExperimental, interval, authorFid, channelId, options);
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['MetricsApi.fetchCastMetrics']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
};
};
exports.MetricsApiFp = MetricsApiFp;
/**
* MetricsApi - factory interface
* @export
*/
const MetricsApiFactory = function (configuration, basePath, axios) {
const localVarFp = (0, exports.MetricsApiFp)(configuration);
return {
/**
* Fetches metrics casts matching a query
* @summary Metrics for casts
* @param {MetricsApiFetchCastMetricsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<CastsMetricsResponse>} A promise that resolves to a `CastsMetricsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-metrics)
*
*/
fetchCastMetrics(requestParameters, options) {
return localVarFp.fetchCastMetrics(requestParameters.q, requestParameters.xNeynarExperimental, requestParameters.interval, requestParameters.authorFid, requestParameters.channelId, options).then((request) => request(axios, basePath));
},
};
};
exports.MetricsApiFactory = MetricsApiFactory;
/**
* MetricsApi - object-oriented interface
* @export
* @class MetricsApi
* @extends {BaseAPI}
*/
class MetricsApi extends base_1.BaseAPI {
/**
* Fetches metrics casts matching a query
* @summary Metrics for casts
* @param {MetricsApiFetchCastMetricsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof MetricsApi
* @returns {Promise<CastsMetricsResponse>} A promise that resolves to a `CastsMetricsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-metrics)
*
*/
fetchCastMetrics(requestParameters, options) {
return (0, exports.MetricsApiFp)(this.configuration).fetchCastMetrics(requestParameters.q, requestParameters.xNeynarExperimental, requestParameters.interval, requestParameters.authorFid, requestParameters.channelId, options).then((request) => request(this.axios, this.basePath));
}
}
exports.MetricsApi = MetricsApi;
/**
* @export
*/
exports.FetchCastMetricsIntervalEnum = {
_1d: '1d',
_7d: '7d',
_30d: '30d',
_90d: '90d',
_180d: '180d'
};