UNPKG

@neynar/nodejs-sdk

Version:

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

460 lines (459 loc) 28.9 kB
"use strict"; /* tslint:disable */ /* eslint-disable */ /** * Farcaster Hub API * Perform basic queries of Farcaster state via the REST API of a Farcaster hub. See the [Neynar docs](https://docs.neynar.com/reference) for more details. * * The version of the OpenAPI document: 2.35.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.CastsApi = exports.CastsApiFactory = exports.CastsApiFp = exports.CastsApiAxiosParamCreator = 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"); /** * CastsApi - axios parameter creator * @export */ const CastsApiAxiosParamCreator = function (configuration) { return { /** * Retrieve all reply casts (responses) to a specific parent cast in the Farcaster network. Parent casts can be identified using either a combination of FID and hash, or by their URL. This endpoint enables traversal of conversation threads and retrieval of all responses to a particular cast. * @summary By parent cast * @param {number} [fid] The Farcaster ID (FID) of the parent cast\&#39;s creator. This parameter must be used together with the \&#39;hash\&#39; parameter to uniquely identify a parent cast. Required only when using hash-based lookup instead of URL-based lookup. The FID is a unique identifier assigned to each Farcaster user. * @param {string} [hash] The unique hash identifier of the parent cast. Must be used together with the \&#39;fid\&#39; parameter when doing hash-based lookup. This is a 40-character hexadecimal string prefixed with \&#39;0x\&#39; that uniquely identifies the cast within the creator\&#39;s posts. Not required if using URL-based lookup. * @param {string} [url] Cast URL starting with \&#39;chain://\&#39; * @param {number} [pageSize] Maximum number of messages to return in a single response * @param {boolean} [reverse] Reverse the sort order, returning latest messages first * @param {string} [pageToken] The page token returned by the previous query, to fetch the next page. If this parameter is empty, fetch the first page * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchCastsByParent200Response>} A promise that resolves to a `FetchCastsByParent200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-by-parent) * */ fetchCastsByParent: async (fid, hash, url, pageSize, reverse, pageToken, options = {}) => { const localVarPath = `/v1/castsByParent`; // 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 (hash !== undefined) { localVarQueryParameter['hash'] = hash; } if (url !== undefined) { localVarQueryParameter['url'] = url; } if (pageSize !== undefined) { localVarQueryParameter['pageSize'] = pageSize; } if (reverse !== undefined) { localVarQueryParameter['reverse'] = reverse; } if (pageToken !== undefined) { localVarQueryParameter['pageToken'] = pageToken; } (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, }; }, /** * Fetch casts mentioning a user. * @summary Mentioning an FID * @param {number} fid The FID that is mentioned in a cast * @param {number} [pageSize] Maximum number of messages to return in a single response * @param {boolean} [reverse] Reverse the sort order, returning latest messages first * @param {string} [pageToken] The page token returned by the previous query, to fetch the next page. If this parameter is empty, fetch the first page * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-mentioning-user) * */ fetchCastsMentioningUser: async (fid, pageSize, reverse, pageToken, options = {}) => { // verify required parameter 'fid' is not null or undefined (0, common_1.assertParamExists)('fetchCastsMentioningUser', 'fid', fid); const localVarPath = `/v1/castsByMention`; // 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 (pageSize !== undefined) { localVarQueryParameter['pageSize'] = pageSize; } if (reverse !== undefined) { localVarQueryParameter['reverse'] = reverse; } if (pageToken !== undefined) { localVarQueryParameter['pageToken'] = pageToken; } (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, }; }, /** * Fetch user\'s casts. * @summary By FID * @param {number} fid The FID of the casts\&#39; creator * @param {number} [pageSize] Maximum number of messages to return in a single response * @param {boolean} [reverse] Reverse the sort order, returning latest messages first * @param {string} [pageToken] The page token returned by the previous query, to fetch the next page. If this parameter is empty, fetch the first page * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-users-casts) * */ fetchUsersCasts: async (fid, pageSize, reverse, pageToken, options = {}) => { // verify required parameter 'fid' is not null or undefined (0, common_1.assertParamExists)('fetchUsersCasts', 'fid', fid); const localVarPath = `/v1/castsByFid`; // 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 (pageSize !== undefined) { localVarQueryParameter['pageSize'] = pageSize; } if (reverse !== undefined) { localVarQueryParameter['reverse'] = reverse; } if (pageToken !== undefined) { localVarQueryParameter['pageToken'] = pageToken; } (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, }; }, /** * Lookup a cast by its FID and hash. * @summary By FID and Hash * @param {number} fid The FID of the cast\&#39;s creator * @param {string} hash The unique hash identifier of the cast. This is a 40-character hexadecimal string prefixed with \&#39;0x\&#39; that uniquely identifies a specific cast in the Farcaster network. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<CastAdd>} A promise that resolves to a `CastAdd` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-cast-by-hash-and-fid) * */ lookupCastByHashAndFid: async (fid, hash, options = {}) => { // verify required parameter 'fid' is not null or undefined (0, common_1.assertParamExists)('lookupCastByHashAndFid', 'fid', fid); // verify required parameter 'hash' is not null or undefined (0, common_1.assertParamExists)('lookupCastByHashAndFid', 'hash', hash); const localVarPath = `/v1/castById`; // 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 (hash !== undefined) { localVarQueryParameter['hash'] = hash; } (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.CastsApiAxiosParamCreator = CastsApiAxiosParamCreator; /** * CastsApi - functional programming interface * @export */ const CastsApiFp = function (configuration) { const localVarAxiosParamCreator = (0, exports.CastsApiAxiosParamCreator)(configuration); return { /** * Retrieve all reply casts (responses) to a specific parent cast in the Farcaster network. Parent casts can be identified using either a combination of FID and hash, or by their URL. This endpoint enables traversal of conversation threads and retrieval of all responses to a particular cast. * @summary By parent cast * @param {number} [fid] The Farcaster ID (FID) of the parent cast\&#39;s creator. This parameter must be used together with the \&#39;hash\&#39; parameter to uniquely identify a parent cast. Required only when using hash-based lookup instead of URL-based lookup. The FID is a unique identifier assigned to each Farcaster user. * @param {string} [hash] The unique hash identifier of the parent cast. Must be used together with the \&#39;fid\&#39; parameter when doing hash-based lookup. This is a 40-character hexadecimal string prefixed with \&#39;0x\&#39; that uniquely identifies the cast within the creator\&#39;s posts. Not required if using URL-based lookup. * @param {string} [url] Cast URL starting with \&#39;chain://\&#39; * @param {number} [pageSize] Maximum number of messages to return in a single response * @param {boolean} [reverse] Reverse the sort order, returning latest messages first * @param {string} [pageToken] The page token returned by the previous query, to fetch the next page. If this parameter is empty, fetch the first page * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchCastsByParent200Response>} A promise that resolves to a `FetchCastsByParent200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-by-parent) * */ async fetchCastsByParent(fid, hash, url, pageSize, reverse, pageToken, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.fetchCastsByParent(fid, hash, url, pageSize, reverse, pageToken, 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['CastsApi.fetchCastsByParent']) === 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); }, /** * Fetch casts mentioning a user. * @summary Mentioning an FID * @param {number} fid The FID that is mentioned in a cast * @param {number} [pageSize] Maximum number of messages to return in a single response * @param {boolean} [reverse] Reverse the sort order, returning latest messages first * @param {string} [pageToken] The page token returned by the previous query, to fetch the next page. If this parameter is empty, fetch the first page * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-mentioning-user) * */ async fetchCastsMentioningUser(fid, pageSize, reverse, pageToken, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.fetchCastsMentioningUser(fid, pageSize, reverse, pageToken, 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['CastsApi.fetchCastsMentioningUser']) === 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); }, /** * Fetch user\'s casts. * @summary By FID * @param {number} fid The FID of the casts\&#39; creator * @param {number} [pageSize] Maximum number of messages to return in a single response * @param {boolean} [reverse] Reverse the sort order, returning latest messages first * @param {string} [pageToken] The page token returned by the previous query, to fetch the next page. If this parameter is empty, fetch the first page * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-users-casts) * */ async fetchUsersCasts(fid, pageSize, reverse, pageToken, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.fetchUsersCasts(fid, pageSize, reverse, pageToken, 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['CastsApi.fetchUsersCasts']) === 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); }, /** * Lookup a cast by its FID and hash. * @summary By FID and Hash * @param {number} fid The FID of the cast\&#39;s creator * @param {string} hash The unique hash identifier of the cast. This is a 40-character hexadecimal string prefixed with \&#39;0x\&#39; that uniquely identifies a specific cast in the Farcaster network. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<CastAdd>} A promise that resolves to a `CastAdd` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-cast-by-hash-and-fid) * */ async lookupCastByHashAndFid(fid, hash, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.lookupCastByHashAndFid(fid, hash, 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['CastsApi.lookupCastByHashAndFid']) === 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.CastsApiFp = CastsApiFp; /** * CastsApi - factory interface * @export */ const CastsApiFactory = function (configuration, basePath, axios) { const localVarFp = (0, exports.CastsApiFp)(configuration); return { /** * Retrieve all reply casts (responses) to a specific parent cast in the Farcaster network. Parent casts can be identified using either a combination of FID and hash, or by their URL. This endpoint enables traversal of conversation threads and retrieval of all responses to a particular cast. * @summary By parent cast * @param {CastsApiFetchCastsByParentRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchCastsByParent200Response>} A promise that resolves to a `FetchCastsByParent200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-by-parent) * */ fetchCastsByParent(requestParameters = {}, options) { return localVarFp.fetchCastsByParent(requestParameters.fid, requestParameters.hash, requestParameters.url, requestParameters.pageSize, requestParameters.reverse, requestParameters.pageToken, options).then((request) => request(axios, basePath)); }, /** * Fetch casts mentioning a user. * @summary Mentioning an FID * @param {CastsApiFetchCastsMentioningUserRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-mentioning-user) * */ fetchCastsMentioningUser(requestParameters, options) { return localVarFp.fetchCastsMentioningUser(requestParameters.fid, requestParameters.pageSize, requestParameters.reverse, requestParameters.pageToken, options).then((request) => request(axios, basePath)); }, /** * Fetch user\'s casts. * @summary By FID * @param {CastsApiFetchUsersCastsRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-users-casts) * */ fetchUsersCasts(requestParameters, options) { return localVarFp.fetchUsersCasts(requestParameters.fid, requestParameters.pageSize, requestParameters.reverse, requestParameters.pageToken, options).then((request) => request(axios, basePath)); }, /** * Lookup a cast by its FID and hash. * @summary By FID and Hash * @param {CastsApiLookupCastByHashAndFidRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<CastAdd>} A promise that resolves to a `CastAdd` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-cast-by-hash-and-fid) * */ lookupCastByHashAndFid(requestParameters, options) { return localVarFp.lookupCastByHashAndFid(requestParameters.fid, requestParameters.hash, options).then((request) => request(axios, basePath)); }, }; }; exports.CastsApiFactory = CastsApiFactory; /** * CastsApi - object-oriented interface * @export * @class CastsApi * @extends {BaseAPI} */ class CastsApi extends base_1.BaseAPI { /** * Retrieve all reply casts (responses) to a specific parent cast in the Farcaster network. Parent casts can be identified using either a combination of FID and hash, or by their URL. This endpoint enables traversal of conversation threads and retrieval of all responses to a particular cast. * @summary By parent cast * @param {CastsApiFetchCastsByParentRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof CastsApi * @returns {Promise<FetchCastsByParent200Response>} A promise that resolves to a `FetchCastsByParent200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-by-parent) * */ fetchCastsByParent(requestParameters = {}, options) { return (0, exports.CastsApiFp)(this.configuration).fetchCastsByParent(requestParameters.fid, requestParameters.hash, requestParameters.url, requestParameters.pageSize, requestParameters.reverse, requestParameters.pageToken, options).then((request) => request(this.axios, this.basePath)); } /** * Fetch casts mentioning a user. * @summary Mentioning an FID * @param {CastsApiFetchCastsMentioningUserRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof CastsApi * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-casts-mentioning-user) * */ fetchCastsMentioningUser(requestParameters, options) { return (0, exports.CastsApiFp)(this.configuration).fetchCastsMentioningUser(requestParameters.fid, requestParameters.pageSize, requestParameters.reverse, requestParameters.pageToken, options).then((request) => request(this.axios, this.basePath)); } /** * Fetch user\'s casts. * @summary By FID * @param {CastsApiFetchUsersCastsRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof CastsApi * @returns {Promise<FetchUsersCasts200Response>} A promise that resolves to a `FetchUsersCasts200Response` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-users-casts) * */ fetchUsersCasts(requestParameters, options) { return (0, exports.CastsApiFp)(this.configuration).fetchUsersCasts(requestParameters.fid, requestParameters.pageSize, requestParameters.reverse, requestParameters.pageToken, options).then((request) => request(this.axios, this.basePath)); } /** * Lookup a cast by its FID and hash. * @summary By FID and Hash * @param {CastsApiLookupCastByHashAndFidRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof CastsApi * @returns {Promise<CastAdd>} A promise that resolves to a `CastAdd` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-cast-by-hash-and-fid) * */ lookupCastByHashAndFid(requestParameters, options) { return (0, exports.CastsApiFp)(this.configuration).lookupCastByHashAndFid(requestParameters.fid, requestParameters.hash, options).then((request) => request(this.axios, this.basePath)); } } exports.CastsApi = CastsApi;