Comparing version 10.0.0-beta.1 to 10.0.0-beta.2
@@ -8,3 +8,3 @@ import { EndpointDescription, HistoricalFilter, News, RestResponse, RestResponseError, RestResponseSuccess } from "./types"; | ||
search(filter: HistoricalFilter, errorHandler?: (apiResponse: RestResponseError<News[]>) => void): Promise<RestResponseSuccess<News[]>>; | ||
getById(id: number, errorHandler?: (apiResponse: RestResponseError<News>) => void): Promise<RestResponseSuccess<News>>; | ||
getById(id: string, errorHandler?: (apiResponse: RestResponseError<News>) => void): Promise<RestResponseSuccess<News>>; | ||
get<T>(path: string, params?: any, errorHandler?: (apiResponse: RestResponseError<T>) => void): Promise<RestResponse<T>>; | ||
@@ -11,0 +11,0 @@ post<T, Z>(path: string, body: T, errorHandler?: (apiResponse: RestResponseError<Z>) => void): Promise<RestResponseSuccess<Z>>; |
@@ -239,8 +239,8 @@ "use strict"; | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
let actualNews = (yield api.getById(2)).data; | ||
(0, chai_1.expect)(actualNews.id).eq(2); | ||
let actualNews = (yield api.getById("2")).data; | ||
(0, chai_1.expect)(actualNews.id).eq("2"); | ||
})); | ||
it("get by id (404)", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const api = new api_1.Api(context.config.apikey, enums_1.Endpoint.LOCALHOST); | ||
yield api.getById(2000, function (response) { | ||
yield api.getById("2000", function (response) { | ||
(0, chai_1.expect)(response.error.code).eq(404); | ||
@@ -247,0 +247,0 @@ (0, chai_1.expect)(response.error.message).eq("Resource not found"); |
@@ -75,3 +75,10 @@ "use strict"; | ||
yield client.indices.create({ | ||
index: config.index | ||
index: config.index, | ||
mappings: { | ||
properties: { | ||
"id": { | ||
type: "keyword" | ||
}, | ||
} | ||
} | ||
}); | ||
@@ -78,0 +85,0 @@ const seedData = JSON.parse(fs.readFileSync("./test/testdata.json") |
{ | ||
"name": "newsware", | ||
"version": "10.0.0-beta.1", | ||
"version": "10.0.0-beta.2", | ||
"description": "Typescript client for interacting with the Newsware API", | ||
@@ -5,0 +5,0 @@ "main": "lib/src/index.js", |
@@ -1,6 +0,6 @@ | ||
import {Api} from "./api"; | ||
import {Endpoint} from "./enums"; | ||
import {expect} from "chai" | ||
import {TestsContext} from "../test/setup"; | ||
import {And, CategoryCodes, Ciks, Or, Sources, Text, Tickers} from "./filters"; | ||
import { Api } from "./api"; | ||
import { Endpoint } from "./enums"; | ||
import { expect } from "chai" | ||
import { TestsContext } from "../test/setup"; | ||
import { And, CategoryCodes, Ciks, Or, Sources, Text, Tickers } from "./filters"; | ||
@@ -129,3 +129,3 @@ describe("Api historical search", () => { | ||
let actualNews = (await api.search({ | ||
filter: Text.any(["one"], {onlyBody: true}) | ||
filter: Text.any(["one"], { onlyBody: true }) | ||
})).data | ||
@@ -135,3 +135,3 @@ expect(actualNews.length).to.eq(1) | ||
actualNews = (await api.search({ | ||
filter: Text.any(["1"], {onlyBody: true}) | ||
filter: Text.any(["1"], { onlyBody: true }) | ||
})).data | ||
@@ -141,3 +141,3 @@ expect(actualNews.length).to.eq(0) | ||
actualNews = (await api.search({ | ||
filter: Text.any(["1 two"], {onlyBody: true}) | ||
filter: Text.any(["1 two"], { onlyBody: true }) | ||
})).data | ||
@@ -151,3 +151,3 @@ expect(actualNews.length).to.eq(0) | ||
let actualNews = (await api.search({ | ||
filter: Text.any(["one"], {onlyHeadline: true}) | ||
filter: Text.any(["one"], { onlyHeadline: true }) | ||
})).data | ||
@@ -157,3 +157,3 @@ expect(actualNews.length).to.eq(0) | ||
actualNews = (await api.search({ | ||
filter: Text.any(["one 2"], {onlyHeadline: true}) | ||
filter: Text.any(["one 2"], { onlyHeadline: true }) | ||
})).data | ||
@@ -163,3 +163,3 @@ expect(actualNews.length).to.eq(0) | ||
actualNews = (await api.search({ | ||
filter: Text.any(["1"], {onlyHeadline: true}) | ||
filter: Text.any(["1"], { onlyHeadline: true }) | ||
})).data | ||
@@ -299,4 +299,4 @@ expect(actualNews.length).to.eq(1) | ||
let actualNews = (await api.getById(2)).data | ||
expect(actualNews.id).eq(2) | ||
let actualNews = (await api.getById("2")).data | ||
expect(actualNews.id).eq("2") | ||
}) | ||
@@ -307,3 +307,3 @@ | ||
await api.getById(2000, function (response) { | ||
await api.getById("2000", function (response) { | ||
expect(response.error.code).eq(404) | ||
@@ -310,0 +310,0 @@ expect(response.error.message).eq("Resource not found") |
@@ -9,3 +9,3 @@ import { | ||
} from "./types" | ||
import {Endpoint} from "./enums" | ||
import { Endpoint } from "./enums" | ||
import fetch from "isomorphic-fetch" | ||
@@ -31,3 +31,3 @@ | ||
async getById(id: number, errorHandler: (apiResponse: RestResponseError<News>) => void = this.handleError): Promise<RestResponseSuccess<News>> { | ||
async getById(id: string, errorHandler: (apiResponse: RestResponseError<News>) => void = this.handleError): Promise<RestResponseSuccess<News>> { | ||
return await this.get<News>(`/news/${id}`, undefined, errorHandler) | ||
@@ -50,3 +50,3 @@ } | ||
}) | ||
return this.handle(res, errorHandler) | ||
@@ -96,8 +96,7 @@ } catch (e: any) { | ||
async handleError<T>(apiResponse: RestResponseError<T>) { | ||
throw Error(`Status ${apiResponse.error.code}${ | ||
apiResponse.error | ||
throw Error(`Status ${apiResponse.error.code}${apiResponse.error | ||
? ": " + apiResponse.error.message.charAt(0).toUpperCase() + apiResponse.error.message.slice(1) | ||
: "" | ||
}`) | ||
}`) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99310
1930