Skip to content

Commit

Permalink
Feature/fetchActiveUsers
Browse files Browse the repository at this point in the history
Feature/fetchActiveUsers
  • Loading branch information
Shreyaschorge authored Feb 15, 2024
2 parents ffa6605 + 19883ec commit 8e94e7a
Show file tree
Hide file tree
Showing 5 changed files with 157 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.9.6",
"version": "1.10.0",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
31 changes: 31 additions & 0 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,37 @@ export class NeynarAPIClient {

// ------------ User ------------

/**
* Retrieves a list of active users, where "active" is determined by the Warpcast active algorithm.
* The information about active users is updated every 12 hours. This method is ideal for identifying
* users who are currently engaging with the platform.
*
* @param {Object} [options] - Optional parameters to customize the request.
* @param {number} [options.limit] - Number of results to retrieve, with a default of 25 and a maximum of 150.
* @param {string} [options.cursor] - Pagination cursor for fetching specific subsets of results.
* Omit this parameter for the initial request.
*
* @returns {Promise<UsersResponse>} A promise that resolves to a `UsersResponse` object,
* containing a list of active users and any relevant pagination information.
*
* @example
* // Example: Fetch a list of active users with a limit and pagination cursor
* client.fetchActiveUsers({
* limit: 50,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request
* }).then(response => {
* console.log('Active Users:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/active-users).
*/
public async fetchActiveUsers(options?: {
limit?: number;
cursor?: string;
}): Promise<UsersResponse> {
return await this.clients.v2.fetchActiveUsers(options);
}

/**
* Removes verification for an eth address for the user.
* (In order to delete verification signer_uuid must be approved)
Expand Down
36 changes: 36 additions & 0 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,42 @@ export class NeynarV2APIClient {

// ------------ User ------------

/**
* Retrieves a list of active users, where "active" is determined by the Warpcast active algorithm.
* The information about active users is updated every 12 hours. This method is ideal for identifying
* users who are currently engaging with the platform.
*
* @param {Object} [options] - Optional parameters to customize the request.
* @param {number} [options.limit] - Number of results to retrieve, with a default of 25 and a maximum of 150.
* @param {string} [options.cursor] - Pagination cursor for fetching specific subsets of results.
* Omit this parameter for the initial request.
*
* @returns {Promise<UsersResponse>} A promise that resolves to a `UsersResponse` object,
* containing a list of active users and any relevant pagination information.
*
* @example
* // Example: Fetch a list of active users with a limit and pagination cursor
* client.fetchActiveUsers({
* limit: 50,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request
* }).then(response => {
* console.log('Active Users:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/active-users).
*/
public async fetchActiveUsers(options?: {
limit?: number;
cursor?: string;
}): Promise<UsersResponse> {
const response = await this.apis.user.activeUsers(
this.apiKey,
options?.limit,
options?.cursor
);
return response.data;
}

/**
* Removes verification for an eth address for the user.
* (In order to delete verification signerUuid must be approved)
Expand Down
88 changes: 88 additions & 0 deletions src/neynar-api/v2/openapi-farcaster/apis/user-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,61 @@ import { User } from '../models';
import { UserResponse } from '../models';
// @ts-ignore
import { UserSearchResponse } from '../models';
// @ts-ignore
import { UsersResponse } from '../models';
/**
* UserApi - axios parameter creator
* @export
*/
export const UserApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* Fetches active users, information is updated every 12 hours
* @summary Fetches active users based on Warpcast active algorithm
* @param {string} apiKey API key required for authentication.
* @param {number} [limit]
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
activeUsers: async (apiKey: string, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('activeUsers', 'apiKey', apiKey)
const localVarPath = `/farcaster/user/active`;
// 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};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Removes verification for an eth address for the user \\ (In order to delete verification `signer_uuid` must be approved)
* @summary Removes verification for an eth address for the user
Expand Down Expand Up @@ -462,6 +511,19 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)
export const UserApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = UserApiAxiosParamCreator(configuration)
return {
/**
* Fetches active users, information is updated every 12 hours
* @summary Fetches active users based on Warpcast active algorithm
* @param {string} apiKey API key required for authentication.
* @param {number} [limit]
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async activeUsers(apiKey: string, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UsersResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.activeUsers(apiKey, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Removes verification for an eth address for the user \\ (In order to delete verification `signer_uuid` must be approved)
* @summary Removes verification for an eth address for the user
Expand Down Expand Up @@ -582,6 +644,18 @@ export const UserApiFp = function(configuration?: Configuration) {
export const UserApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = UserApiFp(configuration)
return {
/**
* Fetches active users, information is updated every 12 hours
* @summary Fetches active users based on Warpcast active algorithm
* @param {string} apiKey API key required for authentication.
* @param {number} [limit]
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
activeUsers(apiKey: string, limit?: number, cursor?: string, options?: any): AxiosPromise<UsersResponse> {
return localVarFp.activeUsers(apiKey, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
* Removes verification for an eth address for the user \\ (In order to delete verification `signer_uuid` must be approved)
* @summary Removes verification for an eth address for the user
Expand Down Expand Up @@ -693,6 +767,20 @@ export const UserApiFactory = function (configuration?: Configuration, basePath?
* @extends {BaseAPI}
*/
export class UserApi extends BaseAPI {
/**
* Fetches active users, information is updated every 12 hours
* @summary Fetches active users based on Warpcast active algorithm
* @param {string} apiKey API key required for authentication.
* @param {number} [limit]
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof UserApi
*/
public activeUsers(apiKey: string, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return UserApiFp(this.configuration).activeUsers(apiKey, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}

/**
* Removes verification for an eth address for the user \\ (In order to delete verification `signer_uuid` must be approved)
* @summary Removes verification for an eth address for the user
Expand Down
2 changes: 1 addition & 1 deletion src/oas
Submodule oas updated 1 files
+33 −0 src/v2/spec.yaml

0 comments on commit 8e94e7a

Please sign in to comment.