diff --git a/package.json b/package.json index 74d0cbec..9d0a95bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@neynar/nodejs-sdk", - "version": "1.1.1", + "version": "1.2.0", "description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)", "main": "./build/index.js", "types": "./build/index.d.ts", diff --git a/src/neynar-api/neynar-api-client.ts b/src/neynar-api/neynar-api-client.ts index f18f7411..2a117f94 100644 --- a/src/neynar-api/neynar-api-client.ts +++ b/src/neynar-api/neynar-api-client.ts @@ -1298,6 +1298,45 @@ export class NeynarAPIClient { return await this.clients.v2.fetchAllNotifications(fid, options); } + /** + * Retrieves a list of notifications for a user within specific channels. This method is useful for + * obtaining notifications related to user interactions within designated channels, identified by + * their parent URLs. + * + * @param {number} fid - The FID of the user whose channel notifications are being fetched. + * @param {Array} parentUrls - An array of channel parent URLs. + * @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, + * omit this parameter for the initial request. + * + * @returns {Promise} 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 + * client.fetchChannelNotificationsForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:7777777/erc721:0x5556efe18d87f132054fbd4ba9afc13ebb1b0594'], + * { + * limit: 30, + * // cursor: "nextPageCursor" // Omit this parameter for the initial request + * }).then(response => { + * console.log('Channel Notifications:', response); + * }); + * + * For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/notifications). + */ + public async fetchChannelNotificationsForUser( + fid: number, + parentUrls: string[], + options?: { cursor?: string; limit?: number } + ): Promise { + return await this.clients.v2.fetchChannelNotificationsForUser( + fid, + parentUrls, + options + ); + } + // ------------ Follows ------------ /** diff --git a/src/neynar-api/v2/client.ts b/src/neynar-api/v2/client.ts index 81a1edf9..ffc83a3d 100644 --- a/src/neynar-api/v2/client.ts +++ b/src/neynar-api/v2/client.ts @@ -882,6 +882,49 @@ export class NeynarV2APIClient { return response.data; } + /** + * Retrieves a list of notifications for a user within specific channels. This method is useful for + * obtaining notifications related to user interactions within designated channels, identified by + * their parent URLs. + * + * @param {number} fid - The FID of the user whose channel notifications are being fetched. + * @param {Array} parentUrls - An array of channel parent URLs. + * @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, + * omit this parameter for the initial request. + * + * @returns {Promise} 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 + * client.fetchChannelNotificationsForUser(3, ['chain://eip155:1/erc721:0xd4498134211baad5846ce70ce04e7c4da78931cc', 'chain://eip155:7777777/erc721:0x5556efe18d87f132054fbd4ba9afc13ebb1b0594'], + * { + * limit: 30, + * // cursor: "nextPageCursor" // Omit this parameter for the initial request. + * }).then(response => { + * console.log('Channel Notifications:', response); + * }); + * + * For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/notifications). + */ + public async fetchChannelNotificationsForUser( + fid: number, + parentUrls: string[], + options?: { cursor?: string; limit?: number } + ): Promise { + const _parentUrls = parentUrls.join(","); + const response = await this.apis.notifications.notificationsChannel( + this.apiKey, + fid, + _parentUrls, + options?.limit, + options?.cursor + ); + return response.data; + } + // ------------ Follows ------------ /** diff --git a/src/neynar-api/v2/openapi-farcaster/apis/cast-api.ts b/src/neynar-api/v2/openapi-farcaster/apis/cast-api.ts index 72b68105..3f7c7f63 100644 --- a/src/neynar-api/v2/openapi-farcaster/apis/cast-api.ts +++ b/src/neynar-api/v2/openapi-farcaster/apis/cast-api.ts @@ -99,10 +99,11 @@ export const CastApiAxiosParamCreator = function (configuration?: Configuration) * @summary Gets information about an array of casts * @param {string} apiKey API key required for authentication. * @param {string} casts Hashes of the cast to be retrived (Comma separated) + * @param {'trending' | 'likes' | 'recasts' | 'replies' | 'recent'} [sortType] Optional parameter to sort the casts based on different criteria * @param {*} [options] Override http request option. * @throws {RequiredError} */ - casts: async (apiKey: string, casts: string, options: AxiosRequestConfig = {}): Promise => { + casts: async (apiKey: string, casts: string, sortType?: 'trending' | 'likes' | 'recasts' | 'replies' | 'recent', options: AxiosRequestConfig = {}): Promise => { // verify required parameter 'apiKey' is not null or undefined assertParamExists('casts', 'apiKey', apiKey) // verify required parameter 'casts' is not null or undefined @@ -123,6 +124,10 @@ export const CastApiAxiosParamCreator = function (configuration?: Configuration) localVarQueryParameter['casts'] = casts; } + if (sortType !== undefined) { + localVarQueryParameter['sort_type'] = sortType; + } + if (apiKey != null) { localVarHeaderParameter['api_key'] = String(apiKey); } @@ -252,11 +257,12 @@ export const CastApiFp = function(configuration?: Configuration) { * @summary Gets information about an array of casts * @param {string} apiKey API key required for authentication. * @param {string} casts Hashes of the cast to be retrived (Comma separated) + * @param {'trending' | 'likes' | 'recasts' | 'replies' | 'recent'} [sortType] Optional parameter to sort the casts based on different criteria * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async casts(apiKey: string, casts: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.casts(apiKey, casts, options); + async casts(apiKey: string, casts: string, sortType?: 'trending' | 'likes' | 'recasts' | 'replies' | 'recent', options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.casts(apiKey, casts, sortType, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** @@ -310,11 +316,12 @@ export const CastApiFactory = function (configuration?: Configuration, basePath? * @summary Gets information about an array of casts * @param {string} apiKey API key required for authentication. * @param {string} casts Hashes of the cast to be retrived (Comma separated) + * @param {'trending' | 'likes' | 'recasts' | 'replies' | 'recent'} [sortType] Optional parameter to sort the casts based on different criteria * @param {*} [options] Override http request option. * @throws {RequiredError} */ - casts(apiKey: string, casts: string, options?: any): AxiosPromise { - return localVarFp.casts(apiKey, casts, options).then((request) => request(axios, basePath)); + casts(apiKey: string, casts: string, sortType?: 'trending' | 'likes' | 'recasts' | 'replies' | 'recent', options?: any): AxiosPromise { + return localVarFp.casts(apiKey, casts, sortType, options).then((request) => request(axios, basePath)); }, /** * Delete an existing cast. \\ (In order to delete a cast `signer_uuid` must be approved) @@ -367,12 +374,13 @@ export class CastApi extends BaseAPI { * @summary Gets information about an array of casts * @param {string} apiKey API key required for authentication. * @param {string} casts Hashes of the cast to be retrived (Comma separated) + * @param {'trending' | 'likes' | 'recasts' | 'replies' | 'recent'} [sortType] Optional parameter to sort the casts based on different criteria * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof CastApi */ - public casts(apiKey: string, casts: string, options?: AxiosRequestConfig) { - return CastApiFp(this.configuration).casts(apiKey, casts, options).then((request) => request(this.axios, this.basePath)); + public casts(apiKey: string, casts: string, sortType?: 'trending' | 'likes' | 'recasts' | 'replies' | 'recent', options?: AxiosRequestConfig) { + return CastApiFp(this.configuration).casts(apiKey, casts, sortType, options).then((request) => request(this.axios, this.basePath)); } /** diff --git a/src/neynar-api/v2/openapi-farcaster/apis/notifications-api.ts b/src/neynar-api/v2/openapi-farcaster/apis/notifications-api.ts index 31f54dc4..a74dfcbd 100644 --- a/src/neynar-api/v2/openapi-farcaster/apis/notifications-api.ts +++ b/src/neynar-api/v2/openapi-farcaster/apis/notifications-api.ts @@ -76,6 +76,67 @@ export const NotificationsApiAxiosParamCreator = function (configuration?: Confi + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Returns a list of notifications for a user in a specific channel + * @summary Retrieve notifications for a user for a given channel + * @param {string} apiKey API key required for authentication. + * @param {number} fid + * @param {string} parentUrls Comma separated channel parent_urls (find mappings here - https://github.com/neynarxyz/farcaster-channels/blob/main/warpcast.json) + * @param {number} [limit] Number of results to retrieve (default 25, max 50) + * @param {string} [cursor] Pagination cursor. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + notificationsChannel: async (apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise => { + // verify required parameter 'apiKey' is not null or undefined + assertParamExists('notificationsChannel', 'apiKey', apiKey) + // verify required parameter 'fid' is not null or undefined + assertParamExists('notificationsChannel', 'fid', fid) + // verify required parameter 'parentUrls' is not null or undefined + assertParamExists('notificationsChannel', 'parentUrls', parentUrls) + const localVarPath = `/farcaster/notifications/channel`; + // 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 (fid !== undefined) { + localVarQueryParameter['fid'] = fid; + } + + if (parentUrls !== undefined) { + localVarQueryParameter['parent_urls'] = parentUrls; + } + + 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}; @@ -109,6 +170,21 @@ export const NotificationsApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.notifications(apiKey, fid, limit, cursor, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * Returns a list of notifications for a user in a specific channel + * @summary Retrieve notifications for a user for a given channel + * @param {string} apiKey API key required for authentication. + * @param {number} fid + * @param {string} parentUrls Comma separated channel parent_urls (find mappings here - https://github.com/neynarxyz/farcaster-channels/blob/main/warpcast.json) + * @param {number} [limit] Number of results to retrieve (default 25, max 50) + * @param {string} [cursor] Pagination cursor. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async notificationsChannel(apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.notificationsChannel(apiKey, fid, parentUrls, limit, cursor, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, } }; @@ -132,6 +208,20 @@ export const NotificationsApiFactory = function (configuration?: Configuration, notifications(apiKey: string, fid: number, limit?: number, cursor?: string, options?: any): AxiosPromise { return localVarFp.notifications(apiKey, fid, limit, cursor, options).then((request) => request(axios, basePath)); }, + /** + * Returns a list of notifications for a user in a specific channel + * @summary Retrieve notifications for a user for a given channel + * @param {string} apiKey API key required for authentication. + * @param {number} fid + * @param {string} parentUrls Comma separated channel parent_urls (find mappings here - https://github.com/neynarxyz/farcaster-channels/blob/main/warpcast.json) + * @param {number} [limit] Number of results to retrieve (default 25, max 50) + * @param {string} [cursor] Pagination cursor. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + notificationsChannel(apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options?: any): AxiosPromise { + return localVarFp.notificationsChannel(apiKey, fid, parentUrls, limit, cursor, options).then((request) => request(axios, basePath)); + }, }; }; @@ -156,4 +246,20 @@ export class NotificationsApi extends BaseAPI { public notifications(apiKey: string, fid: number, limit?: number, cursor?: string, options?: AxiosRequestConfig) { return NotificationsApiFp(this.configuration).notifications(apiKey, fid, limit, cursor, options).then((request) => request(this.axios, this.basePath)); } + + /** + * Returns a list of notifications for a user in a specific channel + * @summary Retrieve notifications for a user for a given channel + * @param {string} apiKey API key required for authentication. + * @param {number} fid + * @param {string} parentUrls Comma separated channel parent_urls (find mappings here - https://github.com/neynarxyz/farcaster-channels/blob/main/warpcast.json) + * @param {number} [limit] Number of results to retrieve (default 25, max 50) + * @param {string} [cursor] Pagination cursor. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof NotificationsApi + */ + public notificationsChannel(apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options?: AxiosRequestConfig) { + return NotificationsApiFp(this.configuration).notificationsChannel(apiKey, fid, parentUrls, limit, cursor, options).then((request) => request(this.axios, this.basePath)); + } } diff --git a/src/oas b/src/oas index 213ed5e6..710eb22c 160000 --- a/src/oas +++ b/src/oas @@ -1 +1 @@ -Subproject commit 213ed5e6136f2076bdef589a3c5b73147a479acd +Subproject commit 710eb22c9e602b2bfc441a73019489edb61bc630 diff --git a/test-sdk.ts b/test-sdk.ts deleted file mode 100644 index e69de29b..00000000