Skip to content

Commit

Permalink
Feature/fetchFramesOnlyFeed and validateFrameAction methods
Browse files Browse the repository at this point in the history
Feature/fetchFramesOnlyFeed and validateFrameAction methods
  • Loading branch information
Shreyaschorge authored Jan 30, 2024
2 parents 3101c2a + 88e0260 commit 6524f4f
Show file tree
Hide file tree
Showing 11 changed files with 456 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neynar/nodejs-sdk",
"version": "1.8.0",
"version": "1.9.0",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
54 changes: 54 additions & 0 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
FnameAvailabilityResponse,
FrameAction,
FrameActionResponse,
ValidateFrameActionResponse,
} from "./v2/openapi-farcaster";

import {
Expand Down Expand Up @@ -1322,6 +1323,34 @@ export class NeynarAPIClient {
return await this.clients.v2.fetchRepliesAndRecastsForUser(fid, options);
}

/**
* Retrieves a feed consisting only of casts with Frames, presented in reverse chronological order.
* This method is ideal for users who are interested in viewing a feed of content that exclusively
* includes casts with frame actions.
*
* @param {Object} [options] - Optional parameters to tailor the response.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 100).
* @param {string} [options.cursor] - Pagination cursor for the next set of results,
* omit this parameter for the initial request.
*
* @returns {Promise<FeedResponse>} A promise that resolves to a `FeedResponse` object,
* containing a feed of casts with Frames.
*
* @example
* // Example: Retrieve a feed of casts with Frames
* client.fetchFramesOnlyFeed({ limit: 30 }).then(response => {
* console.log('Frames Only Feed:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/feed-frames).
*/
public async fetchFramesOnlyFeed(options?: {
limit?: number;
cursor?: string;
}) {
return await this.clients.v2.fetchFramesOnlyFeed(options);
}

// ------------ Reaction ------------

/**
Expand Down Expand Up @@ -1837,6 +1866,31 @@ export class NeynarAPIClient {
return await this.clients.v2.postFrameAction(signerUuid, castHash, action);
}

/**
* Validates a frame action against the Farcaster Hub. This method is essential for verifying
* the authenticity and integrity of a frame action by providing the message bytes from the
* frame action in hexadecimal format.
*
* @param {string} messageBytesInHex - The message bytes from the Frame Action provided in hexadecimal format.
*
* @returns {Promise<ValidateFrameActionResponse>} A promise that resolves to a `ValidateFrameActionResponse` object,
* indicating the validation result of the frame action.
*
* @example
* // Example: Validate a frame action
* const messageBytesInHex = '0a49080d1085940118f6a6a32e20018201390a1a86db69b3ffdf6ab8acb6872b69ccbe7eb6a67af7ab71e95aa69f10021a1908ef011214237025b322fd03a9ddc7ec6c078fb9c56d1a72111214e3d88aeb2d0af356024e0c693f31c11b42c76b721801224043cb2f3fcbfb5dafce110e934b9369267cf3d1aef06f51ce653dc01700fc7b778522eb7873fd60dda4611376200076caf26d40a736d3919ce14e78a684e4d30b280132203a66717c82d728beb3511b05975c6603275c7f6a0600370bf637b9ecd2bd231e';
* client.validateFrameAction(messageBytesInHex).then(response => {
* console.log('Frame Action Validation:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/validate-frame).
*/
public async validateFrameAction(
messageBytesInHex: string
): Promise<ValidateFrameActionResponse> {
return await this.clients.v2.validateFrameAction(messageBytesInHex);
}

// ------------ Recommendation ------------

/**
Expand Down
65 changes: 65 additions & 0 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import {
FrameApi,
FrameActionReqBody,
FrameAction,
ValidateFrameRequest,
ValidateFrameActionResponse,
} from "./openapi-farcaster";
import axios, { AxiosError, AxiosInstance } from "axios";
import { silentLogger, Logger } from "../common/logger";
Expand Down Expand Up @@ -929,6 +931,39 @@ export class NeynarV2APIClient {
return response.data;
}

/**
* Retrieves a feed consisting only of casts with Frames, presented in reverse chronological order.
* This method is ideal for users who are interested in viewing a feed of content that exclusively
* includes casts with frame actions.
*
* @param {Object} [options] - Optional parameters to tailor the response.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 100).
* @param {string} [options.cursor] - Pagination cursor for the next set of results,
* omit this parameter for the initial request.
*
* @returns {Promise<FeedResponse>} A promise that resolves to a `FeedResponse` object,
* containing a feed of casts with Frames.
*
* @example
* // Example: Retrieve a feed of casts with Frames
* client.fetchFramesOnlyFeed({ limit: 30 }).then(response => {
* console.log('Frames Only Feed:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/feed-frames).
*/
public async fetchFramesOnlyFeed(options?: {
limit?: number;
cursor?: string;
}) {
const response = await this.apis.feed.feedFrames(
this.apiKey,
options?.limit,
options?.cursor
);
return response.data;
}

// ------------ Reaction ------------

/**
Expand Down Expand Up @@ -1522,6 +1557,36 @@ export class NeynarV2APIClient {
return response.data;
}

/**
* Validates a frame action against the Farcaster Hub. This method is essential for verifying
* the authenticity and integrity of a frame action by providing the message bytes from the
* frame action in hexadecimal format.
*
* @param {string} messageBytesInHex - The message bytes from the Frame Action provided in hexadecimal format.
*
* @returns {Promise<ValidateFrameActionResponse>} A promise that resolves to a `ValidateFrameActionResponse` object,
* indicating the validation result of the frame action.
*
* @example
* // Example: Validate a frame action
* const messageBytesInHex = '0a49080d1085940118f6a6a32e20018201390a1a86db69b3ffdf6ab8acb6872b69ccbe7eb6a67af7ab71e95aa69f10021a1908ef011214237025b322fd03a9ddc7ec6c078fb9c56d1a72111214e3d88aeb2d0af356024e0c693f31c11b42c76b721801224043cb2f3fcbfb5dafce110e934b9369267cf3d1aef06f51ce653dc01700fc7b778522eb7873fd60dda4611376200076caf26d40a736d3919ce14e78a684e4d30b280132203a66717c82d728beb3511b05975c6603275c7f6a0600370bf637b9ecd2bd231e';
* client.validateFrameAction(messageBytesInHex).then(response => {
* console.log('Frame Action Validation:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/validate-frame).
*/
public async validateFrameAction(
messageBytesInHex: string
): Promise<ValidateFrameActionResponse> {
const reqBody: ValidateFrameRequest = {
message_bytes_in_hex: messageBytesInHex,
};

const response = await this.apis.frame.validateFrame(this.apiKey, reqBody);
return response.data;
}

// ------------ Recommendation ------------

/**
Expand Down
3 changes: 3 additions & 0 deletions src/neynar-api/v2/openapi-farcaster/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@ models/user-search-response-result.ts
models/user-search-response.ts
models/user-viewer-context.ts
models/user.ts
models/validate-frame-action-response.ts
models/validate-frame-request.ts
models/validated-frame-action.ts
86 changes: 86 additions & 0 deletions src/neynar-api/v2/openapi-farcaster/apis/feed-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,53 @@ export const FeedApiAxiosParamCreator = function (configuration?: Configuration)



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Retrieve feed of casts with Frames, reverse chronological order
* @param {string} apiKey API key required for authentication.
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
feedFrames: async (apiKey: string, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('feedFrames', 'apiKey', apiKey)
const localVarPath = `/farcaster/feed/frames`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}

if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}

if (apiKey != null) {
localVarHeaderParameter['api_key'] = String(apiKey);
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
Expand Down Expand Up @@ -415,6 +462,19 @@ export const FeedApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.feedFollowing(apiKey, fid, withRecasts, withReplies, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Retrieve feed of casts with Frames, reverse chronological order
* @param {string} apiKey API key required for authentication.
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async feedFrames(apiKey: string, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FeedResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.feedFrames(apiKey, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Retrieve 10 most popular casts for a given user FID; popularity based on replies, likes and recasts; sorted by most popular first
* @summary Retrieve 10 most popular casts for a user
Expand Down Expand Up @@ -502,6 +562,18 @@ export const FeedApiFactory = function (configuration?: Configuration, basePath?
feedFollowing(apiKey: string, fid: number, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options?: any): AxiosPromise<FeedResponse> {
return localVarFp.feedFollowing(apiKey, fid, withRecasts, withReplies, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Retrieve feed of casts with Frames, reverse chronological order
* @param {string} apiKey API key required for authentication.
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
feedFrames(apiKey: string, limit?: number, cursor?: string, options?: any): AxiosPromise<FeedResponse> {
return localVarFp.feedFrames(apiKey, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
* Retrieve 10 most popular casts for a given user FID; popularity based on replies, likes and recasts; sorted by most popular first
* @summary Retrieve 10 most popular casts for a user
Expand Down Expand Up @@ -593,6 +665,20 @@ export class FeedApi extends BaseAPI {
return FeedApiFp(this.configuration).feedFollowing(apiKey, fid, withRecasts, withReplies, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Retrieve feed of casts with Frames, reverse chronological order
* @param {string} apiKey API key required for authentication.
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof FeedApi
*/
public feedFrames(apiKey: string, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return FeedApiFp(this.configuration).feedFrames(apiKey, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}

/**
* Retrieve 10 most popular casts for a given user FID; popularity based on replies, likes and recasts; sorted by most popular first
* @summary Retrieve 10 most popular casts for a user
Expand Down
Loading

0 comments on commit 6524f4f

Please sign in to comment.