@neynar/nodejs-sdk
Version:
SDK to interact with Neynar APIs (https://docs.neynar.com/reference/quickstart)
318 lines (317 loc) • 18.2 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.175.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.UpgradePreviewProductCategoryEnum = exports.PortalApi = exports.PortalApiFactory = exports.PortalApiFp = exports.PortalApiAxiosParamCreator = 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");
/**
* PortalApi - axios parameter creator
* @export
*/
const PortalApiAxiosParamCreator = function (configuration) {
return {
/**
* Retrieves billing and subscription details for the current organization, including plan status, product category, billing email, and effective plan.
* @summary Get billing information for the current organization
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Billing200Response>} A promise that resolves to a `Billing200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/billing)
*
*/
billing: async (options = {}) => {
const localVarPath = `/portal/organization/billing`;
// 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);
(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,
};
},
/**
* Applies a subscription plan change for the current organization and returns the applied credit, charge amount, and whether the change takes effect immediately.
* @summary Process subscription upgrade with credit
* @param {UpgradeRequest} upgradeRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Upgrade200Response>} A promise that resolves to a `Upgrade200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade)
*
*/
upgrade: async (upgradeRequest, options = {}) => {
// verify required parameter 'upgradeRequest' is not null or undefined
(0, common_1.assertParamExists)('upgrade', 'upgradeRequest', upgradeRequest);
const localVarPath = `/portal/subscription/upgrade`;
// 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)(upgradeRequest, localVarRequestOptions, configuration);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Calculates the billing impact of changing to a new subscription plan, including available credit, charge amount, and whether the billing date or usage carryover changes.
* @summary Get upgrade preview with credit calculation
* @param {string} newPlan
* @param {UpgradePreviewProductCategoryEnum} [productCategory]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<UpgradePreview200Response>} A promise that resolves to a `UpgradePreview200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade-preview)
*
*/
upgradePreview: async (newPlan, productCategory, options = {}) => {
// verify required parameter 'newPlan' is not null or undefined
(0, common_1.assertParamExists)('upgradePreview', 'newPlan', newPlan);
const localVarPath = `/portal/subscription/upgrade/preview`;
// 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 (newPlan !== undefined) {
localVarQueryParameter['newPlan'] = newPlan;
}
if (productCategory !== undefined) {
localVarQueryParameter['productCategory'] = productCategory;
}
(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.PortalApiAxiosParamCreator = PortalApiAxiosParamCreator;
/**
* PortalApi - functional programming interface
* @export
*/
const PortalApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.PortalApiAxiosParamCreator)(configuration);
return {
/**
* Retrieves billing and subscription details for the current organization, including plan status, product category, billing email, and effective plan.
* @summary Get billing information for the current organization
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Billing200Response>} A promise that resolves to a `Billing200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/billing)
*
*/
async billing(options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.billing(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['PortalApi.billing']) === 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);
},
/**
* Applies a subscription plan change for the current organization and returns the applied credit, charge amount, and whether the change takes effect immediately.
* @summary Process subscription upgrade with credit
* @param {UpgradeRequest} upgradeRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Upgrade200Response>} A promise that resolves to a `Upgrade200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade)
*
*/
async upgrade(upgradeRequest, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.upgrade(upgradeRequest, 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['PortalApi.upgrade']) === 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);
},
/**
* Calculates the billing impact of changing to a new subscription plan, including available credit, charge amount, and whether the billing date or usage carryover changes.
* @summary Get upgrade preview with credit calculation
* @param {string} newPlan
* @param {UpgradePreviewProductCategoryEnum} [productCategory]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<UpgradePreview200Response>} A promise that resolves to a `UpgradePreview200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade-preview)
*
*/
async upgradePreview(newPlan, productCategory, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.upgradePreview(newPlan, productCategory, 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['PortalApi.upgradePreview']) === 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.PortalApiFp = PortalApiFp;
/**
* PortalApi - factory interface
* @export
*/
const PortalApiFactory = function (configuration, basePath, axios) {
const localVarFp = (0, exports.PortalApiFp)(configuration);
return {
/**
* Retrieves billing and subscription details for the current organization, including plan status, product category, billing email, and effective plan.
* @summary Get billing information for the current organization
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Billing200Response>} A promise that resolves to a `Billing200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/billing)
*
*/
billing(options) {
return localVarFp.billing(options).then((request) => request(axios, basePath));
},
/**
* Applies a subscription plan change for the current organization and returns the applied credit, charge amount, and whether the change takes effect immediately.
* @summary Process subscription upgrade with credit
* @param {PortalApiUpgradeRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Upgrade200Response>} A promise that resolves to a `Upgrade200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade)
*
*/
upgrade(requestParameters, options) {
return localVarFp.upgrade(requestParameters.upgradeRequest, options).then((request) => request(axios, basePath));
},
/**
* Calculates the billing impact of changing to a new subscription plan, including available credit, charge amount, and whether the billing date or usage carryover changes.
* @summary Get upgrade preview with credit calculation
* @param {PortalApiUpgradePreviewRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<UpgradePreview200Response>} A promise that resolves to a `UpgradePreview200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade-preview)
*
*/
upgradePreview(requestParameters, options) {
return localVarFp.upgradePreview(requestParameters.newPlan, requestParameters.productCategory, options).then((request) => request(axios, basePath));
},
};
};
exports.PortalApiFactory = PortalApiFactory;
/**
* PortalApi - object-oriented interface
* @export
* @class PortalApi
* @extends {BaseAPI}
*/
class PortalApi extends base_1.BaseAPI {
/**
* Retrieves billing and subscription details for the current organization, including plan status, product category, billing email, and effective plan.
* @summary Get billing information for the current organization
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PortalApi
* @returns {Promise<Billing200Response>} A promise that resolves to a `Billing200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/billing)
*
*/
billing(options) {
return (0, exports.PortalApiFp)(this.configuration).billing(options).then((request) => request(this.axios, this.basePath));
}
/**
* Applies a subscription plan change for the current organization and returns the applied credit, charge amount, and whether the change takes effect immediately.
* @summary Process subscription upgrade with credit
* @param {PortalApiUpgradeRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PortalApi
* @returns {Promise<Upgrade200Response>} A promise that resolves to a `Upgrade200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade)
*
*/
upgrade(requestParameters, options) {
return (0, exports.PortalApiFp)(this.configuration).upgrade(requestParameters.upgradeRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
* Calculates the billing impact of changing to a new subscription plan, including available credit, charge amount, and whether the billing date or usage carryover changes.
* @summary Get upgrade preview with credit calculation
* @param {PortalApiUpgradePreviewRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PortalApi
* @returns {Promise<UpgradePreview200Response>} A promise that resolves to a `UpgradePreview200Response` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/upgrade-preview)
*
*/
upgradePreview(requestParameters, options) {
return (0, exports.PortalApiFp)(this.configuration).upgradePreview(requestParameters.newPlan, requestParameters.productCategory, options).then((request) => request(this.axios, this.basePath));
}
}
exports.PortalApi = PortalApi;
/**
* @export
*/
exports.UpgradePreviewProductCategoryEnum = {
Api: 'API',
Studio: 'STUDIO'
};