Skip to content

Commit

Permalink
feat: new methods addBlock and deleteBlock (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
valerierose authored Nov 5, 2024
1 parent e473b78 commit c64860c
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 18 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.68.0",
"version": "1.69.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.68.0";
export const version = "1.69.0";
49 changes: 48 additions & 1 deletion src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,7 @@ export class NeynarAPIClient {
* console.log('Blocked Fids:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/block-list).
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/fetch-block-list).
*/
public async fetchBlockList(options?: {
blockerFid: number;
Expand All @@ -3845,6 +3845,53 @@ export class NeynarAPIClient {
return await this.clients.v2.fetchBlockList(options);
}

/**
* Adds a block for a given fid.
* @summary Adds a block for a fid.
* @param {string} signerUuid - UUID of the signer who is performing the action.
* @param {number} blockedFid The fid of the user being blocked.
*
* @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object.
*
* @example
* // Example: Block a user
* client.publishBlock(3, 19960).then(response => {
* console.log('Block Response:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/publish-block).
*
*/
public async publishBlock(
signerUuid: string,
blockedFid: number
): Promise<OperationResponse> {
return await this.clients.v2.publishBlock(signerUuid, blockedFid);
}

/**
* Deletes a block for a given fid.
* @summary Deletes a block for a fid.
* @param {string} signerUuid - UUID of the signer who is performing the action.
* @param {number} blockedFid The fid of the user being unblocked.
*
* @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object.
*
* @example
* // Example: Unblock a user
* client.deleteBlock(3, 19960).then(response => {
* console.log('Block Response:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/delete-block).
*/
public async deleteBlock(
signerUuid: string,
blockedFid: number
): Promise<OperationResponse> {
return await this.clients.v2.deleteBlock(signerUuid, blockedFid);
}

// ------------ Ban ------------

/**
Expand Down
59 changes: 57 additions & 2 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3876,15 +3876,15 @@ export class NeynarV2APIClient {
* console.log('Blocked Fids:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/block-list).
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/fetch-block-list).
*/
public async fetchBlockList(options?: {
blockerFid: number;
blockedFid: number;
limit?: number;
cursor: string;
}): Promise<BlockListResponse> {
const response = await this.apis.block.blockList(
const response = await this.apis.block.fetchBlockList(
options?.blockerFid,
options?.blockedFid,
options?.limit,
Expand All @@ -3893,6 +3893,61 @@ export class NeynarV2APIClient {
return response.data;
}

/**
* Adds a block for a given fid.
* @summary Adds a block for a fid.
* @param {string} signerUuid - A signer uuid for the user blocking another user.
* @param {number} blockedFid - The fid of the user being blocked.
*
* @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object.
*
* @example
* // Example: Block a user
* client.publishBlock('aaa-aaa-aaa', 19960).then(response => {
* console.log('Block Response:', response);
* });
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/publish-block).
*/
public async publishBlock(
signerUuid: string,
blockedFid: number
): Promise<OperationResponse> {
const addBlockBody = {
signer_uuid: signerUuid,
blocked_fid: blockedFid,
};
const response = await this.apis.block.publishBlock(addBlockBody);
return response.data;
}

/**
* Deletes a block for a given fid.
* @summary Deletes a block for a fid.
* @param {string} signerUuid - A signer uuid for the user unblocking another user.
* @param {number} blockedFid - The fid of the user being unblocked.
*
* @returns {Promise<OperationResponse>} A promise that resolves to a `OperationResponse` object.
*
* @example
* // Example: Unblock a user
* client.deleteBlock('aaa-aaa-aaa', 19960).then(response => {
* console.log('Block Response:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/delete-block).
*/
public async deleteBlock(
signerUuid: string,
blockedFid: number
): Promise<OperationResponse> {
const deleteBlockBody = {
signer_uuid: signerUuid,
blocked_fid: blockedFid,
};
const response = await this.apis.block.deleteBlock(deleteBlockBody);
return response.data;
}

// ------------ Ban ------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ models/ban-req-body.ts
models/ban-response.ts
models/block-list-response.ts
models/block-record.ts
models/block-req-body.ts
models/bulk-casts-response.ts
models/bulk-follow-response.ts
models/bulk-users-response.ts
Expand Down
Loading

0 comments on commit c64860c

Please sign in to comment.