diff --git a/.stats.yml b/.stats.yml index f119ef79..1ec52b9d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 19 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-5e4d2c73f9b73c1a0b50bd28842d3af5ed35f8a52e1b5cd39b94f4ac8083bfcc.yml +configured_endpoints: 20 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-63c446028fc6e2ac5a16a0517c126a07fa4e97a5ab23853fb88750ccebaa991f.yml diff --git a/api.md b/api.md index ccb45a2f..79620554 100644 --- a/api.md +++ b/api.md @@ -201,6 +201,14 @@ Methods: # Scan +Types: + +- ScanStatusResponse + +Methods: + +- client.scan.status({ ...params }) -> unknown + # Token Types: diff --git a/src/index.ts b/src/index.ts index a318dcc2..6da72cc5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import * as Core from './core'; import * as Errors from './error'; import * as Uploads from './uploads'; import * as API from './resources/index'; -import { Scan } from './resources/scan'; +import { Scan, ScanStatusParams, ScanStatusResponse } from './resources/scan'; import { Site, SiteReportParams, @@ -454,7 +454,11 @@ export declare namespace Blockaid { type SiteScanParams as SiteScanParams, }; - export { Scan as Scan }; + export { + Scan as Scan, + type ScanStatusResponse as ScanStatusResponse, + type ScanStatusParams as ScanStatusParams, + }; export { Token as Token, diff --git a/src/resources/index.ts b/src/resources/index.ts index 17f32ff3..ddb58cde 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -30,7 +30,7 @@ export { type TransactionValidationError, type UsdDiff, } from './evm/evm'; -export { Scan } from './scan'; +export { Scan, type ScanStatusResponse, type ScanStatusParams } from './scan'; export { Site, type SiteScanHitResponse, diff --git a/src/resources/scan.ts b/src/resources/scan.ts index 2b73a4a4..eaa430d2 100644 --- a/src/resources/scan.ts +++ b/src/resources/scan.ts @@ -1,5 +1,32 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../resource'; +import * as Core from '../core'; -export class Scan extends APIResource {} +export class Scan extends APIResource { + /** + * Report whether the end-user accepted the Blockaid classification on the entity + * being scanned. + */ + status(body: ScanStatusParams, options?: Core.RequestOptions): Core.APIPromise { + return this._client.post('/v0/scan/status/', { body, ...options }); + } +} + +export type ScanStatusResponse = unknown; + +export interface ScanStatusParams { + /** + * The x-request-id header returned from the previous Blockaid api request + */ + request_id: string; + + /** + * An enumeration. + */ + status: 'accepted' | 'rejected'; +} + +export declare namespace Scan { + export { type ScanStatusResponse as ScanStatusResponse, type ScanStatusParams as ScanStatusParams }; +} diff --git a/tests/api-resources/scan.test.ts b/tests/api-resources/scan.test.ts new file mode 100644 index 00000000..ecc7093e --- /dev/null +++ b/tests/api-resources/scan.test.ts @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Blockaid from '@blockaid/client'; +import { Response } from 'node-fetch'; + +const client = new Blockaid({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource scan', () => { + test('status: only required params', async () => { + const responsePromise = client.scan.status({ + request_id: '7f959417-76c1-4c4d-89e8-5fdedab76a8d', + status: 'accepted', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('status: required and optional params', async () => { + const response = await client.scan.status({ + request_id: '7f959417-76c1-4c4d-89e8-5fdedab76a8d', + status: 'accepted', + }); + }); +});