Skip to content

Commit

Permalink
feat(api): api update (#326)
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 eaeb32d commit 6355cab
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 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-da8075d6f26ac858d52626cb7f8e9607322b2250184696c6ef1119033e7242c9.yml
configured_endpoints: 20
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-f9b9d0b0f1cedf56f0b5f9084b5862d5f5aa70fe89034338deb374d214c8ccff.yml
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ Methods:
- <code title="post /v0/site/report">client.site.<a href="./src/resources/site.ts">report</a>({ ...params }) -> unknown</code>
- <code title="post /v0/site/scan">client.site.<a href="./src/resources/site.ts">scan</a>({ ...params }) -> SiteScanResponse</code>

# 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
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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, ScanStatusParams, ScanStatusResponse } from './resources/scan';
import {
Site,
SiteReportParams,
Expand Down Expand Up @@ -255,6 +256,7 @@ export class Blockaid extends Core.APIClient {
bitcoin: API.Bitcoin = new API.Bitcoin(this);
starknet: API.Starknet = new API.Starknet(this);
site: API.Site = new API.Site(this);
scan: API.Scan = new API.Scan(this);
token: API.Token = new API.Token(this);
tokenBulk: API.TokenBulk = new API.TokenBulk(this);

Expand Down Expand Up @@ -344,6 +346,7 @@ Blockaid.Stellar = Stellar;
Blockaid.Bitcoin = Bitcoin;
Blockaid.Starknet = Starknet;
Blockaid.Site = Site;
Blockaid.Scan = Scan;
Blockaid.Token = Token;
Blockaid.TokenBulk = TokenBulk;
export declare namespace Blockaid {
Expand Down Expand Up @@ -451,6 +454,12 @@ export declare namespace Blockaid {
type SiteScanParams as SiteScanParams,
};

export {
Scan as Scan,
type ScanStatusResponse as ScanStatusResponse,
type ScanStatusParams as ScanStatusParams,
};

export {
Token as Token,
type TokenReportResponse as TokenReportResponse,
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export {
type TransactionValidationError,
type UsdDiff,
} from './evm/evm';
export { Scan, type ScanStatusResponse, type ScanStatusParams } from './scan';
export {
Site,
type SiteScanHitResponse,
Expand Down
32 changes: 32 additions & 0 deletions src/resources/scan.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 { APIResource } from '../resource';
import * as Core from '../core';

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 6355cab

Please sign in to comment.