UNPKG

@neynar/nodejs-sdk

Version:

SDK to interact with Neynar APIs (https://docs.neynar.com/reference/quickstart)

458 lines (457 loc) 26.8 kB
"use strict"; /* 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.FetchUserReactionsTypeEnum = exports.FetchCastReactionsTypesEnum = exports.ReactionApi = exports.ReactionApiFactory = exports.ReactionApiFp = exports.ReactionApiAxiosParamCreator = 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"); /** * ReactionApi - axios parameter creator * @export */ const ReactionApiAxiosParamCreator = function (configuration) { return { /** * Delete a reaction (like or recast) to a cast (In order to delete a reaction `signer_uuid` must be approved) * @summary Delete reaction * @param {ReactionReqBody} reactionReqBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/delete-reaction) * */ deleteReaction: async (reactionReqBody, options = {}) => { // verify required parameter 'reactionReqBody' is not null or undefined (0, common_1.assertParamExists)('deleteReaction', 'reactionReqBody', reactionReqBody); const localVarPath = `/v2/farcaster/reaction/`; // 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: 'DELETE' }, baseOptions), options); const localVarHeaderParameter = {}; const localVarQueryParameter = {}; // authentication ApiKeyAuth required await (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "x-api-key", configuration); localVarHeaderParameter['Content-Type'] = 'application/json'; (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); localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(reactionReqBody, localVarRequestOptions, configuration); return { url: (0, common_1.toPathString)(localVarUrlObj), options: localVarRequestOptions, }; }, /** * Fetches reactions for a given cast * @summary Reactions for cast * @param {string} hash * @param {Array<FetchCastReactionsTypesEnum>} types Customize which reaction types the request should search for. This is a comma-separated string that can include the following values: \&#39;likes\&#39; and \&#39;recasts\&#39;. By default api returns both. To select multiple types, use a comma-separated list of these values. * @param {number} [viewerFid] Providing this will return a list of reactions that respects this user\&#39;s mutes and blocks and includes &#x60;viewer_context&#x60;. * @param {number} [limit] Number of results to fetch (Default: 25, Maximum: 100) * @param {string} [cursor] Pagination cursor. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<ReactionsCastResponse>} A promise that resolves to a `ReactionsCastResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-reactions) * */ fetchCastReactions: async (hash, types, viewerFid, limit, cursor, options = {}) => { // verify required parameter 'hash' is not null or undefined (0, common_1.assertParamExists)('fetchCastReactions', 'hash', hash); // verify required parameter 'types' is not null or undefined (0, common_1.assertParamExists)('fetchCastReactions', 'types', types); const localVarPath = `/v2/farcaster/reactions/cast/`; // 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 (hash !== undefined) { localVarQueryParameter['hash'] = hash; } if (types) { localVarQueryParameter['types'] = types; } if (viewerFid !== undefined) { localVarQueryParameter['viewer_fid'] = viewerFid; } if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } if (cursor !== undefined) { localVarQueryParameter['cursor'] = cursor; } (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, }; }, /** * Fetches reactions for a given user * @summary Reactions for user * @param {number} fid The unique identifier of a farcaster user or app (unsigned integer) * @param {FetchUserReactionsTypeEnum} type Type of reaction to fetch (likes or recasts or all) * @param {number} [viewerFid] Providing this will return a list of reactions that respects this user\&#39;s mutes and blocks and includes &#x60;viewer_context&#x60;. * @param {number} [limit] Number of results to fetch (Default: 25, Maximum: 100) * @param {string} [cursor] Pagination cursor. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<ReactionsResponse>} A promise that resolves to a `ReactionsResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-user-reactions) * */ fetchUserReactions: async (fid, type, viewerFid, limit, cursor, options = {}) => { // verify required parameter 'fid' is not null or undefined (0, common_1.assertParamExists)('fetchUserReactions', 'fid', fid); // verify required parameter 'type' is not null or undefined (0, common_1.assertParamExists)('fetchUserReactions', 'type', type); const localVarPath = `/v2/farcaster/reactions/user/`; // 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 (fid !== undefined) { localVarQueryParameter['fid'] = fid; } if (viewerFid !== undefined) { localVarQueryParameter['viewer_fid'] = viewerFid; } if (type !== undefined) { localVarQueryParameter['type'] = type; } if (limit !== undefined) { localVarQueryParameter['limit'] = limit; } if (cursor !== undefined) { localVarQueryParameter['cursor'] = cursor; } (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, }; }, /** * Post a reaction (like or recast) to a given cast (In order to post a reaction `signer_uuid` must be approved) * @summary Post a reaction * @param {ReactionReqBody} reactionReqBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/publish-reaction) * */ publishReaction: async (reactionReqBody, options = {}) => { // verify required parameter 'reactionReqBody' is not null or undefined (0, common_1.assertParamExists)('publishReaction', 'reactionReqBody', reactionReqBody); const localVarPath = `/v2/farcaster/reaction/`; // 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: 'POST' }, baseOptions), options); const localVarHeaderParameter = {}; const localVarQueryParameter = {}; // authentication ApiKeyAuth required await (0, common_1.setApiKeyToObject)(localVarHeaderParameter, "x-api-key", configuration); localVarHeaderParameter['Content-Type'] = 'application/json'; (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); localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(reactionReqBody, localVarRequestOptions, configuration); return { url: (0, common_1.toPathString)(localVarUrlObj), options: localVarRequestOptions, }; }, }; }; exports.ReactionApiAxiosParamCreator = ReactionApiAxiosParamCreator; /** * ReactionApi - functional programming interface * @export */ const ReactionApiFp = function (configuration) { const localVarAxiosParamCreator = (0, exports.ReactionApiAxiosParamCreator)(configuration); return { /** * Delete a reaction (like or recast) to a cast (In order to delete a reaction `signer_uuid` must be approved) * @summary Delete reaction * @param {ReactionReqBody} reactionReqBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/delete-reaction) * */ async deleteReaction(reactionReqBody, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.deleteReaction(reactionReqBody, 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['ReactionApi.deleteReaction']) === 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); }, /** * Fetches reactions for a given cast * @summary Reactions for cast * @param {string} hash * @param {Array<FetchCastReactionsTypesEnum>} types Customize which reaction types the request should search for. This is a comma-separated string that can include the following values: \&#39;likes\&#39; and \&#39;recasts\&#39;. By default api returns both. To select multiple types, use a comma-separated list of these values. * @param {number} [viewerFid] Providing this will return a list of reactions that respects this user\&#39;s mutes and blocks and includes &#x60;viewer_context&#x60;. * @param {number} [limit] Number of results to fetch (Default: 25, Maximum: 100) * @param {string} [cursor] Pagination cursor. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<ReactionsCastResponse>} A promise that resolves to a `ReactionsCastResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-reactions) * */ async fetchCastReactions(hash, types, viewerFid, limit, cursor, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.fetchCastReactions(hash, types, viewerFid, limit, cursor, 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['ReactionApi.fetchCastReactions']) === 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); }, /** * Fetches reactions for a given user * @summary Reactions for user * @param {number} fid The unique identifier of a farcaster user or app (unsigned integer) * @param {FetchUserReactionsTypeEnum} type Type of reaction to fetch (likes or recasts or all) * @param {number} [viewerFid] Providing this will return a list of reactions that respects this user\&#39;s mutes and blocks and includes &#x60;viewer_context&#x60;. * @param {number} [limit] Number of results to fetch (Default: 25, Maximum: 100) * @param {string} [cursor] Pagination cursor. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<ReactionsResponse>} A promise that resolves to a `ReactionsResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-user-reactions) * */ async fetchUserReactions(fid, type, viewerFid, limit, cursor, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.fetchUserReactions(fid, type, viewerFid, limit, cursor, 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['ReactionApi.fetchUserReactions']) === 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); }, /** * Post a reaction (like or recast) to a given cast (In order to post a reaction `signer_uuid` must be approved) * @summary Post a reaction * @param {ReactionReqBody} reactionReqBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/publish-reaction) * */ async publishReaction(reactionReqBody, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.publishReaction(reactionReqBody, 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['ReactionApi.publishReaction']) === 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.ReactionApiFp = ReactionApiFp; /** * ReactionApi - factory interface * @export */ const ReactionApiFactory = function (configuration, basePath, axios) { const localVarFp = (0, exports.ReactionApiFp)(configuration); return { /** * Delete a reaction (like or recast) to a cast (In order to delete a reaction `signer_uuid` must be approved) * @summary Delete reaction * @param {ReactionApiDeleteReactionRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/delete-reaction) * */ deleteReaction(requestParameters, options) { return localVarFp.deleteReaction(requestParameters.reactionReqBody, options).then((request) => request(axios, basePath)); }, /** * Fetches reactions for a given cast * @summary Reactions for cast * @param {ReactionApiFetchCastReactionsRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<ReactionsCastResponse>} A promise that resolves to a `ReactionsCastResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-reactions) * */ fetchCastReactions(requestParameters, options) { return localVarFp.fetchCastReactions(requestParameters.hash, requestParameters.types, requestParameters.viewerFid, requestParameters.limit, requestParameters.cursor, options).then((request) => request(axios, basePath)); }, /** * Fetches reactions for a given user * @summary Reactions for user * @param {ReactionApiFetchUserReactionsRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<ReactionsResponse>} A promise that resolves to a `ReactionsResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-user-reactions) * */ fetchUserReactions(requestParameters, options) { return localVarFp.fetchUserReactions(requestParameters.fid, requestParameters.type, requestParameters.viewerFid, requestParameters.limit, requestParameters.cursor, options).then((request) => request(axios, basePath)); }, /** * Post a reaction (like or recast) to a given cast (In order to post a reaction `signer_uuid` must be approved) * @summary Post a reaction * @param {ReactionApiPublishReactionRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/publish-reaction) * */ publishReaction(requestParameters, options) { return localVarFp.publishReaction(requestParameters.reactionReqBody, options).then((request) => request(axios, basePath)); }, }; }; exports.ReactionApiFactory = ReactionApiFactory; /** * ReactionApi - object-oriented interface * @export * @class ReactionApi * @extends {BaseAPI} */ class ReactionApi extends base_1.BaseAPI { /** * Delete a reaction (like or recast) to a cast (In order to delete a reaction `signer_uuid` must be approved) * @summary Delete reaction * @param {ReactionApiDeleteReactionRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ReactionApi * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/delete-reaction) * */ deleteReaction(requestParameters, options) { return (0, exports.ReactionApiFp)(this.configuration).deleteReaction(requestParameters.reactionReqBody, options).then((request) => request(this.axios, this.basePath)); } /** * Fetches reactions for a given cast * @summary Reactions for cast * @param {ReactionApiFetchCastReactionsRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ReactionApi * @returns {Promise<ReactionsCastResponse>} A promise that resolves to a `ReactionsCastResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-cast-reactions) * */ fetchCastReactions(requestParameters, options) { return (0, exports.ReactionApiFp)(this.configuration).fetchCastReactions(requestParameters.hash, requestParameters.types, requestParameters.viewerFid, requestParameters.limit, requestParameters.cursor, options).then((request) => request(this.axios, this.basePath)); } /** * Fetches reactions for a given user * @summary Reactions for user * @param {ReactionApiFetchUserReactionsRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ReactionApi * @returns {Promise<ReactionsResponse>} A promise that resolves to a `ReactionsResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-user-reactions) * */ fetchUserReactions(requestParameters, options) { return (0, exports.ReactionApiFp)(this.configuration).fetchUserReactions(requestParameters.fid, requestParameters.type, requestParameters.viewerFid, requestParameters.limit, requestParameters.cursor, options).then((request) => request(this.axios, this.basePath)); } /** * Post a reaction (like or recast) to a given cast (In order to post a reaction `signer_uuid` must be approved) * @summary Post a reaction * @param {ReactionApiPublishReactionRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof ReactionApi * @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/publish-reaction) * */ publishReaction(requestParameters, options) { return (0, exports.ReactionApiFp)(this.configuration).publishReaction(requestParameters.reactionReqBody, options).then((request) => request(this.axios, this.basePath)); } } exports.ReactionApi = ReactionApi; /** * @export */ exports.FetchCastReactionsTypesEnum = { All: 'all', Likes: 'likes', Recasts: 'recasts' }; /** * @export */ exports.FetchUserReactionsTypeEnum = { All: 'all', Likes: 'likes', Recasts: 'recasts' };