Skip to content

Commit

Permalink
Sync APIs with oas and Add fetchRelaventMints API
Browse files Browse the repository at this point in the history
Sync APIs with oas and Add fetchRelaventMints API
  • Loading branch information
Shreyaschorge authored Nov 6, 2023
2 parents e8f429a + c6cc8f2 commit b0cdc7f
Show file tree
Hide file tree
Showing 28 changed files with 1,125 additions and 24 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neynar/nodejs-sdk",
"version": "0.9.0",
"version": "0.9.1",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand All @@ -10,8 +10,9 @@
"scripts": {
"clean": "del-cli ./build/*",
"build": "yarn run clean && tsc",
"generate:neynar-oas": "rm -rf src/neynar-api/neynar-v1-api/openapi-tmp; openapi-generator-cli generate -i src/oas/src/v1/spec.yaml -g typescript-axios -o src/neynar-api/neynar-v1-api/openapi-tmp --config src/oas/openapi-generator-config.json",
"generate:neynar-oas-v2-farcaster": "rm -rf src/neynar-api/neynar-v2-api/openapi-farcaster-tmp; openapi-generator-cli generate -i src/oas/src/v2/spec.yaml -g typescript-axios -o src/neynar-api/neynar-v2-api/openapi-farcaster --config src/oas/openapi-generator-config.json"
"generate:neynar-oas": "openapi-generator-cli generate -i src/oas/src/v1/spec.yaml -g typescript-axios -o src/neynar-api/neynar-v1-api/openapi --config src/oas/openapi-generator-config.json",
"generate:neynar-oas-v2-farcaster": "openapi-generator-cli generate -i src/oas/src/v2/spec.yaml -g typescript-axios -o src/neynar-api/neynar-v2-api/openapi-farcaster --config src/oas/openapi-generator-config.json",
"generate:neynar-oas-v2-recommendation": "openapi-generator-cli generate -i src/oas/src/v2/recommendation/spec.yaml -g typescript-axios -o src/neynar-api/neynar-v2-api/openapi-recommendation --config src/oas/openapi-generator-config.json"
},
"author": "Neynar",
"license": "ISC",
Expand Down
4 changes: 2 additions & 2 deletions src/neynar-api/neynar-v1-api/neynar-api-v1-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class NeynarV1APIClient {
}

