Skip to content

Commit

Permalink
Add fetchNotificationsByParentUrlForUser
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyaschorge committed Jan 19, 2024
1 parent 8d70ae9 commit d3e68a1
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 16 deletions.
35 changes: 35 additions & 0 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,41 @@ export class NeynarAPIClient {
return await this.clients.v2.fetchTrendingChannels(timeWindow);
}

/**
* Retrieves a list of notifications for a user based on specific parent URLs. This method is
* particularly useful for fetching notifications related to user interactions within designated
* channels or content categories.
*
* @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 {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 notifications for the specified user and parent URLs.
*
* @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 => {
* console.log('User Notifications:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/notifications-parent-url).
*/
public async fetchNotificationsByParentUrlForUser(
fid: number,
parentUrls: string[],
options?: { cursor?: string; limit?: number }
) {
return await this.clients.v2.fetchNotificationsByParentUrlForUser(
fid,
parentUrls,
options
);
}

// ------------ Follows ------------

/**
Expand Down
39 changes: 39 additions & 0 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,45 @@ export class NeynarV2APIClient {
return response.data;
}

/**
* Retrieves a list of notifications for a user based on specific parent URLs. This method is
* particularly useful for fetching notifications related to user interactions within designated
* channels or content categories.
*
* @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 {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 notifications for the specified user and parent URLs.
*
* @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 => {
* console.log('User Notifications:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/notifications-parent-url).
*/
public async fetchNotificationsByParentUrlForUser(
fid: number,
parentUrls: string[],
options?: { cursor?: string; limit?: number }
) {
const _parentUrls = parentUrls.join(",");
const response = await this.apis.notifications.notificationsParentUrl(
this.apiKey,
fid,
_parentUrls,
options?.limit,
options?.cursor
);
return response.data;
}

// ------------ Channel ------------

/**
Expand Down
138 changes: 122 additions & 16 deletions src/neynar-api/v2/openapi-farcaster/apis/notifications-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const NotificationsApiAxiosParamCreator = function (configuration?: Confi
* Returns a list of notifications for a specific FID.
* @summary Retrieve notifications for a given user
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
Expand Down Expand Up @@ -86,10 +86,10 @@ export const NotificationsApiAxiosParamCreator = function (configuration?: Confi
};
},
/**
* Returns a list of notifications for a user in a specific channel
* @summary Retrieve notifications for a user for a given channel
* Returns a list of notifications for a user in specific channels
* @summary Retrieve notifications for a user in given channels
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} channelIds Comma separated channel_ids (find list of all channels here - https://docs.neynar.com/reference/list-all-channels)
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
Expand Down Expand Up @@ -137,6 +137,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 specific parent_urls
* @summary Retrieve notifications for a user in given parent_urls
* @param {string} apiKey API key required for authentication.
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} parentUrls Comma separated parent_urls
* @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}
*/
notificationsParentUrl: async (apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('notificationsParentUrl', 'apiKey', apiKey)
// verify required parameter 'fid' is not null or undefined
assertParamExists('notificationsParentUrl', 'fid', fid)
// verify required parameter 'parentUrls' is not null or undefined
assertParamExists('notificationsParentUrl', 'parentUrls', parentUrls)
const localVarPath = `/farcaster/notifications/parent_url`;
// 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};
Expand All @@ -160,7 +221,7 @@ export const NotificationsApiFp = function(configuration?: Configuration) {
* Returns a list of notifications for a specific FID.
* @summary Retrieve notifications for a given user
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
Expand All @@ -171,10 +232,10 @@ export const NotificationsApiFp = function(configuration?: Configuration) {
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
* Returns a list of notifications for a user in specific channels
* @summary Retrieve notifications for a user in given channels
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} channelIds Comma separated channel_ids (find list of all channels here - https://docs.neynar.com/reference/list-all-channels)
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
Expand All @@ -185,6 +246,21 @@ export const NotificationsApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.notificationsChannel(apiKey, fid, channelIds, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Returns a list of notifications for a user in specific parent_urls
* @summary Retrieve notifications for a user in given parent_urls
* @param {string} apiKey API key required for authentication.
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} parentUrls Comma separated parent_urls
* @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 notificationsParentUrl(apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<NotificationsResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.notificationsParentUrl(apiKey, fid, parentUrls, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
};

Expand All @@ -199,7 +275,7 @@ export const NotificationsApiFactory = function (configuration?: Configuration,
* Returns a list of notifications for a specific FID.
* @summary Retrieve notifications for a given user
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
Expand All @@ -209,10 +285,10 @@ export const NotificationsApiFactory = function (configuration?: Configuration,
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
* Returns a list of notifications for a user in specific channels
* @summary Retrieve notifications for a user in given channels
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} channelIds Comma separated channel_ids (find list of all channels here - https://docs.neynar.com/reference/list-all-channels)
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
Expand All @@ -222,6 +298,20 @@ export const NotificationsApiFactory = function (configuration?: Configuration,
notificationsChannel(apiKey: string, fid: number, channelIds: string, limit?: number, cursor?: string, options?: any): AxiosPromise<NotificationsResponse> {
return localVarFp.notificationsChannel(apiKey, fid, channelIds, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
* Returns a list of notifications for a user in specific parent_urls
* @summary Retrieve notifications for a user in given parent_urls
* @param {string} apiKey API key required for authentication.
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} parentUrls Comma separated parent_urls
* @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}
*/
notificationsParentUrl(apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options?: any): AxiosPromise<NotificationsResponse> {
return localVarFp.notificationsParentUrl(apiKey, fid, parentUrls, limit, cursor, options).then((request) => request(axios, basePath));
},
};
};

Expand All @@ -236,7 +326,7 @@ export class NotificationsApi extends BaseAPI {
* Returns a list of notifications for a specific FID.
* @summary Retrieve notifications for a given user
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
Expand All @@ -248,10 +338,10 @@ export class NotificationsApi extends BaseAPI {
}

/**
* Returns a list of notifications for a user in a specific channel
* @summary Retrieve notifications for a user for a given channel
* Returns a list of notifications for a user in specific channels
* @summary Retrieve notifications for a user in given channels
* @param {string} apiKey API key required for authentication.
* @param {number} fid
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} channelIds Comma separated channel_ids (find list of all channels here - https://docs.neynar.com/reference/list-all-channels)
* @param {number} [limit] Number of results to retrieve (default 25, max 50)
* @param {string} [cursor] Pagination cursor.
Expand All @@ -262,4 +352,20 @@ export class NotificationsApi extends BaseAPI {
public notificationsChannel(apiKey: string, fid: number, channelIds: string, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return NotificationsApiFp(this.configuration).notificationsChannel(apiKey, fid, channelIds, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}

/**
* Returns a list of notifications for a user in specific parent_urls
* @summary Retrieve notifications for a user in given parent_urls
* @param {string} apiKey API key required for authentication.
* @param {number} fid FID of the user you you want to fetch notifications for
* @param {string} parentUrls Comma separated parent_urls
* @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 notificationsParentUrl(apiKey: string, fid: number, parentUrls: string, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return NotificationsApiFp(this.configuration).notificationsParentUrl(apiKey, fid, parentUrls, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}
}

0 comments on commit d3e68a1

Please sign in to comment.