Skip to content

Commit

Permalink
Allow users to add global headers (#235)
Browse files Browse the repository at this point in the history
* Generate code

* Accept global headers

* Minor update: v1.70.0
  • Loading branch information
Shreyaschorge authored Nov 11, 2024
1 parent a05e4a9 commit 370529d
Show file tree
Hide file tree
Showing 17 changed files with 495 additions and 102 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.69.1",
"version": "1.70.0",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/neynar-api/common/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "1.69.1";
export const version = "1.70.0";
17 changes: 14 additions & 3 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ export class NeynarAPIClient {
constructor(
apiKey: string,
{
baseOptions,
basePath,
logger = silentLogger,
axiosInstance,
}: {
baseOptions?: any;
basePath?: string;
logger?: Logger;
axiosInstance?: AxiosInstance;
Expand All @@ -155,8 +157,17 @@ export class NeynarAPIClient {
}

this.clients = {
v1: new NeynarV1APIClient(apiKey, { basePath, logger, axiosInstance }),
v2: new NeynarV2APIClient(apiKey, { basePath, logger, axiosInstance }),
v1: new NeynarV1APIClient(apiKey, {
basePath,
logger,
axiosInstance,
}),
v2: new NeynarV2APIClient(apiKey, {
baseOptions,
basePath,
logger,
axiosInstance,
}),
};
}

Expand Down Expand Up @@ -2943,7 +2954,7 @@ export class NeynarAPIClient {
fid: number,
options?: {
viewerFid?: number;
sortType: FollowSortType;
sortType?: FollowSortType;
cursor?: string;
limit?: number;
}
Expand Down
3 changes: 3 additions & 0 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ export class NeynarV2APIClient {
constructor(
apiKey: string,
{
baseOptions,
basePath,
logger = silentLogger,
axiosInstance,
}: {
baseOptions?: any;
basePath?: string;
logger?: Logger;
axiosInstance?: AxiosInstance;
Expand Down Expand Up @@ -204,6 +206,7 @@ export class NeynarV2APIClient {

axiosInstance.defaults.headers["x-sdk-version"] = version;
const config: Configuration = new Configuration({
baseOptions: baseOptions,
basePath: basePath ? `${basePath}/v2` : BASE_PATH,
apiKey: apiKey,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ models/trending-channel-response.ts
models/update-user-req-body-location.ts
models/update-user-req-body.ts
models/user-dehydrated.ts
models/user-experimental.ts
models/user-fidresponse.ts
models/user-power-lite-response-result.ts
models/user-power-lite-response.ts
Expand Down
27 changes: 22 additions & 5 deletions src/neynar-api/v2/openapi-farcaster/apis/ban-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ export const BanApiAxiosParamCreator = function (configuration?: Configuration)
* @summary Banned FIDs of app
* @param {number} [limit] Number of results to fetch (Default: 20, Maximum: 100)
* @param {string} [cursor] Pagination cursor.
* @param {boolean} [x_neynar_experimental] Enables experimental features
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<BanListResponse>} A promise that resolves to a `BanListResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-ban-list)
*
*/
fetchBanList: async (limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
fetchBanList: async (limit?: number, cursor?: string, x_neynar_experimental?: boolean, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/farcaster/ban/list`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand All @@ -114,6 +115,12 @@ export const BanApiAxiosParamCreator = function (configuration?: Configuration)
localVarQueryParameter['cursor'] = cursor;
}

if (x_neynar_experimental != null) {
localVarHeaderParameter['x-neynar-experimental'] = typeof x_neynar_experimental === 'string'
? x_neynar_experimental
: JSON.stringify(x_neynar_experimental);
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
Expand Down Expand Up @@ -200,15 +207,16 @@ export const BanApiFp = function(configuration?: Configuration) {
* @summary Banned FIDs of app
* @param {number} [limit] Number of results to fetch (Default: 20, Maximum: 100)
* @param {string} [cursor] Pagination cursor.
* @param {boolean} [x_neynar_experimental] Enables experimental features
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<BanListResponse>} A promise that resolves to a `BanListResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-ban-list)
*
*/
async fetchBanList(limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BanListResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchBanList(limit, cursor, options);
async fetchBanList(limit?: number, cursor?: string, x_neynar_experimental?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BanListResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchBanList(limit, cursor, x_neynar_experimental, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['BanApi.fetchBanList']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
Expand Down Expand Up @@ -266,7 +274,7 @@ export const BanApiFactory = function (configuration?: Configuration, basePath?:
*
*/
fetchBanList(requestParameters: BanApiFetchBanListRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<BanListResponse> {
return localVarFp.fetchBanList(requestParameters.limit, requestParameters.cursor, options).then((request) => request(axios, basePath));
return localVarFp.fetchBanList(requestParameters.limit, requestParameters.cursor, requestParameters.x_neynar_experimental, options).then((request) => request(axios, basePath));
},
/**
* Bans a list of FIDs from the app associated with your API key. Banned users, their casts and reactions will not appear in feeds.
Expand Down Expand Up @@ -374,6 +382,15 @@ export interface BanApiFetchBanListRequest {
* @memberof BanApiFetchBanList
*/
readonly cursor?: string

/**
* Enables experimental features
*
*
* @type {boolean}
* @memberof BanApiFetchBanList
*/
readonly x_neynar_experimental?: boolean
}

/**
Expand Down Expand Up @@ -428,7 +445,7 @@ export class BanApi extends BaseAPI implements BanApiInterface {
*
*/
public fetchBanList(requestParameters: BanApiFetchBanListRequest = {}, options?: RawAxiosRequestConfig) {
return BanApiFp(this.configuration).fetchBanList(requestParameters.limit, requestParameters.cursor, options).then((request) => request(this.axios, this.basePath));
return BanApiFp(this.configuration).fetchBanList(requestParameters.limit, requestParameters.cursor, requestParameters.x_neynar_experimental, options).then((request) => request(this.axios, this.basePath));
}

/**
Expand Down
27 changes: 22 additions & 5 deletions src/neynar-api/v2/openapi-farcaster/apis/block-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ export const BlockApiAxiosParamCreator = function (configuration?: Configuration
* @param {number} [blocked_fid] Providing this will return the users that have blocked this user
* @param {number} [limit] Number of results to fetch (Default: 20, Maximum: 100)
* @param {string} [cursor] Pagination cursor.
* @param {boolean} [x_neynar_experimental] Enables experimental features
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<BlockListResponse>} A promise that resolves to a `BlockListResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-block-list)
*
*/
fetchBlockList: async (blocker_fid?: number, blocked_fid?: number, limit?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
fetchBlockList: async (blocker_fid?: number, blocked_fid?: number, limit?: number, cursor?: string, x_neynar_experimental?: boolean, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/farcaster/block/list`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand Down Expand Up @@ -124,6 +125,12 @@ export const BlockApiAxiosParamCreator = function (configuration?: Configuration
localVarQueryParameter['cursor'] = cursor;
}

if (x_neynar_experimental != null) {
localVarHeaderParameter['x-neynar-experimental'] = typeof x_neynar_experimental === 'string'
? x_neynar_experimental
: JSON.stringify(x_neynar_experimental);
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
Expand Down Expand Up @@ -212,15 +219,16 @@ export const BlockApiFp = function(configuration?: Configuration) {
* @param {number} [blocked_fid] Providing this will return the users that have blocked this user
* @param {number} [limit] Number of results to fetch (Default: 20, Maximum: 100)
* @param {string} [cursor] Pagination cursor.
* @param {boolean} [x_neynar_experimental] Enables experimental features
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @returns {Promise<BlockListResponse>} A promise that resolves to a `BlockListResponse` object
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-block-list)
*
*/
async fetchBlockList(blocker_fid?: number, blocked_fid?: number, limit?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BlockListResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchBlockList(blocker_fid, blocked_fid, limit, cursor, options);
async fetchBlockList(blocker_fid?: number, blocked_fid?: number, limit?: number, cursor?: string, x_neynar_experimental?: boolean, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<BlockListResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchBlockList(blocker_fid, blocked_fid, limit, cursor, x_neynar_experimental, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['BlockApi.fetchBlockList']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
Expand Down Expand Up @@ -278,7 +286,7 @@ export const BlockApiFactory = function (configuration?: Configuration, basePath
*
*/
fetchBlockList(requestParameters: BlockApiFetchBlockListRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<BlockListResponse> {
return localVarFp.fetchBlockList(requestParameters.blocker_fid, requestParameters.blocked_fid, requestParameters.limit, requestParameters.cursor, options).then((request) => request(axios, basePath));
return localVarFp.fetchBlockList(requestParameters.blocker_fid, requestParameters.blocked_fid, requestParameters.limit, requestParameters.cursor, requestParameters.x_neynar_experimental, options).then((request) => request(axios, basePath));
},
/**
* Adds a block for a given FID.
Expand Down Expand Up @@ -404,6 +412,15 @@ export interface BlockApiFetchBlockListRequest {
* @memberof BlockApiFetchBlockList
*/
readonly cursor?: string

/**
* Enables experimental features
*
*
* @type {boolean}
* @memberof BlockApiFetchBlockList
*/
readonly x_neynar_experimental?: boolean
}

/**
Expand Down Expand Up @@ -458,7 +475,7 @@ export class BlockApi extends BaseAPI implements BlockApiInterface {
*
*/
public fetchBlockList(requestParameters: BlockApiFetchBlockListRequest = {}, options?: RawAxiosRequestConfig) {
return BlockApiFp(this.configuration).fetchBlockList(requestParameters.blocker_fid, requestParameters.blocked_fid, requestParameters.limit, requestParameters.cursor, options).then((request) => request(this.axios, this.basePath));
return BlockApiFp(this.configuration).fetchBlockList(requestParameters.blocker_fid, requestParameters.blocked_fid, requestParameters.limit, requestParameters.cursor, requestParameters.x_neynar_experimental, options).then((request) => request(this.axios, this.basePath));
}

/**
Expand Down
Loading

0 comments on commit 370529d

Please sign in to comment.