@neynar/nodejs-sdk
Version:
SDK to interact with Neynar APIs (https://docs.neynar.com/reference/quickstart)
464 lines (463 loc) • 27.7 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.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.FetchSubscriptionsForFidSubscriptionProviderEnum = exports.FetchSubscribersForFidSubscriptionProviderEnum = exports.FetchSubscribedToForFidSubscriptionProviderEnum = exports.SubscribersApi = exports.SubscribersApiFactory = exports.SubscribersApiFp = exports.SubscribersApiAxiosParamCreator = 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");
/**
* SubscribersApi - axios parameter creator
* @export
*/
const SubscribersApiAxiosParamCreator = function (configuration) {
return {
/**
* Fetch what FIDs and contracts a FID is subscribed to.
* @summary Subscribed to
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {FetchSubscribedToForFidSubscriptionProviderEnum} subscriptionProvider The provider of the subscription.
* @param {number} [viewerFid]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscribedToResponse>} A promise that resolves to a `SubscribedToResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribed-to-for-fid)
*
*/
fetchSubscribedToForFid: async (fid, subscriptionProvider, viewerFid, options = {}) => {
// verify required parameter 'fid' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscribedToForFid', 'fid', fid);
// verify required parameter 'subscriptionProvider' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscribedToForFid', 'subscriptionProvider', subscriptionProvider);
const localVarPath = `/v2/farcaster/user/subscribed_to/`;
// 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 (subscriptionProvider !== undefined) {
localVarQueryParameter['subscription_provider'] = subscriptionProvider;
}
(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 subscribers for a given FID\'s contracts. Doesn\'t return addresses that don\'t have an FID.
* @summary Subscribers of a user
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {FetchSubscribersForFidSubscriptionProviderEnum} subscriptionProvider The provider of the subscription.
* @param {number} [viewerFid]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscribersResponse>} A promise that resolves to a `SubscribersResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribers-for-fid)
*
*/
fetchSubscribersForFid: async (fid, subscriptionProvider, viewerFid, options = {}) => {
// verify required parameter 'fid' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscribersForFid', 'fid', fid);
// verify required parameter 'subscriptionProvider' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscribersForFid', 'subscriptionProvider', subscriptionProvider);
const localVarPath = `/v2/farcaster/user/subscribers/`;
// 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 (subscriptionProvider !== undefined) {
localVarQueryParameter['subscription_provider'] = subscriptionProvider;
}
(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,
};
},
/**
* Check if a wallet address is subscribed to a given STP (Hypersub) contract.
* @summary Hypersub subscription check
* @param {string} addresses Comma separated list of Ethereum addresses, up to 350 at a time
* @param {string} contractAddress Ethereum address of the STP contract
* @param {string} chainId Chain ID of the STP contract
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscriptionCheckResponse>} A promise that resolves to a `SubscriptionCheckResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscription-check)
*
*/
fetchSubscriptionCheck: async (addresses, contractAddress, chainId, options = {}) => {
// verify required parameter 'addresses' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscriptionCheck', 'addresses', addresses);
// verify required parameter 'contractAddress' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscriptionCheck', 'contractAddress', contractAddress);
// verify required parameter 'chainId' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscriptionCheck', 'chainId', chainId);
const localVarPath = `/v2/stp/subscription_check/`;
// 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 (addresses !== undefined) {
localVarQueryParameter['addresses'] = addresses;
}
if (contractAddress !== undefined) {
localVarQueryParameter['contract_address'] = contractAddress;
}
if (chainId !== undefined) {
localVarQueryParameter['chain_id'] = chainId;
}
(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 created subscriptions for a given FID\'s.
* @summary Subscriptions created by FID
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {FetchSubscriptionsForFidSubscriptionProviderEnum} subscriptionProvider The provider of the subscription.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscriptionsResponse>} A promise that resolves to a `SubscriptionsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscriptions-for-fid)
*
*/
fetchSubscriptionsForFid: async (fid, subscriptionProvider, options = {}) => {
// verify required parameter 'fid' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscriptionsForFid', 'fid', fid);
// verify required parameter 'subscriptionProvider' is not null or undefined
(0, common_1.assertParamExists)('fetchSubscriptionsForFid', 'subscriptionProvider', subscriptionProvider);
const localVarPath = `/v2/farcaster/user/subscriptions_created/`;
// 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 (subscriptionProvider !== undefined) {
localVarQueryParameter['subscription_provider'] = subscriptionProvider;
}
(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.SubscribersApiAxiosParamCreator = SubscribersApiAxiosParamCreator;
/**
* SubscribersApi - functional programming interface
* @export
*/
const SubscribersApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.SubscribersApiAxiosParamCreator)(configuration);
return {
/**
* Fetch what FIDs and contracts a FID is subscribed to.
* @summary Subscribed to
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {FetchSubscribedToForFidSubscriptionProviderEnum} subscriptionProvider The provider of the subscription.
* @param {number} [viewerFid]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscribedToResponse>} A promise that resolves to a `SubscribedToResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribed-to-for-fid)
*
*/
async fetchSubscribedToForFid(fid, subscriptionProvider, viewerFid, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchSubscribedToForFid(fid, subscriptionProvider, viewerFid, 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['SubscribersApi.fetchSubscribedToForFid']) === 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 subscribers for a given FID\'s contracts. Doesn\'t return addresses that don\'t have an FID.
* @summary Subscribers of a user
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {FetchSubscribersForFidSubscriptionProviderEnum} subscriptionProvider The provider of the subscription.
* @param {number} [viewerFid]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscribersResponse>} A promise that resolves to a `SubscribersResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribers-for-fid)
*
*/
async fetchSubscribersForFid(fid, subscriptionProvider, viewerFid, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchSubscribersForFid(fid, subscriptionProvider, viewerFid, 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['SubscribersApi.fetchSubscribersForFid']) === 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);
},
/**
* Check if a wallet address is subscribed to a given STP (Hypersub) contract.
* @summary Hypersub subscription check
* @param {string} addresses Comma separated list of Ethereum addresses, up to 350 at a time
* @param {string} contractAddress Ethereum address of the STP contract
* @param {string} chainId Chain ID of the STP contract
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscriptionCheckResponse>} A promise that resolves to a `SubscriptionCheckResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscription-check)
*
*/
async fetchSubscriptionCheck(addresses, contractAddress, chainId, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchSubscriptionCheck(addresses, contractAddress, chainId, 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['SubscribersApi.fetchSubscriptionCheck']) === 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 created subscriptions for a given FID\'s.
* @summary Subscriptions created by FID
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {FetchSubscriptionsForFidSubscriptionProviderEnum} subscriptionProvider The provider of the subscription.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscriptionsResponse>} A promise that resolves to a `SubscriptionsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscriptions-for-fid)
*
*/
async fetchSubscriptionsForFid(fid, subscriptionProvider, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchSubscriptionsForFid(fid, subscriptionProvider, 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['SubscribersApi.fetchSubscriptionsForFid']) === 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.SubscribersApiFp = SubscribersApiFp;
/**
* SubscribersApi - factory interface
* @export
*/
const SubscribersApiFactory = function (configuration, basePath, axios) {
const localVarFp = (0, exports.SubscribersApiFp)(configuration);
return {
/**
* Fetch what FIDs and contracts a FID is subscribed to.
* @summary Subscribed to
* @param {SubscribersApiFetchSubscribedToForFidRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscribedToResponse>} A promise that resolves to a `SubscribedToResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribed-to-for-fid)
*
*/
fetchSubscribedToForFid(requestParameters, options) {
return localVarFp.fetchSubscribedToForFid(requestParameters.fid, requestParameters.subscriptionProvider, requestParameters.viewerFid, options).then((request) => request(axios, basePath));
},
/**
* Fetch subscribers for a given FID\'s contracts. Doesn\'t return addresses that don\'t have an FID.
* @summary Subscribers of a user
* @param {SubscribersApiFetchSubscribersForFidRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscribersResponse>} A promise that resolves to a `SubscribersResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribers-for-fid)
*
*/
fetchSubscribersForFid(requestParameters, options) {
return localVarFp.fetchSubscribersForFid(requestParameters.fid, requestParameters.subscriptionProvider, requestParameters.viewerFid, options).then((request) => request(axios, basePath));
},
/**
* Check if a wallet address is subscribed to a given STP (Hypersub) contract.
* @summary Hypersub subscription check
* @param {SubscribersApiFetchSubscriptionCheckRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscriptionCheckResponse>} A promise that resolves to a `SubscriptionCheckResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscription-check)
*
*/
fetchSubscriptionCheck(requestParameters, options) {
return localVarFp.fetchSubscriptionCheck(requestParameters.addresses, requestParameters.contractAddress, requestParameters.chainId, options).then((request) => request(axios, basePath));
},
/**
* Fetch created subscriptions for a given FID\'s.
* @summary Subscriptions created by FID
* @param {SubscribersApiFetchSubscriptionsForFidRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<SubscriptionsResponse>} A promise that resolves to a `SubscriptionsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscriptions-for-fid)
*
*/
fetchSubscriptionsForFid(requestParameters, options) {
return localVarFp.fetchSubscriptionsForFid(requestParameters.fid, requestParameters.subscriptionProvider, options).then((request) => request(axios, basePath));
},
};
};
exports.SubscribersApiFactory = SubscribersApiFactory;
/**
* SubscribersApi - object-oriented interface
* @export
* @class SubscribersApi
* @extends {BaseAPI}
*/
class SubscribersApi extends base_1.BaseAPI {
/**
* Fetch what FIDs and contracts a FID is subscribed to.
* @summary Subscribed to
* @param {SubscribersApiFetchSubscribedToForFidRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SubscribersApi
* @returns {Promise<SubscribedToResponse>} A promise that resolves to a `SubscribedToResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribed-to-for-fid)
*
*/
fetchSubscribedToForFid(requestParameters, options) {
return (0, exports.SubscribersApiFp)(this.configuration).fetchSubscribedToForFid(requestParameters.fid, requestParameters.subscriptionProvider, requestParameters.viewerFid, options).then((request) => request(this.axios, this.basePath));
}
/**
* Fetch subscribers for a given FID\'s contracts. Doesn\'t return addresses that don\'t have an FID.
* @summary Subscribers of a user
* @param {SubscribersApiFetchSubscribersForFidRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SubscribersApi
* @returns {Promise<SubscribersResponse>} A promise that resolves to a `SubscribersResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscribers-for-fid)
*
*/
fetchSubscribersForFid(requestParameters, options) {
return (0, exports.SubscribersApiFp)(this.configuration).fetchSubscribersForFid(requestParameters.fid, requestParameters.subscriptionProvider, requestParameters.viewerFid, options).then((request) => request(this.axios, this.basePath));
}
/**
* Check if a wallet address is subscribed to a given STP (Hypersub) contract.
* @summary Hypersub subscription check
* @param {SubscribersApiFetchSubscriptionCheckRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SubscribersApi
* @returns {Promise<SubscriptionCheckResponse>} A promise that resolves to a `SubscriptionCheckResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscription-check)
*
*/
fetchSubscriptionCheck(requestParameters, options) {
return (0, exports.SubscribersApiFp)(this.configuration).fetchSubscriptionCheck(requestParameters.addresses, requestParameters.contractAddress, requestParameters.chainId, options).then((request) => request(this.axios, this.basePath));
}
/**
* Fetch created subscriptions for a given FID\'s.
* @summary Subscriptions created by FID
* @param {SubscribersApiFetchSubscriptionsForFidRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SubscribersApi
* @returns {Promise<SubscriptionsResponse>} A promise that resolves to a `SubscriptionsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-subscriptions-for-fid)
*
*/
fetchSubscriptionsForFid(requestParameters, options) {
return (0, exports.SubscribersApiFp)(this.configuration).fetchSubscriptionsForFid(requestParameters.fid, requestParameters.subscriptionProvider, options).then((request) => request(this.axios, this.basePath));
}
}
exports.SubscribersApi = SubscribersApi;
/**
* @export
*/
exports.FetchSubscribedToForFidSubscriptionProviderEnum = {
FabricStp: 'fabric_stp'
};
/**
* @export
*/
exports.FetchSubscribersForFidSubscriptionProviderEnum = {
FabricStp: 'fabric_stp',
Paragraph: 'paragraph'
};
/**
* @export
*/
exports.FetchSubscriptionsForFidSubscriptionProviderEnum = {
FabricStp: 'fabric_stp'
};