@neynar/nodejs-sdk
Version:
SDK to interact with Neynar APIs (https://docs.neynar.com/reference/quickstart)
230 lines (229 loc) • 12.6 kB
JavaScript
;
/* tslint:disable */
/* eslint-disable */
/**
* Farcaster Hub API
* Perform basic queries of Farcaster state via the REST API of a Farcaster hub. See the [Neynar docs](https://docs.neynar.com/reference) for more details.
*
* The version of the OpenAPI document: 2.35.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.MessageApi = exports.MessageApiFactory = exports.MessageApiFp = exports.MessageApiAxiosParamCreator = 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");
/**
* MessageApi - axios parameter creator
* @export
*/
const MessageApiAxiosParamCreator = function (configuration) {
return {
/**
* Submit a message to the Farcaster network.
* @summary Submit signed message
* @param {File} body A Message is a delta operation on the Farcaster network. The message protobuf is an envelope that wraps a MessageData object and contains a hash and signature which can verify its authenticity.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Message>} A promise that resolves to a `Message` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/submit-signed-message)
*
*/
publishMessage: async (body, options = {}) => {
// verify required parameter 'body' is not null or undefined
(0, common_1.assertParamExists)('publishMessage', 'body', body);
const localVarPath = `/v1/submitMessage`;
// 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/octet-stream';
(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)(body, localVarRequestOptions, configuration);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Validate a message on the Farcaster network.
* @summary Validate signed message
* @param {File} body A Message is a delta operation on the Farcaster network. The message protobuf is an envelope that wraps a MessageData object and contains a hash and signature which can verify its authenticity.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<ValidateMessageResponse>} A promise that resolves to a `ValidateMessageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/validate-message)
*
*/
validateMessage: async (body, options = {}) => {
// verify required parameter 'body' is not null or undefined
(0, common_1.assertParamExists)('validateMessage', 'body', body);
const localVarPath = `/v1/validateMessage`;
// 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/octet-stream';
(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)(body, localVarRequestOptions, configuration);
return {
url: (0, common_1.toPathString)(localVarUrlObj),
options: localVarRequestOptions,
};
},
};
};
exports.MessageApiAxiosParamCreator = MessageApiAxiosParamCreator;
/**
* MessageApi - functional programming interface
* @export
*/
const MessageApiFp = function (configuration) {
const localVarAxiosParamCreator = (0, exports.MessageApiAxiosParamCreator)(configuration);
return {
/**
* Submit a message to the Farcaster network.
* @summary Submit signed message
* @param {File} body A Message is a delta operation on the Farcaster network. The message protobuf is an envelope that wraps a MessageData object and contains a hash and signature which can verify its authenticity.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Message>} A promise that resolves to a `Message` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/submit-signed-message)
*
*/
async publishMessage(body, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.publishMessage(body, 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['MessageApi.publishMessage']) === 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);
},
/**
* Validate a message on the Farcaster network.
* @summary Validate signed message
* @param {File} body A Message is a delta operation on the Farcaster network. The message protobuf is an envelope that wraps a MessageData object and contains a hash and signature which can verify its authenticity.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<ValidateMessageResponse>} A promise that resolves to a `ValidateMessageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/validate-message)
*
*/
async validateMessage(body, options) {
var _a, _b, _c;
const localVarAxiosArgs = await localVarAxiosParamCreator.validateMessage(body, 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['MessageApi.validateMessage']) === 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.MessageApiFp = MessageApiFp;
/**
* MessageApi - factory interface
* @export
*/
const MessageApiFactory = function (configuration, basePath, axios) {
const localVarFp = (0, exports.MessageApiFp)(configuration);
return {
/**
* Submit a message to the Farcaster network.
* @summary Submit signed message
* @param {MessageApiPublishMessageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<Message>} A promise that resolves to a `Message` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/submit-signed-message)
*
*/
publishMessage(requestParameters, options) {
return localVarFp.publishMessage(requestParameters.body, options).then((request) => request(axios, basePath));
},
/**
* Validate a message on the Farcaster network.
* @summary Validate signed message
* @param {MessageApiValidateMessageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<ValidateMessageResponse>} A promise that resolves to a `ValidateMessageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/validate-message)
*
*/
validateMessage(requestParameters, options) {
return localVarFp.validateMessage(requestParameters.body, options).then((request) => request(axios, basePath));
},
};
};
exports.MessageApiFactory = MessageApiFactory;
/**
* MessageApi - object-oriented interface
* @export
* @class MessageApi
* @extends {BaseAPI}
*/
class MessageApi extends base_1.BaseAPI {
/**
* Submit a message to the Farcaster network.
* @summary Submit signed message
* @param {MessageApiPublishMessageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof MessageApi
* @returns {Promise<Message>} A promise that resolves to a `Message` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/submit-signed-message)
*
*/
publishMessage(requestParameters, options) {
return (0, exports.MessageApiFp)(this.configuration).publishMessage(requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
/**
* Validate a message on the Farcaster network.
* @summary Validate signed message
* @param {MessageApiValidateMessageRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof MessageApi
* @returns {Promise<ValidateMessageResponse>} A promise that resolves to a `ValidateMessageResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/validate-message)
*
*/
validateMessage(requestParameters, options) {
return (0, exports.MessageApiFp)(this.configuration).validateMessage(requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
}
exports.MessageApi = MessageApi;