Skip to content

Commit

Permalink
Add channel related ops in feed and notifications apis
Browse files Browse the repository at this point in the history
Add channel related ops in feed and notifications apis
  • Loading branch information
Shreyaschorge authored Dec 22, 2023
2 parents e79c2ce + 4e8612d commit 7218096
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 43 deletions.
20 changes: 10 additions & 10 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1124,16 +1124,15 @@ export class NeynarAPIClient {
*
* @param {FeedType} feedType - Type of the feed, defaults to 'following' but can be set to 'filter' for specific filtering.
* @param {Object} [options] - Optional parameters for customizing the feed.
* @param {FilterType} [options.filterType] - Used when feedType is 'filter'. Determines the filter criteria (e.g., 'fids' or 'parent_url').
* @param {FilterType} [options.filterType] - Used when feed_type=filter. Can be set to fids (requires fids) or parent_url (requires parent_url) or channel_id (requires channel_id)
* @param {number} [options.fid] - FID of the user whose feed is being created. Required unless a 'filterType' is provided.
* @param {Array<number>} [options.fids] - Used for creating a feed based on a list of FIDs. Requires 'feedType' and 'filterType'.
* @param {string} [options.parentUrl] - Used for fetching content under a specific parent URL. Requires 'feedType' and 'filterType'.
* @param {string} [options.channelId] Used when filter_type=channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [options.embedUrl] - Used when filter_type=embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [options.withRecasts] - Whether to include recasts in the response. True by default.
* @param {number} [options.limit] - The maximum number of users to be returned in the response.
* Defaults to 25, with a maximum allowable value of 100.
* @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.
* @param {number} [options.limit] - Number of results to retrieve, with a default of 25 and a maximum of 100.
* @param {string} [options.cursor] - Pagination cursor for fetching specific subsets of results.
*
* @returns {Promise<FeedResponse>} A promise that resolves to a `FeedResponse` object,
* containing the requested feed data.
Expand All @@ -1153,6 +1152,7 @@ export class NeynarAPIClient {
fid?: number;
fids?: number[];
parentUrl?: string;
channelId?: string;
embedUrl?: string;
limit?: number;
cursor?: string;
Expand Down Expand Up @@ -1309,7 +1309,7 @@ export class NeynarAPIClient {
* their parent URLs.
*
* @param {number} fid - The FID of the user whose channel notifications are being fetched.
* @param {Array<string>} parentUrls - An array of channel parent URLs.
* @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 {string} [options.cursor] - Pagination cursor for the next set of results,
Expand All @@ -1320,10 +1320,10 @@ export class NeynarAPIClient {
*
* @example
* // Example: Retrieve channel notifications for a user limit to 30 results
* client.fetchChannelNotificationsForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:7777777/erc721:0x5556efe18d87f132054fbd4ba9afc13ebb1b0594'],
* client.fetchChannelNotificationsForUser(3, ['neynar', 'farcaster'],
* {
* limit: 30,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request
* // cursor: "nextPageCursor" // Omit this parameter for the initial request.
* }).then(response => {
* console.log('Channel Notifications:', response);
* });
Expand All @@ -1332,12 +1332,12 @@ export class NeynarAPIClient {
*/
public async fetchChannelNotificationsForUser(
fid: number,
parentUrls: string[],
channelIds: string[],
options?: { cursor?: string; limit?: number }
): Promise<NotificationsResponse> {
return await this.clients.v2.fetchChannelNotificationsForUser(
fid,
parentUrls,
channelIds,
options
);
}
Expand Down
15 changes: 9 additions & 6 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,11 @@ export class NeynarV2APIClient {
*
* @param {FeedType} feedType - Type of the feed, defaults to 'following' but can be set to 'filter' for specific filtering.
* @param {Object} [options] - Optional parameters for customizing the feed.
* @param {FilterType} [options.filterType] - Used when feedType is 'filter'. Determines the filter criteria (e.g., 'fids' or 'parent_url').
* @param {FilterType} [options.filterType] - Used when feed_type=filter. Can be set to fids (requires fids) or parent_url (requires parent_url) or channel_id (requires channel_id)
* @param {number} [options.fid] - FID of the user whose feed is being created. Required unless a 'filterType' is provided.
* @param {Array<number>} [options.fids] - Used for creating a feed based on a list of FIDs. Requires 'feedType' and 'filterType'.
* @param {string} [options.parentUrl] - Used for fetching content under a specific parent URL. Requires 'feedType' and 'filterType'.
* @param {string} [options.channelId] Used when filter_type=channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [options.embedUrl] - Used when filter_type=embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [options.withRecasts] - Whether to include recasts in the response. True by default.
* @param {number} [options.limit] - Number of results to retrieve, with a default of 25 and a maximum of 100.
Expand All @@ -700,6 +701,7 @@ export class NeynarV2APIClient {
fid?: number;
fids?: number[];
parentUrl?: string;
channelId?: string;
embedUrl?: string;
limit?: number;
cursor?: string;
Expand All @@ -715,6 +717,7 @@ export class NeynarV2APIClient {
options?.fid,
_fids,
options?.parentUrl,
options?.channelId,
options?.embedUrl,
options?.withRecasts,
options?.limit,
Expand Down Expand Up @@ -898,7 +901,7 @@ export class NeynarV2APIClient {
* their parent URLs.
*
* @param {number} fid - The FID of the user whose channel notifications are being fetched.
* @param {Array<string>} parentUrls - An array of channel parent URLs.
* @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 {string} [options.cursor] - Pagination cursor for the next set of results,
Expand All @@ -909,7 +912,7 @@ export class NeynarV2APIClient {
*
* @example
* // Example: Retrieve channel notifications for a user limit to 30 results
* client.fetchChannelNotificationsForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:7777777/erc721:0x5556efe18d87f132054fbd4ba9afc13ebb1b0594'],
* client.fetchChannelNotificationsForUser(3, ['neynar', 'farcaster'],
* {
* limit: 30,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request.
Expand All @@ -921,14 +924,14 @@ export class NeynarV2APIClient {
*/
public async fetchChannelNotificationsForUser(
fid: number,
parentUrls: string[],
channelIds: string[],
options?: { cursor?: string; limit?: number }
): Promise<NotificationsResponse> {
const _parentUrls = parentUrls.join(",");
const _channelIds = channelIds.join(",");
const response = await this.apis.notifications.notificationsChannel(
this.apiKey,
fid,
_parentUrls,
_channelIds,
options?.limit,
options?.cursor
);
Expand Down
30 changes: 19 additions & 11 deletions src/neynar-api/v2/openapi-farcaster/apis/feed-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ export const FeedApiAxiosParamCreator = function (configuration?: Configuration)
* @summary Retrieve casts based on filters
* @param {string} apiKey API key required for authentication.
* @param {FeedType} feedType Defaults to following (requires fid or address). If set to filter (requires filter_type)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url) or channel_id (requires channel_id)
* @param {number} [fid] (Optional) fid of user whose feed you want to create. By default, the API expects this field, except if you pass a filter_type
* @param {string} [fids] Used when filter_type&#x3D;fids . Create a feed based on a list of fids. Max array size is 250. Requires feed_type and filter_type.
* @param {string} [parentUrl] Used when filter_type&#x3D;parent_url can be used to fetch content under any parent url e.g. FIP-2 channels on Warpcast. Requires feed_type and filter_type
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @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}
*/
feed: async (apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
feed: async (apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('feed', 'apiKey', apiKey)
// verify required parameter 'feedType' is not null or undefined
Expand Down Expand Up @@ -88,6 +89,10 @@ export const FeedApiAxiosParamCreator = function (configuration?: Configuration)
localVarQueryParameter['parent_url'] = parentUrl;
}

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

if (embedUrl !== undefined) {
localVarQueryParameter['embed_url'] = embedUrl;
}
Expand Down Expand Up @@ -134,19 +139,20 @@ export const FeedApiFp = function(configuration?: Configuration) {
* @summary Retrieve casts based on filters
* @param {string} apiKey API key required for authentication.
* @param {FeedType} feedType Defaults to following (requires fid or address). If set to filter (requires filter_type)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url) or channel_id (requires channel_id)
* @param {number} [fid] (Optional) fid of user whose feed you want to create. By default, the API expects this field, except if you pass a filter_type
* @param {string} [fids] Used when filter_type&#x3D;fids . Create a feed based on a list of fids. Max array size is 250. Requires feed_type and filter_type.
* @param {string} [parentUrl] Used when filter_type&#x3D;parent_url can be used to fetch content under any parent url e.g. FIP-2 channels on Warpcast. Requires feed_type and filter_type
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @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 feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FeedResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.feed(apiKey, feedType, filterType, fid, fids, parentUrl, embedUrl, withRecasts, limit, cursor, options);
async feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FeedResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
Expand All @@ -164,19 +170,20 @@ export const FeedApiFactory = function (configuration?: Configuration, basePath?
* @summary Retrieve casts based on filters
* @param {string} apiKey API key required for authentication.
* @param {FeedType} feedType Defaults to following (requires fid or address). If set to filter (requires filter_type)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url) or channel_id (requires channel_id)
* @param {number} [fid] (Optional) fid of user whose feed you want to create. By default, the API expects this field, except if you pass a filter_type
* @param {string} [fids] Used when filter_type&#x3D;fids . Create a feed based on a list of fids. Max array size is 250. Requires feed_type and filter_type.
* @param {string} [parentUrl] Used when filter_type&#x3D;parent_url can be used to fetch content under any parent url e.g. FIP-2 channels on Warpcast. Requires feed_type and filter_type
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @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}
*/
feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: any): AxiosPromise<FeedResponse> {
return localVarFp.feed(apiKey, feedType, filterType, fid, fids, parentUrl, embedUrl, withRecasts, limit, cursor, options).then((request) => request(axios, basePath));
feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: any): AxiosPromise<FeedResponse> {
return localVarFp.feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, limit, cursor, options).then((request) => request(axios, basePath));
},
};
};
Expand All @@ -193,10 +200,11 @@ export class FeedApi extends BaseAPI {
* @summary Retrieve casts based on filters
* @param {string} apiKey API key required for authentication.
* @param {FeedType} feedType Defaults to following (requires fid or address). If set to filter (requires filter_type)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url)
* @param {FilterType} [filterType] Used when feed_type&#x3D;filter. Can be set to fids (requires fids) or parent_url (requires parent_url) or channel_id (requires channel_id)
* @param {number} [fid] (Optional) fid of user whose feed you want to create. By default, the API expects this field, except if you pass a filter_type
* @param {string} [fids] Used when filter_type&#x3D;fids . Create a feed based on a list of fids. Max array size is 250. Requires feed_type and filter_type.
* @param {string} [parentUrl] Used when filter_type&#x3D;parent_url can be used to fetch content under any parent url e.g. FIP-2 channels on Warpcast. Requires feed_type and filter_type
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
Expand All @@ -205,7 +213,7 @@ export class FeedApi extends BaseAPI {
* @throws {RequiredError}
* @memberof FeedApi
*/
public feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return FeedApiFp(this.configuration).feed(apiKey, feedType, filterType, fid, fids, parentUrl, embedUrl, withRecasts, limit, cursor, options).then((request) => request(this.axios, this.basePath));
public feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return FeedApiFp(this.configuration).feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}
}
Loading

0 comments on commit 7218096

Please sign in to comment.