UNPKG

@neynar/nodejs-sdk

Version:

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

243 lines (242 loc) 13.7 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.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.SubscriptionApi = exports.SubscriptionApiFactory = exports.SubscriptionApiFp = exports.SubscriptionApiAxiosParamCreator = 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"); /** * SubscriptionApi - axios parameter creator * @export */ const SubscriptionApiAxiosParamCreator = function (configuration) { return { /** * 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.SubscriptionApiAxiosParamCreator = SubscriptionApiAxiosParamCreator; /** * SubscriptionApi - functional programming interface * @export */ const SubscriptionApiFp = function (configuration) { const localVarAxiosParamCreator = (0, exports.SubscriptionApiAxiosParamCreator)(configuration); return { /** * 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['SubscriptionApi.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['SubscriptionApi.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.SubscriptionApiFp = SubscriptionApiFp; /** * SubscriptionApi - factory interface * @export */ const SubscriptionApiFactory = function (configuration, basePath, axios) { const localVarFp = (0, exports.SubscriptionApiFp)(configuration); return { /** * 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 {SubscriptionApiUpgradeRequest} 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 {SubscriptionApiUpgradePreviewRequest} 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.SubscriptionApiFactory = SubscriptionApiFactory; /** * SubscriptionApi - object-oriented interface * @export * @class SubscriptionApi * @extends {BaseAPI} */ class SubscriptionApi extends base_1.BaseAPI { /** * 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 {SubscriptionApiUpgradeRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SubscriptionApi * @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.SubscriptionApiFp)(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 {SubscriptionApiUpgradePreviewRequest} requestParameters Request parameters. * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof SubscriptionApi * @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.SubscriptionApiFp)(this.configuration).upgradePreview(requestParameters.newPlan, requestParameters.productCategory, options).then((request) => request(this.axios, this.basePath)); } } exports.SubscriptionApi = SubscriptionApi; /** * @export */ exports.UpgradePreviewProductCategoryEnum = { Api: 'API', Studio: 'STUDIO' };