Skip to content

Commit

Permalink
feat(api): api update (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 13, 2024
1 parent 3869551 commit 0c5ad43
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ Methods:

# Scan

Types:

- <code><a href="./src/resources/scan.ts">ScanStatusResponse</a></code>

Methods:

- <code title="post /v0/scan/status/">client.scan.<a href="./src/resources/scan.ts">status</a>({ ...params }) -> unknown</code>

# Token

Types:
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 28 additions & 1 deletion src/resources/scan.ts
Original file line number Diff line number Diff line change
@@ -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<unknown> {
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 };
}
32 changes: 32 additions & 0 deletions tests/api-resources/scan.test.ts
Original file line number Diff line number Diff line change
@@ -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',
});
});
});

0 comments on commit 0c5ad43

Please sign in to comment.