UNPKG

@neynar/nodejs-sdk

Version:

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

338 lines (337 loc) 19.9 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.115.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.AppHostGetEventEventEnum = exports.AppHostApi = exports.AppHostApiFactory = exports.AppHostApiFp = exports.AppHostApiAxiosParamCreator = 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"); /** * AppHostApi - axios parameter creator * @export */ const AppHostApiAxiosParamCreator = function (configuration) { return { /** * Returns event object for app host events. Used if the app host intends to sign the event message instead of using Neynar-hosted signers. * @summary Generate event * @param {string} appDomain The domain of the mini app * @param {number} fid The FID of the user who initiated the event * @param {AppHostGetEventEventEnum} event The type of event * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostGetEventResponse>} A promise that resolves to a `AppHostGetEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-event) * */ appHostGetEvent: async (appDomain, fid, event, options = {}) => { // verify required parameter 'appDomain' is not null or undefined (0, common_1.assertParamExists)('appHostGetEvent', 'appDomain', appDomain); // verify required parameter 'fid' is not null or undefined (0, common_1.assertParamExists)('appHostGetEvent', 'fid', fid); // verify required parameter 'event' is not null or undefined (0, common_1.assertParamExists)('appHostGetEvent', 'event', event); const localVarPath = `/v2/farcaster/app_host/user/event/`; // 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 (appDomain !== undefined) { localVarQueryParameter['app_domain'] = appDomain; } if (fid !== undefined) { localVarQueryParameter['fid'] = fid; } if (event !== undefined) { localVarQueryParameter['event'] = event; } (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, }; }, /** * Returns the current notification state for a specific user across all mini app domains in this app host. Shows which domains have notifications enabled. * @summary Enabled notifications * @param {number} fid The FID of the user * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostUserStateResponse>} A promise that resolves to a `AppHostUserStateResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-user-state) * */ appHostGetUserState: async (fid, options = {}) => { // verify required parameter 'fid' is not null or undefined (0, common_1.assertParamExists)('appHostGetUserState', 'fid', fid); const localVarPath = `/v2/farcaster/app_host/user/state/`; // 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; } (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 an app_host event to the domain\'s webhook. Events such as enabling or disabling notifications for a user. Provide either a signed message or the signer UUID of an authorized neynar-hosted signers. * @summary Send event * @param {AppHostPostEventReqBody} appHostPostEventReqBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostPostEventResponse>} A promise that resolves to a `AppHostPostEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-post-event) * */ appHostPostEvent: async (appHostPostEventReqBody, options = {}) => { // verify required parameter 'appHostPostEventReqBody' is not null or undefined (0, common_1.assertParamExists)('appHostPostEvent', 'appHostPostEventReqBody', appHostPostEventReqBody); const localVarPath = `/v2/farcaster/app_host/user/event/`; // 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)(appHostPostEventReqBody, localVarRequestOptions, configuration); return { url: (0, common_1.toPathString)(localVarUrlObj), options: localVarRequestOptions, }; }, }; }; exports.AppHostApiAxiosParamCreator = AppHostApiAxiosParamCreator; /** * AppHostApi - functional programming interface * @export */ const AppHostApiFp = function (configuration) { const localVarAxiosParamCreator = (0, exports.AppHostApiAxiosParamCreator)(configuration); return { /** * Returns event object for app host events. Used if the app host intends to sign the event message instead of using Neynar-hosted signers. * @summary Generate event * @param {string} appDomain The domain of the mini app * @param {number} fid The FID of the user who initiated the event * @param {AppHostGetEventEventEnum} event The type of event * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostGetEventResponse>} A promise that resolves to a `AppHostGetEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-event) * */ async appHostGetEvent(appDomain, fid, event, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.appHostGetEvent(appDomain, fid, event, 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['AppHostApi.appHostGetEvent']) === 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); }, /** * Returns the current notification state for a specific user across all mini app domains in this app host. Shows which domains have notifications enabled. * @summary Enabled notifications * @param {number} fid The FID of the user * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostUserStateResponse>} A promise that resolves to a `AppHostUserStateResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-user-state) * */ async appHostGetUserState(fid, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.appHostGetUserState(fid, 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['AppHostApi.appHostGetUserState']) === 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 an app_host event to the domain\'s webhook. Events such as enabling or disabling notifications for a user. Provide either a signed message or the signer UUID of an authorized neynar-hosted signers. * @summary Send event * @param {AppHostPostEventReqBody} appHostPostEventReqBody * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostPostEventResponse>} A promise that resolves to a `AppHostPostEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-post-event) * */ async appHostPostEvent(appHostPostEventReqBody, options) { var _a, _b, _c; const localVarAxiosArgs = await localVarAxiosParamCreator.appHostPostEvent(appHostPostEventReqBody, 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['AppHostApi.appHostPostEvent']) === 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.AppHostApiFp = AppHostApiFp; /** * AppHostApi - factory interface * @export */ const AppHostApiFactory = function (configuration, basePath, axios) { const localVarFp = (0, exports.AppHostApiFp)(configuration); return { /** * Returns event object for app host events. Used if the app host intends to sign the event message instead of using Neynar-hosted signers. * @summary Generate event * @param {AppHostApiAppHostGetEventRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostGetEventResponse>} A promise that resolves to a `AppHostGetEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-event) * */ appHostGetEvent(requestParameters, options) { return localVarFp.appHostGetEvent(requestParameters.appDomain, requestParameters.fid, requestParameters.event, options).then((request) => request(axios, basePath)); }, /** * Returns the current notification state for a specific user across all mini app domains in this app host. Shows which domains have notifications enabled. * @summary Enabled notifications * @param {AppHostApiAppHostGetUserStateRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostUserStateResponse>} A promise that resolves to a `AppHostUserStateResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-user-state) * */ appHostGetUserState(requestParameters, options) { return localVarFp.appHostGetUserState(requestParameters.fid, options).then((request) => request(axios, basePath)); }, /** * Post an app_host event to the domain\'s webhook. Events such as enabling or disabling notifications for a user. Provide either a signed message or the signer UUID of an authorized neynar-hosted signers. * @summary Send event * @param {AppHostApiAppHostPostEventRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @returns {Promise<AppHostPostEventResponse>} A promise that resolves to a `AppHostPostEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-post-event) * */ appHostPostEvent(requestParameters, options) { return localVarFp.appHostPostEvent(requestParameters.appHostPostEventReqBody, options).then((request) => request(axios, basePath)); }, }; }; exports.AppHostApiFactory = AppHostApiFactory; /** * AppHostApi - object-oriented interface * @export * @class AppHostApi * @extends {BaseAPI} */ class AppHostApi extends base_1.BaseAPI { /** * Returns event object for app host events. Used if the app host intends to sign the event message instead of using Neynar-hosted signers. * @summary Generate event * @param {AppHostApiAppHostGetEventRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AppHostApi * @returns {Promise<AppHostGetEventResponse>} A promise that resolves to a `AppHostGetEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-event) * */ appHostGetEvent(requestParameters, options) { return (0, exports.AppHostApiFp)(this.configuration).appHostGetEvent(requestParameters.appDomain, requestParameters.fid, requestParameters.event, options).then((request) => request(this.axios, this.basePath)); } /** * Returns the current notification state for a specific user across all mini app domains in this app host. Shows which domains have notifications enabled. * @summary Enabled notifications * @param {AppHostApiAppHostGetUserStateRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AppHostApi * @returns {Promise<AppHostUserStateResponse>} A promise that resolves to a `AppHostUserStateResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-get-user-state) * */ appHostGetUserState(requestParameters, options) { return (0, exports.AppHostApiFp)(this.configuration).appHostGetUserState(requestParameters.fid, options).then((request) => request(this.axios, this.basePath)); } /** * Post an app_host event to the domain\'s webhook. Events such as enabling or disabling notifications for a user. Provide either a signed message or the signer UUID of an authorized neynar-hosted signers. * @summary Send event * @param {AppHostApiAppHostPostEventRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof AppHostApi * @returns {Promise<AppHostPostEventResponse>} A promise that resolves to a `AppHostPostEventResponse` object * * For more information, refer to the [API documentation](https://docs.neynar.com/reference/app-host-post-event) * */ appHostPostEvent(requestParameters, options) { return (0, exports.AppHostApiFp)(this.configuration).appHostPostEvent(requestParameters.appHostPostEventReqBody, options).then((request) => request(this.axios, this.basePath)); } } exports.AppHostApi = AppHostApi; /** * @export */ exports.AppHostGetEventEventEnum = { FrameAdded: 'frame_added', FrameRemoved: 'frame_removed', NotificationsEnabled: 'notifications_enabled', NotificationsDisabled: 'notifications_disabled' };