@neoskop/aviation-client
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -38,5 +38,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var rm = require("typed-rest-client/RestClient"); | ||
var loading_failed_error_1 = require("./error/loading-failed-error"); | ||
var feature_unmanaged_error_1 = require("./error/feature-unmanaged-error"); | ||
var request = require("superagent"); | ||
var AviationClient = (function () { | ||
@@ -51,3 +51,3 @@ function AviationClient(endpointUrl, token, meta) { | ||
var _this = this; | ||
var aviationService, response; | ||
var res; | ||
return __generator(this, function (_a) { | ||
@@ -57,18 +57,18 @@ switch (_a.label) { | ||
if (!(this._featureMap == null)) return [3 /*break*/, 2]; | ||
aviationService = new rm.RestClient('aviation-client-typescript', this._endpointUrl); | ||
return [4 /*yield*/, aviationService.get('/features', { | ||
additionalHeaders: { | ||
'Authorization': 'Bearer ' + this._token | ||
} | ||
})]; | ||
return [4 /*yield*/, request | ||
.get(this._endpointUrl + '/features') | ||
.set('Authorization', 'Bearer ' + this._token) | ||
.set('Accept', 'application/json') | ||
.accept('json')]; | ||
case 1: | ||
response = _a.sent(); | ||
if (response.statusCode == 200) { | ||
res = _a.sent(); | ||
if (res.status == 200) { | ||
this._featureMap = new Map(); | ||
response.result.forEach(function (f) { | ||
_this._featureMap.set(f.name, f); | ||
res.body.forEach(function (f) { | ||
var feature = f; | ||
_this._featureMap.set(feature.name, feature); | ||
}); | ||
} | ||
else { | ||
return [2 /*return*/, Promise.reject(new loading_failed_error_1.LoadingFailedError())]; | ||
throw new loading_failed_error_1.LoadingFailedError(res.body); | ||
} | ||
@@ -75,0 +75,0 @@ _a.label = 2; |
@@ -26,2 +26,3 @@ "use strict"; | ||
var sut = new aviation_client_1.AviationClient(endpointTestUrl, 'sup3rs3cr3t'); | ||
sut.feature('test-feature-1').catch(function (err) { return console.log(err); }); | ||
return sut.feature('test-feature-1').should.eventually.be.fulfilled; | ||
@@ -28,0 +29,0 @@ }); |
{ | ||
"name": "@neoskop/aviation-client", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
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
16357
245