当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.doesConformToSchema方法代码示例

本文整理汇总了TypeScript中@0xproject/assert.assert.doesConformToSchema方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.doesConformToSchema方法的具体用法?TypeScript assert.doesConformToSchema怎么用?TypeScript assert.doesConformToSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@0xproject/assert.assert的用法示例。


在下文中一共展示了assert.doesConformToSchema方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getTokenPairsAsync

 /**
  * Retrieve token pair info from the API
  * @param   requestOpts     Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
  * @return  The resulting TokenPairsItems that match the request
  */
 public async getTokenPairsAsync(requestOpts?: TokenPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]> {
     if (!_.isUndefined(requestOpts)) {
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.tokenPairsRequestOptsSchema);
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
     }
     const httpRequestOpts = {
         params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
     };
     const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, httpRequestOpts);
     const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson);
     return tokenPairs;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:17,代码来源:http_client.ts

示例2: getOrdersAsync

 /**
  * Retrieve orders from the API
  * @param   requestOpts     Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
  * @return  The resulting SignedOrders that match the request
  */
 public async getOrdersAsync(requestOpts?: OrdersRequestOpts & PagedRequestOpts): Promise<SignedOrder[]> {
     if (!_.isUndefined(requestOpts)) {
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
     }
     const httpRequestOpts = {
         params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
     };
     const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, httpRequestOpts);
     const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
     return orders;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:17,代码来源:http_client.ts

示例3: getOrderbookAsync

 /**
  * Retrieve an orderbook from the API
  * @param   request         An OrderbookRequest instance describing the specific orderbook to retrieve
  * @param   requestOpts     Options specifying page information, defaults to { page: 1, perPage: 100 }
  * @return  The resulting OrderbookResponse that matches the request
  */
 public async getOrderbookAsync(
     request: OrderbookRequest,
     requestOpts?: PagedRequestOpts,
 ): Promise<OrderbookResponse> {
     assert.doesConformToSchema('request', request, clientSchemas.orderBookRequestSchema);
     if (!_.isUndefined(requestOpts)) {
         assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
     }
     const httpRequestOpts = {
         params: _.defaults({}, request, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
     };
     const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, httpRequestOpts);
     const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
     return orderbook;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:21,代码来源:http_client.ts

示例4: submitOrderAsync

 /**
  * Submit a signed order to the API
  * @param   signedOrder     A SignedOrder instance to submit
  */
 public async submitOrderAsync(signedOrder: SignedOrder): Promise<void> {
     assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
     const requestOpts = {
         payload: signedOrder,
     };
     await this._requestAsync('/order', HttpRequestType.Post, requestOpts);
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:11,代码来源:http_client.ts

示例5: getFeesAsync

 /**
  * Retrieve fee information from the API
  * @param   request     A FeesRequest instance describing the specific fees to retrieve
  * @return  The resulting FeesResponse that matches the request
  */
 public async getFeesAsync(request: FeesRequest): Promise<FeesResponse> {
     assert.doesConformToSchema('request', request, clientSchemas.feesRequestSchema);
     const httpRequestOpts = {
         payload: request,
     };
     const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, httpRequestOpts);
     const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson);
     return fees;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:14,代码来源:http_client.ts

示例6: parse

import { schemas } from '@0xproject/json-schemas';
import * as _ from 'lodash';

import { OrderbookChannelMessage, OrderbookChannelMessageTypes } from '../types';

import { relayerResponseJsonParsers } from './relayer_response_json_parsers';

export const orderbookChannelMessageParser = {
    parse(utf8Data: string): OrderbookChannelMessage {
        const messageObj = JSON.parse(utf8Data);
        const type: string = _.get(messageObj, 'type');
        assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
        assert.isString('type', type);
        switch (type) {
            case OrderbookChannelMessageTypes.Snapshot: {
                assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema);
                const orderbookJson = messageObj.payload;
                const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(orderbookJson);
                return _.assign(messageObj, { payload: orderbook });
            }
            case OrderbookChannelMessageTypes.Update: {
                assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelUpdateSchema);
                const orderJson = messageObj.payload;
                const order = relayerResponseJsonParsers.parseOrderJson(orderJson);
                return _.assign(messageObj, { payload: order });
            }
            default: {
                return {
                    type: OrderbookChannelMessageTypes.Unknown,
                    requestId: 0,
                    payload: undefined,
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:orderbook_channel_message_parser.ts

示例7: getOrderAsync

 /**
  * Retrieve a specific order from the API
  * @param   orderHash     An orderHash generated from the desired order
  * @return  The SignedOrder that matches the supplied orderHash
  */
 public async getOrderAsync(orderHash: string): Promise<SignedOrder> {
     assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
     const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get);
     const order = relayerResponseJsonParsers.parseOrderJson(responseJson);
     return order;
 }
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:11,代码来源:http_client.ts

示例8: parseTokenPairsJson

import { assert } from '@0xproject/assert';
import { schemas } from '@0xproject/json-schemas';
import { SignedOrder } from '@0xproject/types';
import * as _ from 'lodash';

import { FeesResponse, OrderbookResponse, TokenPairsItem } from '../types';

import { typeConverters } from './type_converters';

export const relayerResponseJsonParsers = {
    parseTokenPairsJson(json: any): TokenPairsItem[] {
        assert.doesConformToSchema('tokenPairs', json, schemas.relayerApiTokenPairsResponseSchema);
        return json.map((tokenPair: any) => {
            return typeConverters.convertStringsFieldsToBigNumbers(tokenPair, [
                'tokenA.minAmount',
                'tokenA.maxAmount',
                'tokenB.minAmount',
                'tokenB.maxAmount',
            ]);
        });
    },
    parseOrdersJson(json: any): SignedOrder[] {
        assert.doesConformToSchema('orders', json, schemas.signedOrdersSchema);
        return json.map((order: object) => typeConverters.convertOrderStringFieldsToBigNumber(order));
    },
    parseOrderJson(json: any): SignedOrder {
        assert.doesConformToSchema('order', json, schemas.signedOrderSchema);
        return typeConverters.convertOrderStringFieldsToBigNumber(json);
    },
    parseOrderbookResponseJson(json: any): OrderbookResponse {
        assert.doesConformToSchema('orderBook', json, schemas.relayerApiOrderBookResponseSchema);
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:31,代码来源:relayer_response_json_parsers.ts


注:本文中的@0xproject/assert.assert.doesConformToSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。