@neynar/nodejs-sdk
Version:
SDK to interact with Neynar APIs (https://docs.neynar.com/reference/quickstart)
322 lines (321 loc) • 18.4 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.StorageApi = exports.StorageApiFactory = exports.StorageApiFp = exports.StorageApiAxiosParamCreator = 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");
/**
* StorageApi - axios parameter creator
* @export
*/
const StorageApiAxiosParamCreator = function (configuration) {
return {
/**
* This api will help you rent units of storage for an year for a specific FID. A storage unit lets you store 5000 casts, 2500 reactions and 2500 links. Requires x-wallet-id header.
* @summary Buy storage
* @param {string} xWalletId Wallet ID to use for transactions
* @param {BuyStorageReqBody} buyStorageReqBody
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/buy-storage)
*
*/
buyStorage: async (xWalletId, buyStorageReqBody, options = {}) => {
// verify required parameter 'xWalletId' is not null or undefined
(0, common_1.assertParamExists)('buyStorage', 'xWalletId', xWalletId);
// verify required parameter 'buyStorageReqBody' is not null or undefined
(0, common_1.assertParamExists)('buyStorage', 'buyStorageReqBody', buyStorageReqBody);
const localVarPath = `/v2/farcaster/storage/buy/`;
// 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);
if (xWalletId != null) {
localVarHeaderParameter['x-wallet-id'] = String(xWalletId);
}
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)(buyStorageReqBody, localVarRequestOptions, configuration);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Fetches storage allocations for a given user
* @summary Allocation of user
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-allocations)
*
*/
lookupUserStorageAllocations: async (fid, options = {}) => {
// verify required parameter 'fid' is not null or undefined
(0, common_1.assertParamExists)('lookupUserStorageAllocations', 'fid', fid);
const localVarPath = `/v2/farcaster/storage/allocations/`;
// 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,
};
},
/**
* Fetches storage usage for a given user
* @summary Usage of user
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageUsageResponse>} A promise that resolves to a `StorageUsageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-usage)
*
*/
lookupUserStorageUsage: async (fid, options = {}) => {
// verify required parameter 'fid' is not null or undefined
(0, common_1.assertParamExists)('lookupUserStorageUsage', 'fid', fid);
const localVarPath = `/v2/farcaster/storage/usage/`;
// 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,
};
},
};
};
exports.StorageApiAxiosParamCreator = StorageApiAxiosParamCreator;
/**
* StorageApi - functional programming interface
* @export
*/
const StorageApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.StorageApiAxiosParamCreator)(configuration);
return {
/**
* This api will help you rent units of storage for an year for a specific FID. A storage unit lets you store 5000 casts, 2500 reactions and 2500 links. Requires x-wallet-id header.
* @summary Buy storage
* @param {string} xWalletId Wallet ID to use for transactions
* @param {BuyStorageReqBody} buyStorageReqBody
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/buy-storage)
*
*/
async buyStorage(xWalletId, buyStorageReqBody, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.buyStorage(xWalletId, buyStorageReqBody, 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['StorageApi.buyStorage']) === 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 storage allocations for a given user
* @summary Allocation of user
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-allocations)
*
*/
async lookupUserStorageAllocations(fid, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.lookupUserStorageAllocations(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['StorageApi.lookupUserStorageAllocations']) === 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 storage usage for a given user
* @summary Usage of user
* @param {number} fid The unique identifier of a farcaster user or app (unsigned integer)
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageUsageResponse>} A promise that resolves to a `StorageUsageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-usage)
*
*/
async lookupUserStorageUsage(fid, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.lookupUserStorageUsage(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['StorageApi.lookupUserStorageUsage']) === 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.StorageApiFp = StorageApiFp;
/**
* StorageApi - factory interface
* @export
*/
const StorageApiFactory = function (configuration, basePath, axios) {
const localVarFp = (0, exports.StorageApiFp)(configuration);
return {
/**
* This api will help you rent units of storage for an year for a specific FID. A storage unit lets you store 5000 casts, 2500 reactions and 2500 links. Requires x-wallet-id header.
* @summary Buy storage
* @param {StorageApiBuyStorageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/buy-storage)
*
*/
buyStorage(requestParameters, options) {
return localVarFp.buyStorage(requestParameters.xWalletId, requestParameters.buyStorageReqBody, options).then((request) => request(axios, basePath));
},
/**
* Fetches storage allocations for a given user
* @summary Allocation of user
* @param {StorageApiLookupUserStorageAllocationsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-allocations)
*
*/
lookupUserStorageAllocations(requestParameters, options) {
return localVarFp.lookupUserStorageAllocations(requestParameters.fid, options).then((request) => request(axios, basePath));
},
/**
* Fetches storage usage for a given user
* @summary Usage of user
* @param {StorageApiLookupUserStorageUsageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<StorageUsageResponse>} A promise that resolves to a `StorageUsageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-usage)
*
*/
lookupUserStorageUsage(requestParameters, options) {
return localVarFp.lookupUserStorageUsage(requestParameters.fid, options).then((request) => request(axios, basePath));
},
};
};
exports.StorageApiFactory = StorageApiFactory;
/**
* StorageApi - object-oriented interface
* @export
* @class StorageApi
* @extends {BaseAPI}
*/
class StorageApi extends base_1.BaseAPI {
/**
* This api will help you rent units of storage for an year for a specific FID. A storage unit lets you store 5000 casts, 2500 reactions and 2500 links. Requires x-wallet-id header.
* @summary Buy storage
* @param {StorageApiBuyStorageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof StorageApi
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/buy-storage)
*
*/
buyStorage(requestParameters, options) {
return (0, exports.StorageApiFp)(this.configuration).buyStorage(requestParameters.xWalletId, requestParameters.buyStorageReqBody, options).then((request) => request(this.axios, this.basePath));
}
/**
* Fetches storage allocations for a given user
* @summary Allocation of user
* @param {StorageApiLookupUserStorageAllocationsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof StorageApi
* @returns {Promise<StorageAllocationsResponse>} A promise that resolves to a `StorageAllocationsResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-allocations)
*
*/
lookupUserStorageAllocations(requestParameters, options) {
return (0, exports.StorageApiFp)(this.configuration).lookupUserStorageAllocations(requestParameters.fid, options).then((request) => request(this.axios, this.basePath));
}
/**
* Fetches storage usage for a given user
* @summary Usage of user
* @param {StorageApiLookupUserStorageUsageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof StorageApi
* @returns {Promise<StorageUsageResponse>} A promise that resolves to a `StorageUsageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/lookup-user-storage-usage)
*
*/
lookupUserStorageUsage(requestParameters, options) {
return (0, exports.StorageApiFp)(this.configuration).lookupUserStorageUsage(requestParameters.fid, options).then((request) => request(this.axios, this.basePath));
}
}
exports.StorageApi = StorageApi;