Socket
Socket
Sign inDemoInstall

itad-api-client-ts

Package Overview
Dependencies
5
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

1

dist/itad-client.d.ts

@@ -5,2 +5,3 @@ import { ItadShop, ItadRegions, ItadDeals, ItadGameSearchParams, ItadGameHistorySearchParams, ItadGameDealSearchParams, ItadPlain, ItadGamesInfo, ItadHistoricalGamesInfo, ItadShopPlains, ItadDealsFull, ItadGamePriceSearchParams, ItadCurrentPrices } from "./types";

private readonly defaultHeaders;
private http;
private key;

@@ -7,0 +8,0 @@ private deals;

63

dist/itad-client.js

@@ -10,11 +10,7 @@ "use strict";

};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const nfetch = __importStar(require("node-fetch"));
const axios_1 = __importDefault(require("axios"));
class IsThereAnyDealApi {

@@ -27,2 +23,5 @@ constructor(key) {

this.key = key;
this.http = axios_1.default.create({
baseURL: this.BASE_URL
});
}

@@ -35,3 +34,3 @@ getShops() {

else {
const url = `${this.BASE_URL}/v01/web/stores/all/`;
const url = `/v01/web/stores/all/`;
this.shops = yield this.request(url);

@@ -44,4 +43,4 @@ return this.shops;

return __awaiter(this, void 0, void 0, function* () {
const url = `${this.BASE_URL}/v02/web/stores/?region=${region ||
""}&country=${country || ""}`;
const url = `/v02/web/stores/?region=${region || ""}&country=${country ||
""}`;
return yield this.request(url);

@@ -56,3 +55,3 @@ });

else {
const url = `${this.BASE_URL}/v01/web/regions/`;
const url = `/v01/web/regions/`;
this.regions = yield this.request(url);

@@ -65,4 +64,5 @@ return this.regions;

return __awaiter(this, void 0, void 0, function* () {
let url = `${this.BASE_URL}/v02/game/plain/?key=${this.key}&shop=${params.shop || ""}&game_id=${params.game_id ||
""}&title=${params.title || ""}&url=${params.url || ""}`;
let url = `/v02/game/plain/?key=${this.key}&shop=${params.shop ||
""}&game_id=${params.game_id || ""}&title=${params.title ||
""}&url=${params.url || ""}`;
return yield this.request(url);

@@ -77,3 +77,3 @@ });

const shopsParam = `shops=${shops ? shops.join(",") : ""}`;
const url = `${this.BASE_URL}/v01/game/plain/list/?key=${this.key}&${shopsParam}`;
const url = `/v01/game/plain/list/?key=${this.key}&${shopsParam}`;
return yield this.request(url);

@@ -90,3 +90,3 @@ });

}
const url = `${this.BASE_URL}/v01/game/info/?key=${this.key}&plains=${plains.join(",")}`;
const url = `/v01/game/info/?key=${this.key}&plains=${plains.join(",")}`;
return yield this.request(url);

@@ -102,4 +102,3 @@ });

const excludesParam = `${params.excludeShops ? params.excludeShops.join(",") : ""}`;
const url = `${this.BASE_URL}/v01/game/prices/?key=${this.key}&plains=${params.plains.join(",")}&region=${params.region ||
""}&country=${params.country ||
const url = `/v01/game/prices/?key=${this.key}&plains=${params.plains.join(",")}&region=${params.region || ""}&country=${params.country ||
""}&shops=${shopsParam}&exclude=${excludesParam}&added=${params.added ||

@@ -117,4 +116,3 @@ 0}`;

const excludesParam = `${params.excludeShops ? params.excludeShops.join(",") : ""}`;
const url = `${this.BASE_URL}/v01/game/lowest/?key=${this.key}&plains=${params.plains.join(",")}&region=${params.region ||
""}&country=${params.country ||
const url = `/v01/game/lowest/?key=${this.key}&plains=${params.plains.join(",")}&region=${params.region || ""}&country=${params.country ||
""}&shops=${shopsParam}&exclude=${excludesParam}&since=${params.since ||

@@ -132,3 +130,3 @@ 0}`;

const countryParam = `country=${params.country || ""}`;
const url = `${this.BASE_URL}/v01/deals/list/?key=${this.key}&${shopsParam}&${offsetParam}&${limitParam}&${regionParam}&${countryParam}`;
const url = `/v01/deals/list/?key=${this.key}&${shopsParam}&${offsetParam}&${limitParam}&${regionParam}&${countryParam}`;
this.deals = yield this.request(url);

@@ -170,3 +168,3 @@ return this.deals;

const countryParam = `country=${params.country || ""}`;
const url = `${this.BASE_URL}/v01/search/search/?key=${this.key}&q=${title}&${shopsParam}&${offsetParam}&${limitParam}&${regionParam}&${countryParam}`;
const url = `/v01/search/search/?key=${this.key}&q=${title}&${shopsParam}&${offsetParam}&${limitParam}&${regionParam}&${countryParam}`;
this.deals = yield this.request(url);

@@ -179,24 +177,19 @@ return this.deals;

try {
const call = process.env.ENV == "test" ? nfetch.default : fetch;
headers = headers
? Object.assign(headers, this.defaultHeaders)
: this.defaultHeaders;
const res = yield call(url, {
const res = yield this.http.request({
url,
method: method || "GET",
headers,
body
data: body
});
const json = yield res.json();
if (res.status >= 200 && res.status < 300) {
return json.data;
}
else if (json.error) {
throw new Error(`${json.error}: ${json.error_description}`);
}
else {
throw new Error("Call to IsThereAnyDeal failed.");
}
return res.data.data;
}
catch (err) {
throw err;
var error = err && err.response && err.response.data
? new Error(`${err.response.data.error}: ${err.response.data.error_description}`)
: err;
console.log(error);
throw error;
}

@@ -203,0 +196,0 @@ });

{
"name": "itad-api-client-ts",
"version": "1.0.2",
"version": "1.0.3",
"description": "A typescript api client/library for the IsThereAnyDeal api.",

@@ -55,4 +55,4 @@ "author": "onowrouzi",

"dependencies": {
"dotenv": "^8.0.0",
"node-fetch": "^2.6.0"
"axios": "^0.19.0",
"dotenv": "^8.0.0"
},

@@ -62,3 +62,2 @@ "devDependencies": {

"@types/node": "^12.0.2",
"@types/node-fetch": "^2.3.6",
"@types/typescript": "^2.0.0",

@@ -65,0 +64,0 @@ "jest": "^24.8.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc