當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。