starhs-models
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.StaRHType = exports.StaRH = undefined; | ||
exports.PersonType = exports.StaRHType = exports.StaRH = undefined; | ||
@@ -40,3 +40,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
/** | ||
* @param {{from: string, to: string, amount: number, message: string}} fields | ||
* @param {{from: PersonType, to: PersonType, amount: number, message: string}} fields | ||
*/ | ||
@@ -53,4 +53,4 @@ function StaRH(fields) { | ||
(0, _tcomb.String)(from); | ||
(0, _tcomb.String)(to); | ||
PersonType(from); | ||
PersonType(to); | ||
PositiveIntegerType(amount); | ||
@@ -74,4 +74,10 @@ (0, _tcomb.String)(message); | ||
return (0, _lodash.merge)(_get(StaRH.prototype.__proto__ || Object.getPrototypeOf(StaRH.prototype), 'toJSON', this).call(this), { | ||
from: this.from, | ||
to: this.to, | ||
from: { | ||
name: this.from.name, | ||
avatar: this.from.avatar.toString() | ||
}, | ||
to: { | ||
name: this.to.name, | ||
avatar: this.to.avatar.toString() | ||
}, | ||
amount: this.amount, | ||
@@ -83,3 +89,3 @@ message: this.message | ||
/** | ||
* @param {{from: string, to: string, amount: number, message: string}} data | ||
* @param {{from: {name: string, avatar: string}, to: {name: string, avatar: string}, amount: number, message: string}} data | ||
* @returns {StaRH} | ||
@@ -91,3 +97,14 @@ */ | ||
value: function fromJSON(data) { | ||
return new StaRH(data); | ||
return new StaRH({ | ||
from: { | ||
name: data.from.name, | ||
avatar: new _uri2.default(data.from.avatar) | ||
}, | ||
to: { | ||
name: data.to.name, | ||
avatar: new _uri2.default(data.to.avatar) | ||
}, | ||
amount: data.amount, | ||
message: data.message | ||
}); | ||
} | ||
@@ -111,2 +128,3 @@ | ||
return x instanceof StaRH; | ||
}); | ||
}); | ||
var PersonType = exports.PersonType = (0, _tcomb.struct)({ name: _tcomb.String, avatar: _uri2.default.Type }, 'PersonType'); |
{ | ||
"name": "starhs-models", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Shared models for the staRHs API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
19643
332