From 16b1021e9ea0c74fcf7e41a62bd75a2dc34fac54 Mon Sep 17 00:00:00 2001 From: Nathaniel Tucker Date: Sat, 28 Oct 2023 18:13:35 +0100 Subject: [PATCH] enhance: Support latest data-client schema --- .../anansi-splash/templates/src/resources/Ticker.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/generator-js/src/anansi-splash/templates/src/resources/Ticker.ts b/packages/generator-js/src/anansi-splash/templates/src/resources/Ticker.ts index f9666177b..acf007dda 100644 --- a/packages/generator-js/src/anansi-splash/templates/src/resources/Ticker.ts +++ b/packages/generator-js/src/anansi-splash/templates/src/resources/Ticker.ts @@ -1,12 +1,6 @@ import { Entity, RestEndpoint } from '@data-client/rest'; import type { FixtureEndpoint } from '@data-client/test'; -class FloatSerializer extends Number { - constructor(v: any) { - super(Number.parseFloat(v)); - } -} - // Visit https://dataclient.io/rest to read more about these definitions export class Ticker extends Entity { product_id = ''; @@ -28,8 +22,8 @@ export class Ticker extends Entity { // convert price to a float and time to a Date // see https://dataclient.io/rest/api/Entity#schema static schema = { - price: FloatSerializer, - time: Date, + price: Number, + time: (iso: string) => new Date(iso), }; // Use server timings to ensure zero race conditions @@ -43,6 +37,7 @@ export class Ticker extends Entity { } } +// Visit https://dataclient.io/rest/api/RestEndpoint to read more about these definitions export const getTicker = new RestEndpoint({ urlPrefix: 'https://api.exchange.coinbase.com', path: '/products/:product_id/ticker', @@ -51,6 +46,7 @@ export const getTicker = new RestEndpoint({ value.product_id = product_id; return value; }, + pollFrequency: 2000, }); export let TickerFixtures: Record = {};