From 890a6df69228224c1f5ff88743436cbe3d781972 Mon Sep 17 00:00:00 2001 From: Shreyaschorge Date: Mon, 13 Nov 2023 23:36:25 +0530 Subject: [PATCH 1/5] Generate code --- .../.openapi-generator/FILES | 1 + .../openapi-farcaster/models/user-response.ts | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/neynar-api/neynar-v2-api/openapi-farcaster/models/user-response.ts diff --git a/src/neynar-api/neynar-v2-api/openapi-farcaster/.openapi-generator/FILES b/src/neynar-api/neynar-v2-api/openapi-farcaster/.openapi-generator/FILES index ee4a297f..a9829371 100644 --- a/src/neynar-api/neynar-v2-api/openapi-farcaster/.openapi-generator/FILES +++ b/src/neynar-api/neynar-v2-api/openapi-farcaster/.openapi-generator/FILES @@ -67,6 +67,7 @@ models/user-bulk200-response.ts models/user-dehydrated.ts models/user-profile-bio.ts models/user-profile.ts +models/user-response.ts models/user-search-response-result.ts models/user-search-response.ts models/user-viewer-context.ts diff --git a/src/neynar-api/neynar-v2-api/openapi-farcaster/models/user-response.ts b/src/neynar-api/neynar-v2-api/openapi-farcaster/models/user-response.ts new file mode 100644 index 00000000..b818304d --- /dev/null +++ b/src/neynar-api/neynar-v2-api/openapi-farcaster/models/user-response.ts @@ -0,0 +1,33 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Farcaster API V2 + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 2.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +// May contain unused imports in some cases +// @ts-ignore +import { User } from './user'; + +/** + * + * @export + * @interface UserResponse + */ +export interface UserResponse { + /** + * + * @type {User} + * @memberof UserResponse + */ + 'user': User; +} + From a7de8da1703e5e36c4723c39f1ab17665f1969e1 Mon Sep 17 00:00:00 2001 From: Shreyaschorge Date: Mon, 13 Nov 2023 23:37:02 +0530 Subject: [PATCH 2/5] Refactor user-api generated code --- .../openapi-farcaster/apis/user-api.ts | 196 ++++++++++++++---- 1 file changed, 153 insertions(+), 43 deletions(-) diff --git a/src/neynar-api/neynar-v2-api/openapi-farcaster/apis/user-api.ts b/src/neynar-api/neynar-v2-api/openapi-farcaster/apis/user-api.ts index f3308dd9..604a0452 100644 --- a/src/neynar-api/neynar-v2-api/openapi-farcaster/apis/user-api.ts +++ b/src/neynar-api/neynar-v2-api/openapi-farcaster/apis/user-api.ts @@ -54,6 +54,8 @@ import { UpdateUserReqBody } from "../models"; // @ts-ignore import { UserBulk200Response } from "../models"; // @ts-ignore +import { UserResponse } from "../models"; +// @ts-ignore import { UserSearchResponse } from "../models"; /** * UserApi - axios parameter creator @@ -64,9 +66,7 @@ export const UserApiAxiosParamCreator = function ( ) { return { /** - * Removes verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) - * + * Removes verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Removes verification for an eth address for the user * @param {RemoveVerificationReqBody} removeVerificationReqBody * @param {*} [options] Override http request option. @@ -127,9 +127,7 @@ export const UserApiAxiosParamCreator = function ( }; }, /** - * Adds verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) - * + * Adds verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Adds verification for an eth address for the user * @param {AddVerificationReqBody} addVerificationReqBody * @param {*} [options] Override http request option. @@ -190,9 +188,7 @@ export const UserApiAxiosParamCreator = function ( }; }, /** - * Follow a user - * (In order to follow a user `signer_uuid` must be approved) - * + * Follow a user \\ (In order to follow a user `signer_uuid` must be approved) * @summary Follow a user * @param {FollowReqBody} followReqBody * @param {*} [options] Override http request option. @@ -249,8 +245,66 @@ export const UserApiAxiosParamCreator = function ( }; }, /** - * Unfollow a user - * (In order to unfollow a user `signer_uuid` must be approved) + * Lookup a user by custody-address + * @summary Lookup a user by custody-address + * @param {string} custodyAddress Custody Address of the associated with mnemonic + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + lookupUserByCustodyAddress: async ( + custodyAddress: string, + options: AxiosRequestConfig = {} + ): Promise => { + // verify required parameter 'custodyAddress' is not null or undefined + assertParamExists( + "lookupUserByCustodyAddress", + "custodyAddress", + custodyAddress + ); + + const localVarPath = `/farcaster/user/custody-address`; + // 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 (custodyAddress !== undefined) { + localVarQueryParameter["custody_address"] = custodyAddress; + } + + // authentication ApiKeyAuth required + await setApiKeyToObject( + localVarHeaderParameter, + "api_key", + configuration + ); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = + baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Unfollow a user \\ (In order to unfollow a user `signer_uuid` must be approved) * @summary Unfollow a user * @param {FollowReqBody} followReqBody * @param {*} [options] Override http request option. @@ -307,8 +361,7 @@ export const UserApiAxiosParamCreator = function ( }; }, /** - * Update user profile - * (In order to update user\'s profile `signer_uuid` must be approved) + * Update user profile \\ (In order to update user\'s profile `signer_uuid` must be approved) * @summary Update user profile * @param {UpdateUserReqBody} updateUserReqBody * @param {*} [options] Override http request option. @@ -497,8 +550,7 @@ export const UserApiFp = function (configuration?: Configuration) { const localVarAxiosParamCreator = UserApiAxiosParamCreator(configuration); return { /** - * Removes verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) + * Removes verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Removes verification for an eth address for the user * @param {RemoveVerificationReqBody} removeVerificationReqBody * @param {*} [options] Override http request option. @@ -526,8 +578,7 @@ export const UserApiFp = function (configuration?: Configuration) { ); }, /** - * Adds verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) + * Adds verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Adds verification for an eth address for the user * @param {AddVerificationReqBody} addVerificationReqBody * @param {*} [options] Override http request option. @@ -555,8 +606,7 @@ export const UserApiFp = function (configuration?: Configuration) { ); }, /** - * Follow a user - * (In order to follow a user `signer_uuid` must be approved) + * Follow a user \\ (In order to follow a user `signer_uuid` must be approved) * @summary Follow a user * @param {FollowReqBody} followReqBody * @param {*} [options] Override http request option. @@ -583,8 +633,32 @@ export const UserApiFp = function (configuration?: Configuration) { ); }, /** - * Unfollow a user - * (In order to unfollow a user `signer_uuid` must be approved) + * Lookup a user by custody-address + * @summary Lookup a user by custody-address + * @param {string} custodyAddress Custody Address of the associated with mnemonic + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async lookupUserByCustodyAddress( + custodyAddress: string, + options?: AxiosRequestConfig + ): Promise< + (axios?: AxiosInstance, basePath?: string) => AxiosPromise + > { + const localVarAxiosArgs = + await localVarAxiosParamCreator.lookupUserByCustodyAddress( + custodyAddress, + options + ); + return createRequestFunction( + localVarAxiosArgs, + globalAxios, + BASE_PATH, + configuration + ); + }, + /** + * Unfollow a user \\ (In order to unfollow a user `signer_uuid` must be approved) * @summary Unfollow a user * @param {FollowReqBody} followReqBody * @param {*} [options] Override http request option. @@ -611,8 +685,7 @@ export const UserApiFp = function (configuration?: Configuration) { ); }, /** - * Update user profile - * (In order to update user\'s profile `signer_uuid` must be approved) + * Update user profile \\ (In order to update user\'s profile `signer_uuid` must be approved) * @summary Update user profile * @param {UpdateUserReqBody} updateUserReqBody * @param {*} [options] Override http request option. @@ -713,8 +786,7 @@ export const UserApiFactory = function ( const localVarFp = UserApiFp(configuration); return { /** - * Removes verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) + * Removes verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Removes verification for an eth address for the user * @param {UserApiRemoveVerificationRequest} requestParameters * @param {*} [options] Override http request option. @@ -732,8 +804,7 @@ export const UserApiFactory = function ( .then((request) => request(axios, basePath)); }, /** - * Adds verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) + * Adds verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Adds verification for an eth address for the user * @param {UserApiAddVerificationRequest} requestParameters * @param {*} [options] Override http request option. @@ -751,8 +822,7 @@ export const UserApiFactory = function ( .then((request) => request(axios, basePath)); }, /** - * Follow a user - *(In order to follow a user `signer_uuid` must be approved) + * Follow a user \\ (In order to follow a user `signer_uuid` must be approved) * @summary Follow a user * @param {UserApiFollowRequest} requestParameters * @param {*} [options] Override http request option. @@ -767,8 +837,22 @@ export const UserApiFactory = function ( .then((request) => request(axios, basePath)); }, /** - * Unfollow a user - * (In order to unfollow a user `signer_uuid` must be approved) + * Lookup a user by custody-address + * @summary Lookup a user by custody-address + * @param {UserApiLookupUserByCustodyAddressRequest} requestParameters + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + lookupUserByCustodyAddress( + requestParameters: UserApiLookupUserByCustodyAddressRequest, + options?: AxiosRequestConfig + ): AxiosPromise { + return localVarFp + .lookupUserByCustodyAddress(requestParameters.custodyAddress, options) + .then((request) => request(axios, basePath)); + }, + /** + * Unfollow a user \\ (In order to unfollow a user `signer_uuid` must be approved) * @summary Unfollow a user * @param {UserApiFollowRequest} requestParameters * @param {*} [options] Override http request option. @@ -783,8 +867,7 @@ export const UserApiFactory = function ( .then((request) => request(axios, basePath)); }, /** - * Update user profile - * (In order to update user\'s profile `signer_uuid` must be approved) + * Update user profile \\ (In order to update user\'s profile `signer_uuid` must be approved) * @summary Update user profile * @param {UserApiUpdateUserRequest} requestParameters * @param {*} [options] Override http request option. @@ -906,6 +989,21 @@ export interface UserApiBulkUserRequest { readonly viewerFid?: number; } +/** + * Request parameters for lookup user by custody address operation in UserApi. + * @export + * @interface UserApiLookupUserByCustodyAddressRequest + */ +export interface UserApiLookupUserByCustodyAddressRequest { + /** + * Custody Address of the associated with mnemonic + * + * @type {string} + * @memberof UserApiLookupUserByCustodyAddress + */ + readonly custodyAddress: string; +} + /** * Request parameters for search user in operation in UserApi. * @export @@ -933,8 +1031,7 @@ export interface UserApiUserSearchRequest { */ export class UserApi extends BaseAPI { /** - * Removes verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) + * Removes verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Removes verification for an eth address for the user * @param {UserApiRemoveVerificationRequest} requestParameters * @param {*} [options] Override http request option. @@ -954,8 +1051,7 @@ export class UserApi extends BaseAPI { } /** - * Adds verification for an eth address for the user - * (In order to add verification `signer_uuid` must be approved) + * Adds verification for an eth address for the user \\ (In order to add verification `signer_uuid` must be approved) * @summary Adds verification for an eth address for the user * @param {UserApiAddVerificationRequest} requestParameters * @param {*} [options] Override http request option. @@ -975,8 +1071,7 @@ export class UserApi extends BaseAPI { } /** - * Follow a user - * (In order to follow a user `signer_uuid` must be approved) + * Follow a user \\ (In order to follow a user `signer_uuid` must be approved) * @summary Follow a user * @param {UserApiFollowRequest} requestParameters * @param {*} [options] Override http request option. @@ -993,8 +1088,24 @@ export class UserApi extends BaseAPI { } /** - * Unfollow a user - * (In order to unfollow a user `signer_uuid` must be approved) + * Lookup a user by custody-address + * @summary Lookup a user by custody-address + * @param {UserApiLookupUserByCustodyAddressRequest} requestParameters + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApi + */ + public lookupUserByCustodyAddress( + requestParameters: UserApiLookupUserByCustodyAddressRequest, + options?: AxiosRequestConfig + ) { + return UserApiFp(this.configuration) + .lookupUserByCustodyAddress(requestParameters.custodyAddress, options) + .then((request) => request(this.axios, this.basePath)); + } + + /** + * Unfollow a user \\ (In order to unfollow a user `signer_uuid` must be approved) * @summary Unfollow a user * @param {UserApiFollowRequest} requestParameters * @param {*} [options] Override http request option. @@ -1011,8 +1122,7 @@ export class UserApi extends BaseAPI { } /** - * Update user profile - * (In order to update user\'s profile `signer_uuid` must be approved) + * Update user profile \\ (In order to update user\'s profile `signer_uuid` must be approved) * @summary Update user profile * @param {UserApiUpdateUserRequest} requestParameters * @param {*} [options] Override http request option. From f8a2582811bb238a99fb05d84270f04ff9e32465 Mon Sep 17 00:00:00 2001 From: Shreyaschorge Date: Mon, 13 Nov 2023 23:41:14 +0530 Subject: [PATCH 3/5] Export UserResponse --- src/neynar-api/neynar-v2-api/openapi-farcaster/models/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/neynar-api/neynar-v2-api/openapi-farcaster/models/index.ts b/src/neynar-api/neynar-v2-api/openapi-farcaster/models/index.ts index 2273cd9a..28692408 100644 --- a/src/neynar-api/neynar-v2-api/openapi-farcaster/models/index.ts +++ b/src/neynar-api/neynar-v2-api/openapi-farcaster/models/index.ts @@ -52,6 +52,7 @@ export * from './user-bulk200-response'; export * from './user-dehydrated'; export * from './user-profile'; export * from './user-profile-bio'; +export * from './user-response'; export * from './user-search-response'; export * from './user-search-response-result'; export * from './user-viewer-context'; From 25b9c6031cb226f9a62ec88f24c79084c570b357 Mon Sep 17 00:00:00 2001 From: Shreyaschorge Date: Mon, 13 Nov 2023 23:48:04 +0530 Subject: [PATCH 4/5] Attach lookupUserByCustodyAddress to client --- src/neynar-api/neynar-api-client.ts | 11 +++++++++++ .../neynar-v2-api/neynar-api-v2-client.ts | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/neynar-api/neynar-api-client.ts b/src/neynar-api/neynar-api-client.ts index ba5010dc..61a557a0 100644 --- a/src/neynar-api/neynar-api-client.ts +++ b/src/neynar-api/neynar-api-client.ts @@ -16,6 +16,7 @@ import { UserSearchResponse, CastResponse, CastsResponse, + UserResponse, } from "./neynar-v2-api/openapi-farcaster"; import { @@ -459,6 +460,16 @@ export class NeynarAPIClient { return await this.clients.v2.searchUser(q, viewerFid); } + /** + * Lookup User by Custody Address + * See [Neynar documentation](https://docs.neynar.com/reference/lookup-user-by-custody-address) + */ + public async lookupUserByCustodyAddress( + custodyAddress: string + ): Promise { + return await this.clients.v2.lookupUserByCustodyAddress(custodyAddress); + } + // ------------ Cast ------------ /** diff --git a/src/neynar-api/neynar-v2-api/neynar-api-v2-client.ts b/src/neynar-api/neynar-v2-api/neynar-api-v2-client.ts index 87d81ede..fb961345 100644 --- a/src/neynar-api/neynar-v2-api/neynar-api-v2-client.ts +++ b/src/neynar-api/neynar-v2-api/neynar-api-v2-client.ts @@ -33,6 +33,7 @@ import { UserSearchResponse, CastResponse, CastsResponse, + UserResponse, } from "./openapi-farcaster"; import axios, { AxiosError, AxiosInstance } from "axios"; import { silentLogger, Logger } from "../common/logger"; @@ -320,6 +321,19 @@ export class NeynarV2APIClient { return response.data; } + /** + * Lookup User by Custody Address + * See [Neynar documentation](https://docs.neynar.com/reference/lookup-user-by-custody-address) + */ + public async lookupUserByCustodyAddress( + custodyAddress: string + ): Promise { + const response = await this.apis.user.lookupUserByCustodyAddress({ + custodyAddress, + }); + return response.data; + } + // ------------ Cast ------------ /** From 0b1c9d165ff2c917488a87ec41ef1a6267afc9e2 Mon Sep 17 00:00:00 2001 From: Shreyaschorge Date: Mon, 13 Nov 2023 23:49:09 +0530 Subject: [PATCH 5/5] Patch update: v0.11.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a8d4e03..896c7508 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@neynar/nodejs-sdk", - "version": "0.11.0", + "version": "0.11.1", "description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)", "main": "./build/index.js", "types": "./build/index.d.ts",