Skip to content

Commit

Permalink
update validateFrameAction to take in channelFollowContext, updates f…
Browse files Browse the repository at this point in the history
…etchTrendingChannels return type

update validateFrameAction to take in channelFollowContext, updates fetchTrendingChannels return type
  • Loading branch information
Shreyaschorge authored Apr 16, 2024
2 parents 8c916a9 + 493ba39 commit c293197
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 57 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.19.0",
"version": "1.19.1",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
28 changes: 15 additions & 13 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
FrameValidateListResponse,
AuthorizationUrlResponse,
AuthorizationUrlResponseType,
TrendingChannelResponse,
} from "./v2/openapi-farcaster";

import {
Expand Down Expand Up @@ -1912,18 +1913,18 @@ export class NeynarAPIClient {
*
* @param {number} fid - The FID of the user whose notifications are being fetched.
* @param {Object} [options] - Optional parameters to tailor the request.
* @param {number} [options.limit] - The maximum number of users to be returned in the response.
* Defaults to 25, with a maximum allowable value of 50.
* @param {number} [options.limit=15] - The maximum number of users to be returned in the response.
* Defaults to 15, with a maximum allowable value of 25.
* @param {string} [options.cursor] - A pagination cursor for fetching specific subsets of results.
* Omit this parameter for the initial request. Use it for paginated retrieval of subsequent data.
*
* @returns {Promise<NotificationsResponse>} A promise that resolves to a `NotificationsResponse` object,
* containing the user's notifications.
*
* @example
* // Example: Fetch the first 30 notifications for a user
* // Example: Fetch the first 25 notifications for a user
* client.fetchAllNotifications(3, {
* limit: 30,
* limit: 25,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request
* }).then(response => {
* console.log('User Notifications:', response);
Expand All @@ -1946,18 +1947,18 @@ export class NeynarAPIClient {
* @param {number} fid - The FID of the user whose channel notifications are being fetched.
* @param {string} channelIds - channel_ids (find list of all channels here - https://docs.neynar.com/reference/list-all-channels)
* @param {Object} [options] - Optional parameters for the request.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 50).
* @param {number} [options.limit=15] - Number of results to retrieve (default 15, max 25).
* @param {string} [options.cursor] - Pagination cursor for the next set of results,
* omit this parameter for the initial request.
*
* @returns {Promise<NotificationsResponse>} A promise that resolves to a `NotificationsResponse` object,
* containing the channel-specific notifications for the user.
*
* @example
* // Example: Retrieve channel notifications for a user limit to 30 results
* // Example: Retrieve channel notifications for a user limit to 25 results
* client.fetchChannelNotificationsForUser(3, ['neynar', 'farcaster'],
* {
* limit: 30,
* limit: 25,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request.
* }).then(response => {
* console.log('Channel Notifications:', response);
Expand Down Expand Up @@ -2132,7 +2133,7 @@ export class NeynarAPIClient {
* @param {string} [options.cursor] - Pagination cursor for the next set of results.
* Omit this parameter for the initial request to start from the first page.
*
* @returns {Promise<ChannelListResponse>} A promise that resolves to a `ChannelListResponse` object,
* @returns {Promise<TrendingChannelResponse>} A promise that resolves to a `ChannelListResponse` object,
* containing a list of trending channels based on the specified time window.
*
* @example
Expand All @@ -2151,7 +2152,7 @@ export class NeynarAPIClient {
limit?: number;
cursor?: string;
}
): Promise<ChannelListResponse> {
): Promise<TrendingChannelResponse> {
return await this.clients.v2.fetchTrendingChannels(timeWindow, options);
}

Expand All @@ -2163,7 +2164,7 @@ export class NeynarAPIClient {
* @param {number} fid - The FID of the user for whom notifications are being fetched.
* @param {Array<string>} parentUrls - An array of parent URLs to specify the channels.
* @param {Object} [options] - Optional parameters for customizing the response.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 50).
* @param {number} [options.limit=15] - Number of results to retrieve (default 15, max 25).
* @param {string} [options.cursor] - Pagination cursor for the next set of results,
* omit this parameter for the initial request.
*
Expand All @@ -2172,7 +2173,7 @@ export class NeynarAPIClient {
*
* @example
* // Example: Retrieve notifications for a user based on specific parent URLs
* client.fetchNotificationsByParentUrlForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:1/erc721:0xfd8427165df67df6d7fd689ae67c8ebf56d9ca61'], { limit: 30 }).then(response => {
* client.fetchNotificationsByParentUrlForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:1/erc721:0xfd8427165df67df6d7fd689ae67c8ebf56d9ca61'], { limit: 25 }).then(response => {
* console.log('User Notifications:', response);
* });
*
Expand Down Expand Up @@ -2478,14 +2479,14 @@ export class NeynarAPIClient {
* @param {boolean} [options.castReactionContext] - Adds viewer_context inside the cast object to indicate whether the interactor reacted to the cast housing the frame.
* @param {boolean} [options.followContext] - Adds viewer_context inside the user (interactor) object to indicate whether the interactor follows or is followed by the cast author.
* @param {boolean} [options.signerContext] - Adds context about the app used by the user inside `frame.action`.
*
* @param {boolean} [options.channelFollowContext] - Adds context about the channel the cast was in the cast object, as well as following information inside `frame.action`.
* @returns {Promise<ValidateFrameActionResponse>} A promise that resolves to a `ValidateFrameActionResponse` object,
* indicating the outcome of the frame action validation, potentially enriched with specified contexts.
*
* @example
* // Example: Validate a frame action with additional context for cast reactions and follow actions
* const messageBytesInHex = '0a49080d1085940118f6a6a32e20018201390a1a86db69b3ffdf6ab8acb6872b69ccbe7eb6a67af7ab71e95aa69f10021a1908ef011214237025b322fd03a9ddc7ec6c078fb9c56d1a72111214e3d88aeb2d0af356024e0c693f31c11b42c76b721801224043cb2f3fcbfb5dafce110e934b9369267cf3d1aef06f51ce653dc01700fc7b778522eb7873fd60dda4611376200076caf26d40a736d3919ce14e78a684e4d30b280132203a66717c82d728beb3511b05975c6603275c7f6a0600370bf637b9ecd2bd231e';
* client.validateFrameAction(messageBytesInHex, { castReactionContext: false, followContext: true, signerContext: true }).then(response => {
* client.validateFrameAction(messageBytesInHex, { castReactionContext: false, followContext: true, signerContext: true, channelFollowContext: true }).then(response => {
* console.log('Frame Action Validation:', response);
* });
*
Expand All @@ -2497,6 +2498,7 @@ export class NeynarAPIClient {
castReactionContext?: boolean;
followContext?: boolean;
signerContext?: boolean;
channelFollowContext?: boolean;
}
): Promise<ValidateFrameActionResponse> {
return await this.clients.v2.validateFrameAction(
Expand Down
28 changes: 17 additions & 11 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
FrameValidateAnalyticsResponse,
AuthorizationUrlResponse,
AuthorizationUrlResponseType,
TrendingChannelResponse,
} from "./openapi-farcaster";
import axios, { AxiosError, AxiosInstance } from "axios";
import { silentLogger, Logger } from "../common/logger";
Expand Down Expand Up @@ -1558,17 +1559,17 @@ export class NeynarV2APIClient {
*
* @param {number} fid - The FID of the user whose notifications are being fetched.
* @param {Object} [options] - Optional parameters to tailor the request.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 50).
* @param {number} [options.limit=15] - Number of results to retrieve (default 15, max 25).
* @param {string} [options.cursor] - Pagination cursor for the next set of results,
* omit this parameter for the initial request.
*
* @returns {Promise<NotificationsResponse>} A promise that resolves to a `NotificationsResponse` object,
* containing the user's notifications.
*
* @example
* // Example: Fetch the first 30 notifications for a user
* // Example: Fetch the first 25 notifications for a user
* client.fetchAllNotifications(3, {
* limit: 30,
* limit: 25,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request
* }).then(response => {
* console.log('User Notifications:', response);
Expand Down Expand Up @@ -1597,18 +1598,18 @@ export class NeynarV2APIClient {
* @param {number} fid - The FID of the user whose channel notifications are being fetched.
* @param {string} channelIds - channel_ids (find list of all channels here - https://docs.neynar.com/reference/list-all-channels)
* @param {Object} [options] - Optional parameters for the request.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 50).
* @param {number} [options.limit=15] - Number of results to retrieve (default 15, max 25).
* @param {string} [options.cursor] - Pagination cursor for the next set of results,
* omit this parameter for the initial request.
*
* @returns {Promise<NotificationsResponse>} A promise that resolves to a `NotificationsResponse` object,
* containing the channel-specific notifications for the user.
*
* @example
* // Example: Retrieve channel notifications for a user limit to 30 results
* // Example: Retrieve channel notifications for a user limit to 25 results
* client.fetchChannelNotificationsForUser(3, ['neynar', 'farcaster'],
* {
* limit: 30,
* limit: 25,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request.
* }).then(response => {
* console.log('Channel Notifications:', response);
Expand Down Expand Up @@ -1640,7 +1641,7 @@ export class NeynarV2APIClient {
* @param {number} fid - The FID of the user for whom notifications are being fetched.
* @param {Array<string>} parentUrls - An array of parent URLs to specify the channels.
* @param {Object} [options] - Optional parameters for customizing the response.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 50).
* @param {number} [options.limit=15] - Number of results to retrieve (default 15, max 25).
* @param {string} [options.cursor] - Pagination cursor for the next set of results,
* omit this parameter for the initial request.
*
Expand All @@ -1649,7 +1650,7 @@ export class NeynarV2APIClient {
*
* @example
* // Example: Retrieve notifications for a user based on specific parent URLs
* client.fetchNotificationsByParentUrlForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:1/erc721:0xfd8427165df67df6d7fd689ae67c8ebf56d9ca61'], { limit: 30 }).then(response => {
* client.fetchNotificationsByParentUrlForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:1/erc721:0xfd8427165df67df6d7fd689ae67c8ebf56d9ca61'], { limit: 25 }).then(response => {
* console.log('User Notifications:', response);
* });
*
Expand Down Expand Up @@ -1877,7 +1878,7 @@ export class NeynarV2APIClient {
* @param {string} [options.cursor] - Pagination cursor for the next set of results.
* Omit this parameter for the initial request to start from the first page.
*
* @returns {Promise<ChannelListResponse>} A promise that resolves to a `ChannelListResponse` object,
* @returns {Promise<TrendingChannelResponse>} A promise that resolves to a `ChannelListResponse` object,
* containing a list of trending channels based on the specified time window.
*
* @example
Expand All @@ -1896,7 +1897,7 @@ export class NeynarV2APIClient {
limit?: number;
cursor?: string;
}
): Promise<ChannelListResponse> {
): Promise<TrendingChannelResponse> {
const response = await this.apis.channel.trendingChannels(
this.apiKey,
timeWindow,
Expand Down Expand Up @@ -2245,14 +2246,15 @@ export class NeynarV2APIClient {
* @param {boolean} [options.castReactionContext] - Adds viewer_context inside the cast object to indicate whether the interactor reacted to the cast housing the frame.
* @param {boolean} [options.followContext] - Adds viewer_context inside the user (interactor) object to indicate whether the interactor follows or is followed by the cast author.
* @param {boolean} [options.signerContext] - Adds context about the app used by the user inside `frame.action`.
* @param {boolean} [options.channelFollowContext] - Adds context about the channel the cast was in the cast object, as well as following information inside `frame.action`.
*
* @returns {Promise<ValidateFrameActionResponse>} A promise that resolves to a `ValidateFrameActionResponse` object,
* indicating the outcome of the frame action validation, potentially enriched with specified contexts.
*
* @example
* // Example: Validate a frame action with additional context for cast reactions and follow actions
* const messageBytesInHex = '0a49080d1085940118f6a6a32e20018201390a1a86db69b3ffdf6ab8acb6872b69ccbe7eb6a67af7ab71e95aa69f10021a1908ef011214237025b322fd03a9ddc7ec6c078fb9c56d1a72111214e3d88aeb2d0af356024e0c693f31c11b42c76b721801224043cb2f3fcbfb5dafce110e934b9369267cf3d1aef06f51ce653dc01700fc7b778522eb7873fd60dda4611376200076caf26d40a736d3919ce14e78a684e4d30b280132203a66717c82d728beb3511b05975c6603275c7f6a0600370bf637b9ecd2bd231e';
* client.validateFrameAction(messageBytesInHex, { castReactionContext: false, followContext: true, signerContext: true }).then(response => {
* client.validateFrameAction(messageBytesInHex, { castReactionContext: false, followContext: true, signerContext: true, channelFollowContext: true }).then(response => {
* console.log('Frame Action Validation:', response);
* });
*
Expand All @@ -2264,6 +2266,7 @@ export class NeynarV2APIClient {
castReactionContext?: boolean;
followContext?: boolean;
signerContext?: boolean;
channelFollowContext?: boolean;
}
): Promise<ValidateFrameActionResponse> {
const reqBody: ValidateFrameRequest = {
Expand All @@ -2277,6 +2280,9 @@ export class NeynarV2APIClient {
...(typeof options?.signerContext !== "undefined" && {
signer_context: options?.signerContext,
}),
...(typeof options?.channelFollowContext !== "undefined" && {
channel_follow_context: options?.channelFollowContext,
}),
};

const response = await this.apis.frame.validateFrame(this.apiKey, reqBody);
Expand Down
4 changes: 3 additions & 1 deletion src/neynar-api/v2/openapi-farcaster/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ models/cast-with-interactions.ts
models/cast.ts
models/casts-response-result.ts
models/casts-response.ts
models/channel-activity.ts
models/channel-list-response.ts
models/channel-response.ts
models/channel-viewer-context.ts
models/channel.ts
models/conversation-response.ts
models/conversation-conversation.ts
models/conversation.ts
models/dehydrated-follower.ts
models/delete-cast-req-body.ts
Expand Down Expand Up @@ -128,6 +129,7 @@ models/storage-allocation.ts
models/storage-allocations-response.ts
models/storage-object.ts
models/storage-usage-response.ts
models/trending-channel-response.ts
models/update-user-req-body.ts
models/user-dehydrated.ts
models/user-fidresponse.ts
Expand Down
6 changes: 4 additions & 2 deletions src/neynar-api/v2/openapi-farcaster/apis/channel-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { ChannelResponse } from '../models';
// @ts-ignore
import { ErrorRes } from '../models';
// @ts-ignore
import { TrendingChannelResponse } from '../models';
// @ts-ignore
import { UsersActiveChannelsResponse } from '../models';
// @ts-ignore
import { UsersResponse } from '../models';
Expand Down Expand Up @@ -571,7 +573,7 @@ export const ChannelApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async trendingChannels(apiKey: string, timeWindow?: '1d' | '7d' | '30d', limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ChannelListResponse>> {
async trendingChannels(apiKey: string, timeWindow?: '1d' | '7d' | '30d', limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<TrendingChannelResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.trendingChannels(apiKey, timeWindow, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
Expand Down Expand Up @@ -687,7 +689,7 @@ export const ChannelApiFactory = function (configuration?: Configuration, basePa
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
trendingChannels(apiKey: string, timeWindow?: '1d' | '7d' | '30d', limit?: number, cursor?: string, options?: any): AxiosPromise<ChannelListResponse> {
trendingChannels(apiKey: string, timeWindow?: '1d' | '7d' | '30d', limit?: number, cursor?: string, options?: any): AxiosPromise<TrendingChannelResponse> {
return localVarFp.trendingChannels(apiKey, timeWindow, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
Expand Down
10 changes: 5 additions & 5 deletions src/neynar-api/v2/openapi-farcaster/apis/user-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
// @ts-ignore
import { AddVerificationReqBody } from '../models';
import { AddVerificationReqBody } from '../models';
// @ts-ignore
import { AuthorizationUrlResponse } from '../models';
// @ts-ignore
Expand Down Expand Up @@ -199,11 +199,11 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
* @summary Fetch authorization url
* @param {string} apiKey API key required for authentication.
* @param {string} clientId
* @param {AuthorizationUrlResponseType} responseType
* @param {AuthorizationUrlResponseType} responseType
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
fetchAuthorizationUrl: async (apiKey: string, clientId: string, responseType: AuthorizationUrlResponseType , options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
fetchAuthorizationUrl: async (apiKey: string, clientId: string, responseType: AuthorizationUrlResponseType, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('fetchAuthorizationUrl', 'apiKey', apiKey)
// verify required parameter 'clientId' is not null or undefined
Expand Down Expand Up @@ -754,7 +754,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @summary Fetch authorization url
* @param {string} apiKey API key required for authentication.
* @param {string} clientId
* @param {AuthorizationUrlResponseType} responseType
* @param {AuthorizationUrlResponseType} responseType
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
Expand Down Expand Up @@ -936,7 +936,7 @@ export const UserApiFactory = function (configuration?: Configuration, basePath?
* @summary Fetch authorization url
* @param {string} apiKey API key required for authentication.
* @param {string} clientId
* @param {AuthorizationUrlResponseType} responseType
* @param {AuthorizationUrlResponseType} responseType
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ export const AuthorizationUrlResponseType = {
Code: 'code'
} as const;

export type AuthorizationUrlResponseType = typeof AuthorizationUrlResponseType[keyof typeof AuthorizationUrlResponseType];
export type AuthorizationUrlResponseType = typeof AuthorizationUrlResponseType[keyof typeof AuthorizationUrlResponseType];



Loading

0 comments on commit c293197

Please sign in to comment.