Skip to content

Commit

Permalink
Merge pull request #3 from neynarxyz/feature/client
Browse files Browse the repository at this point in the history
Add fetchCast method
  • Loading branch information
Shreyaschorge authored Oct 26, 2023
2 parents 85febd7 + 379129d commit 0a67fd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ build
.DS_Store

# Temporary generated files
src/neynar-api/neynar-v1-api/openapi-tmp
src/neynar-api/neynar-v1-api/openapi-tmp
src/neynar-api/neynar-v2-api/openapi-tmp
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neynar/nodejs-sdk",
"version": "0.0.3",
"version": "0.0.4",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand All @@ -10,7 +10,7 @@
"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 --config src/oas/openapi-generator-config.json",
"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": "rm -rf src/neynar-api/neynar-v2-api/openapi-tmp; openapi-generator-cli generate -i src/oas/src/v2/spec.yaml -g typescript-axios -o src/neynar-api/neynar-v2-api/openapi --config src/oas/openapi-generator-config.json"
},
"author": "Neynar",
Expand Down
14 changes: 14 additions & 0 deletions src/neynar-api/neynar-v1-api/neynar-api-v1-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ export class NeynarV1APIClient {
);
}

/**
* Fetches a single cast by its hash. See [Neynar documentation](https://docs.neynar.com/reference/cast-v1)
*/
public async fetchCast(
hash: string,
options?: { viewerFid?: number }
): Promise<Cast | null> {
const response = await this.apis.cast.cast({
hash,
viewerFid: options?.viewerFid,
});
return response.data.result.cast;
}

/**
* Fetches casts in a given thread. See [Neynar documentation](https://docs.neynar.com/reference/get-all-casts-in-thread)
* Note that the parent provided by the caller is included in the response.
Expand Down

0 comments on commit 0a67fd0

Please sign in to comment.