postgrid-node-client
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -112,6 +112,7 @@ "use strict"; | ||
PostGrid.prototype.fire = function (method, uri, headers, query, body) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, isForm, response, payload, _a, err_1; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var url, isForm, response, err_1, response_1, error, payload, payload, _b, err_2; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
@@ -130,2 +131,5 @@ url = new URL(PROTOCOL + '://' + path_1.default.join(this.host, uri)); | ||
} | ||
_c.label = 1; | ||
case 1: | ||
_c.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, node_fetch_1.default(url, { | ||
@@ -137,16 +141,22 @@ method: method, | ||
})]; | ||
case 1: | ||
response = _b.sent(); | ||
_b.label = 2; | ||
case 2: | ||
_b.trys.push([2, 4, , 5]); | ||
_a = camelcase_keys_1.default; | ||
response = _c.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
err_1 = _c.sent(); | ||
response_1 = { status: 503 }; | ||
error = (_a = err_1 === null || err_1 === void 0 ? void 0 : err_1.message) !== null && _a !== void 0 ? _a : "Failed to fetch " + uri; | ||
payload = { error: error }; | ||
return [2 /*return*/, { response: response_1, payload: payload }]; | ||
case 4: | ||
_c.trys.push([4, 6, , 7]); | ||
_b = camelcase_keys_1.default; | ||
return [4 /*yield*/, response.json()]; | ||
case 3: | ||
payload = _a.apply(void 0, [(_b.sent()), { deep: true }]); | ||
case 5: | ||
payload = _b.apply(void 0, [(_c.sent()), { deep: true }]); | ||
return [2 /*return*/, { response: response, payload: payload }]; | ||
case 4: | ||
err_1 = _b.sent(); | ||
case 6: | ||
err_2 = _c.sent(); | ||
return [2 /*return*/, { response: response }]; | ||
case 5: return [2 /*return*/]; | ||
case 7: return [2 /*return*/]; | ||
} | ||
@@ -153,0 +163,0 @@ }); |
@@ -51,3 +51,3 @@ "use strict"; | ||
/* | ||
* Function to take a Webhook id and return the Wbhook object in the | ||
* Function to take a Webhook id and return the Webhook object in the | ||
* response. If the webhook isn't in the system, then we will return | ||
@@ -54,0 +54,0 @@ * the appropriate error. |
{ | ||
"name": "postgrid-node-client", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Node.js Client for PostGrid Business API", | ||
@@ -22,3 +22,4 @@ "keywords": [ | ||
"Bob Beaty <bob@flexbase.app>", | ||
"Patrick Flor <patrick@flexbase.app>" | ||
"Patrick Flor <patrick@flexbase.app>", | ||
"Alex Pearson <alex.pearson@flexbase.app>" | ||
], | ||
@@ -25,0 +26,0 @@ "engines": { |
198637
3002