From 67bea09fe81912d4e86379f425eeb972a718579e Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 17 May 2016 11:23:29 -0300 Subject: [PATCH] add tx note as model --- lib/model/index.js | 1 + lib/model/txnote.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 lib/model/txnote.js diff --git a/lib/model/index.js b/lib/model/index.js index 747d73a..bcf5e3e 100644 --- a/lib/model/index.js +++ b/lib/model/index.js @@ -8,5 +8,6 @@ Model.Address = require('./address'); Model.Notification = require('./notification'); Model.Preferences = require('./preferences'); Model.Email = require('./email'); +Model.TxNote = require('./txnote'); module.exports = Model; diff --git a/lib/model/txnote.js b/lib/model/txnote.js new file mode 100644 index 0000000..3bb3fec --- /dev/null +++ b/lib/model/txnote.js @@ -0,0 +1,34 @@ +var _ = require('lodash'); +var Uuid = require('uuid'); + +function TxNote() {}; + +TxNote.create = function(opts) { + opts = opts || {}; + + var x = new TxNote(); + + x.version = 1; + x.walletId = opts.walletId; + x.txid = opts.txid; + x.body = opts.body; + x.lastEditedOn = Math.floor(Date.now() / 1000); + x.lastEditedById = opts.lastEditedById; + + return x; +}; + +TxNote.fromObj = function(obj) { + var x = new TxNote(); + + x.version = obj.version; + x.walletId = obj.walletId; + x.txid = obj.txid; + x.body = obj.body; + x.lastEditedOn = obj.lastEditedOn; + x.lastEditedById = obj.lastEditedById; + + return x; +}; + +module.exports = TxNote;