@muil/muil-javascript
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -56,3 +56,2 @@ "use strict"; | ||
var form_data_1 = __importDefault(require("form-data")); | ||
var types_1 = require("./types"); | ||
var host = null; | ||
@@ -72,19 +71,11 @@ var apiKey = null; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var data, _d, _e, statusCode, message; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
var data; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
ensureInitialized(); | ||
_f.label = 1; | ||
return [4 /*yield*/, axios_1.default.post(host + "/templates/" + branch + "/" + templateId + "?type=" + type, { props: props }, { headers: { 'x-api-key': apiKey } })]; | ||
case 1: | ||
_f.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, axios_1.default.post(host + "/templates/" + branch + "/" + templateId + "?type=" + type, { props: props }, { headers: { 'x-api-key': apiKey } })]; | ||
case 2: | ||
data = (_f.sent()).data; | ||
data = (_d.sent()).data; | ||
return [2 /*return*/, data]; | ||
case 3: | ||
_d = _f.sent(); | ||
_e = _d.response.data, statusCode = _e.statusCode, message = _e.message; | ||
throw new types_1.HttpError(statusCode, message); | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -97,10 +88,6 @@ }); | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var _c, _d, statusCode, message; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
ensureInitialized(); | ||
_e.label = 1; | ||
case 1: | ||
_e.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, axios_1.default.post(host + "/templates/" + branch + "/" + templateId + "/email", { | ||
@@ -115,10 +102,5 @@ from: from, | ||
}, { headers: { 'x-api-key': apiKey } })]; | ||
case 2: | ||
_e.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_c = _e.sent(); | ||
_d = _c.response.data, statusCode = _d.statusCode, message = _d.message; | ||
throw new types_1.HttpError(statusCode, message); | ||
case 4: return [2 /*return*/]; | ||
case 1: | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
} | ||
@@ -129,10 +111,7 @@ }); | ||
exports.uploadAsset = function (fileName, value) { return __awaiter(void 0, void 0, void 0, function () { | ||
var bodyData, url, _a, _b, statusCode, message; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var bodyData, url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
ensureInitialized(); | ||
_c.label = 1; | ||
case 1: | ||
_c.trys.push([1, 3, , 4]); | ||
bodyData = new form_data_1.default(); | ||
@@ -143,10 +122,5 @@ bodyData.append('file', value, { filename: fileName }); | ||
})]; | ||
case 2: | ||
url = (_c.sent()).data.data.url; | ||
case 1: | ||
url = (_a.sent()).data.data.url; | ||
return [2 /*return*/, url]; | ||
case 3: | ||
_a = _c.sent(); | ||
_b = _a.response.data, statusCode = _b.statusCode, message = _b.message; | ||
throw new types_1.HttpError(statusCode, message); | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -156,21 +130,12 @@ }); | ||
exports.deleteAsset = function (fileName) { return __awaiter(void 0, void 0, void 0, function () { | ||
var _a, _b, statusCode, message; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
ensureInitialized(); | ||
_c.label = 1; | ||
case 1: | ||
_c.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, axios_1.default.delete(host + "/assets/" + fileName, { | ||
headers: { 'x-api-key': apiKey }, | ||
})]; | ||
case 2: | ||
_c.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
_a = _c.sent(); | ||
_b = _a.response.data, statusCode = _b.statusCode, message = _b.message; | ||
throw new types_1.HttpError(statusCode, message); | ||
case 4: return [2 /*return*/]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
@@ -177,0 +142,0 @@ }); |
@@ -28,5 +28,1 @@ export declare type Config = { | ||
}; | ||
export declare class HttpError extends Error { | ||
private statusCode; | ||
constructor(statusCode: number, message: string); | ||
} |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HttpError = void 0; | ||
var HttpError = /** @class */ (function (_super) { | ||
__extends(HttpError, _super); | ||
function HttpError(statusCode, message) { | ||
var _this = _super.call(this, message) || this; | ||
_this.statusCode = statusCode; | ||
return _this; | ||
} | ||
return HttpError; | ||
}(Error)); | ||
exports.HttpError = HttpError; | ||
//# sourceMappingURL=types.js.map |
@@ -34,3 +34,3 @@ { | ||
}, | ||
"version": "0.0.5" | ||
"version": "0.0.6" | ||
} |
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
12261
171