Skip to content

Commit

Permalink
enhance: Support latest data-client schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Oct 28, 2023
1 parent 4ea34ea commit 2bb827f
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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 = '';
Expand All @@ -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
Expand All @@ -51,6 +45,7 @@ export const getTicker = new RestEndpoint({
value.product_id = product_id;
return value;
},
pollFrequency: 2000,
});

export let TickerFixtures: Record<string, FixtureEndpoint> = {};
Expand Down

0 comments on commit 2bb827f

Please sign in to comment.