@incdevco/framework
Version:
node.js lambda framework
52 lines (31 loc) • 790 B
JavaScript
function Action() {
this.data = {};
this.id = null;
this.message = null;
this.name = null;
this.receiptHandle = null;
this.user = null;
}
Action.prototype.fromMessage = function (message) {
this.message = message;
this.id = message.MessageId;
this.receiptHandle = message.ReceiptHandle;
this.fromMessageBody(message.Body);
};
Action.prototype.fromMessageBody = function (body) {
body = JSON.parse(body);
this.data = body.data;
this.name = body.name;
this.user = body.user;
};
Action.prototype.toMessage = function () {
return this.message;
};
Action.prototype.toMessageBody = function () {
return JSON.stringify({
data: this.data,
name: this.name,
user: this.user
});
};
module.exports = Action;