Skip to content

Commit

Permalink
Updated datasets endpoint data structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
lprokein committed Dec 22, 2021
1 parent d6d78df commit 241086e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fetch from "isomorphic-unfetch";
import qs from "querystringify";
import {
IDataset,
IDatasetListResponse,
IDatasetMetadataResponse,
IStockOverlayFetchResponse,
Expand Down Expand Up @@ -104,8 +105,10 @@ export class Client {
/* Miscellaneous API
-------------------------------------------------------------------------*/

public async getDatasetList(): Promise<IDatasetListResponse> {
return this.requestData<IDatasetListResponse>(Paths.datasets);
public async getDatasetList(): Promise<IDataset[]> {
return this.requestData<IDatasetListResponse>(Paths.datasets).then((data) => {
return data.datasets;
});
}

public async getDatasetMetadata(datasetId: string): Promise<IDatasetMetadataResponse> {
Expand All @@ -116,15 +119,19 @@ export class Client {
return this.requestData<IDatasetMetadataResponse>(Paths.datasetMetadata(datasetId.trim()));
}

public async getTickerDatasetList(ticker: string): Promise<IDatasetListResponse> {
public async getTickerDatasetList(ticker: string): Promise<IDataset[]> {
if (!ticker || ticker.trim().length === 0) {
return Promise.reject(new Error("Missing or invalid ticker"));
}

const params = {
ticker: ticker.trim(),
};
return this.requestData(Paths.datasets + qs.stringify(params, "?"));
return this.requestData<IDatasetListResponse>(Paths.datasets + qs.stringify(params, "?")).then(
(data) => {
return data.datasets;
},
);
}

public async getTickerList(query: string, datasetId?: string) {
Expand Down

0 comments on commit 241086e

Please sign in to comment.