/**
* Fetches casts in a given thread.
* Gets all casts, including root cast and all replies for a given thread hash. No limit the depth of replies.
* See [Neynar documentation](https://docs.neynar.com/reference/all-casts-in-thread-v1)
* Note that the parent provided by the caller is included in the response.
*
Expand Down Expand Up @@ -384,7 +384,7 @@ export class NeynarV1APIClient {
*/
public async fetchCastReactions(
castOrCastHash: Cast | string,
options?: { viewerFid?: number; limit?: number, cursor?: string }
options?: { viewerFid?: number; limit?: number; cursor?: string }
): Promise<CastReactionsResponse> {
let castHash: string;
if (typeof castOrCastHash === "string") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
apis/cast-api.ts
apis/follows-api.ts
Expand Down
8 changes: 4 additions & 4 deletions src/neynar-api/neynar-v1-api/openapi/apis/cast-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const CastApiAxiosParamCreator = function (
) {
return {
/**
* Gets the most recent casts for a user in reverse-chronological order
* Gets all casts, including root cast and all replies for a given thread hash. No limit the depth of replies.
* @summary Retrieve all casts in a given thread hash
* @param {string} threadHash The hash of the thread to retrieve casts from.
* @param {number} [viewerFid] fid of the user viewing this information, needed for contextual information.
Expand Down Expand Up @@ -328,7 +328,7 @@ export const CastApiFp = function (configuration?: Configuration) {
const localVarAxiosParamCreator = CastApiAxiosParamCreator(configuration);
return {
/**
* Gets the most recent casts for a user in reverse-chronological order
* Gets all casts, including root cast and all replies for a given thread hash. No limit the depth of replies.
* @summary Retrieve all casts in a given thread hash
* @param {string} threadHash The hash of the thread to retrieve casts from.
* @param {number} [viewerFid] fid of the user viewing this information, needed for contextual information.
Expand Down Expand Up @@ -469,7 +469,7 @@ export const CastApiFactory = function (
const localVarFp = CastApiFp(configuration);
return {
/**
* Gets the most recent casts for a user in reverse-chronological order
* Gets all casts, including root cast and all replies for a given thread hash. No limit the depth of replies.
* @summary Retrieve all casts in a given thread hash
* @param {CastApiAllCastsInThreadRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
Expand Down Expand Up @@ -667,7 +667,7 @@ export interface CastApiRecentCastsRequest {
*/
export class CastApi extends BaseAPI {
/**
* Gets the most recent casts for a user in reverse-chronological order
* Gets all casts, including root cast and all replies for a given thread hash. No limit the depth of replies.
* @summary Retrieve all casts in a given thread hash
* @param {CastApiAllCastsInThreadRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
Expand Down
30 changes: 29 additions & 1 deletion src/neynar-api/neynar-v2-api/neynar-api-v2-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import {
import axios, { AxiosError, AxiosInstance } from "axios";
import { silentLogger, Logger } from "../common/logger";
import type { SetRequired } from "type-fest";
import {
FetchRelevantMints200Response,
NFTApi,
} from "./openapi-recommendation";

const BASE_PATH = "https://api.neynar.com/v2";

Expand All @@ -53,6 +57,7 @@ export class NeynarV2APIClient {
feed: FeedApi;
notifications: NotificationsApi;
follows: FollowsApi;
nft: NFTApi;
};

/**
Expand Down Expand Up @@ -102,6 +107,7 @@ export class NeynarV2APIClient {
feed: new FeedApi(config, undefined, axiosInstance),
notifications: new NotificationsApi(config, undefined, axiosInstance),
follows: new FollowsApi(config, undefined, axiosInstance),
nft: new NFTApi(config, undefined, axiosInstance),
};
}

Expand Down Expand Up @@ -313,7 +319,7 @@ export class NeynarV2APIClient {
// ------------ Cast ------------

/**
* Gets information about an individual cast.
* Gets information about an individual cast by passing in a Warpcast web URL or cast hash
* See [Neynar documentation](https://docs.neynar.com/reference/cast)
*
*/
Expand Down Expand Up @@ -479,6 +485,7 @@ export class NeynarV2APIClient {
parentUrl?: string;
limit?: number;
cursor?: string;
withRecasts?: boolean;
}
): Promise<FeedResponse> {
const response = await this.apis.feed.feed({
Expand All @@ -489,6 +496,7 @@ export class NeynarV2APIClient {
parentUrl: options?.parentUrl,
cursor: options?.cursor,
limit: options?.limit,
withRecasts: options?.withRecasts,
});
return response.data;
}
Expand Down Expand Up @@ -529,4 +537,24 @@ export class NeynarV2APIClient {
});
return response.data;
}

// ------------ Recommendation ------------

/**
* Fetches all mint actions relevant for a contract address (and optionally tokenId for ERC1155s) given a user's ethereum address
* See [Neynar documentation](https://docs.neynar.com/reference/fetch-relevant-mints)
*
*/
public async fetchRelevantMints(
address: string,
contractAddress: string,
tokenId?: string
): Promise<FetchRelevantMints200Response> {
const response = await this.apis.nft.fetchRelevantMints({
address,
contractAddress,
tokenId,
});
return response.data;
}
}
18 changes: 9 additions & 9 deletions src/neynar-api/neynar-v2-api/openapi-farcaster/apis/cast-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export const CastApiAxiosParamCreator = function (
) {
return {
/**
* Gets information about an individual cast by passing in a web URL or cast hash
* @summary Retrieve cast for a given hash
* Gets information about an individual cast by passing in a Warpcast web URL or cast hash
* @summary Retrieve cast for a given hash or Warpcast URL
* @param {CastParamType} type
* @param {string} identifier Cast identifier (Its either a url or a hash)
* @param {*} [options] Override http request option.
Expand Down Expand Up @@ -185,7 +185,7 @@ export const CastApiAxiosParamCreator = function (
/**
* Delete an existing cast.
* (In order to delete a cast `signer_uuid` must be approved)
*
*
* @summary Delete a cast
* @param {DeleteCastReqBody} deleteCastReqBody
* @param {*} [options] Override http request option.
Expand Down Expand Up @@ -309,8 +309,8 @@ export const CastApiFp = function (configuration?: Configuration) {
const localVarAxiosParamCreator = CastApiAxiosParamCreator(configuration);
return {
/**
* Gets information about an individual cast by passing in a web URL or cast hash
* @summary Retrieve cast for a given hash
* Gets information about an individual cast by passing in a Warpcast web URL or cast hash
* @summary Retrieve cast for a given hash or Warpcast URL
* @param {CastParamType} type
* @param {string} identifier Cast identifier (Its either a url or a hash)
* @param {*} [options] Override http request option.
Expand Down Expand Up @@ -429,8 +429,8 @@ export const CastApiFactory = function (
const localVarFp = CastApiFp(configuration);
return {
/**
* Gets information about an individual cast by passing in a web URL or cast hash
* @summary Retrieve cast for a given hash
* Gets information about an individual cast by passing in a Warpcast web URL or cast hash
* @summary Retrieve cast for a given hash or Warpcast URL
* @param {CastApiCastRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
Expand Down Expand Up @@ -563,8 +563,8 @@ export interface CastApiPostCastRequest {
*/
export class CastApi extends BaseAPI {
/**
* Gets information about an individual cast by passing in a web URL or cast hash
* @summary Retrieve cast for a given hash
* Gets information about an individual cast by passing in a Warpcast web URL or cast hash
* @summary Retrieve cast for a given hash or Warpcast URL
* @param {CastApiCastRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
Expand Down
24 changes: 21 additions & 3 deletions src/neynar-api/neynar-v2-api/openapi-farcaster/apis/feed-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export const FeedApiAxiosParamCreator = function (
* @param {string} [fids] Used when filter_type=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=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} [cursor] Pagination cursor.
* @param {number} [limit] Number of results to retrieve (default 25, max 150)
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
Expand All @@ -70,6 +71,7 @@ export const FeedApiAxiosParamCreator = function (
parentUrl?: string,
cursor?: string,
limit?: number,
withRecasts?: boolean,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'fid' is not null or undefined
Expand Down Expand Up @@ -125,6 +127,10 @@ export const FeedApiAxiosParamCreator = function (
localVarQueryParameter["limit"] = limit;
}

if (withRecasts !== undefined) {
localVarQueryParameter["with_recasts"] = withRecasts;
}

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions =
baseOptions && baseOptions.headers ? baseOptions.headers : {};
Expand Down Expand Up @@ -158,7 +164,8 @@ export const FeedApiFp = function (configuration?: Configuration) {
* @param {string} [fids] Used when filter_type=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=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} [cursor] Pagination cursor.
* @param {number} [limit] Number of results to retrieve (default 25, max 150)
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
Expand All @@ -170,6 +177,7 @@ export const FeedApiFp = function (configuration?: Configuration) {
parentUrl?: string,
cursor?: string,
limit?: number,
withRecasts?: boolean,
options?: AxiosRequestConfig
): Promise<
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FeedResponse>
Expand All @@ -182,6 +190,7 @@ export const FeedApiFp = function (configuration?: Configuration) {
parentUrl,
cursor,
limit,
withRecasts,
options
);
return createRequestFunction(
Expand Down Expand Up @@ -225,6 +234,7 @@ export const FeedApiFactory = function (
requestParameters.parentUrl,
requestParameters.cursor,
requestParameters.limit,
requestParameters.withRecasts,
options
)
.then((request) => request(axios, basePath));
Expand Down Expand Up @@ -281,11 +291,18 @@ export interface FeedApiFeedRequest {
readonly cursor?: string;

/**
* Number of results to retrieve (default 25, max 150)
* Number of results to retrieve (default 25, max 100)
* @type {number}
* @memberof FeedApiFeed
*/
readonly limit?: number;

/**
* Include recasts in the response, true by default
* @type {boolean}
* @memberof FeedApiFeed
*/
readonly withRecasts?: boolean;
}

/**
Expand Down Expand Up @@ -316,6 +333,7 @@ export class FeedApi extends BaseAPI {
requestParameters.parentUrl,
requestParameters.cursor,
requestParameters.limit,
requestParameters.withRecasts,
options
)
.then((request) => request(this.axios, this.basePath));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.gitignore
.npmignore
.openapi-generator-ignore
api.ts
apis/nftapi.ts
base.ts
common.ts
configuration.ts
git_push.sh
index.ts
models/active-status.ts
models/error-res.ts
models/fetch-relevant-mints200-response.ts
models/index.ts
models/relevant-mint.ts
models/user-profile-bio.ts
models/user-profile.ts
models/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.1
18 changes: 18 additions & 0 deletions src/neynar-api/neynar-v2-api/openapi-recommendation/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/**
* Recommendation 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.
*/



export * from './apis/nftapi';

Loading

0 comments on commit b0cdc7f

Please sign in to comment.