Skip to content

Commit af4ec53

Browse files
ezewerJacobPlaster
authored andcommitted
Add ChangeLog model
Add a new model as to represent the change logs
1 parent 8b05e28 commit af4ec53

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

lib/change_log.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict'
2+
3+
const stringValidator = require('./validators/string')
4+
const dateValidator = require('./validators/date')
5+
const Model = require('./model')
6+
7+
const fields = {
8+
mtsCreate: 0,
9+
log: 2,
10+
ip: 5,
11+
userAgent: 6
12+
}
13+
14+
/**
15+
* ChangeLog model
16+
*/
17+
class ChangeLog extends Model {
18+
/**
19+
* @param {object|Array} data - log data
20+
* @param {number} data.mtsCreate - timestamp
21+
* @param {string} data.log - log data
22+
* @param {string} data.ip - ip
23+
* @param {string} data.userAgent - user agent
24+
*/
25+
constructor (data = {}) {
26+
super({ data, fields })
27+
}
28+
29+
/**
30+
* @param {object[]|object|Array[]|Array} data - data to convert to POJO
31+
* @returns {object} pojo
32+
*/
33+
static unserialize (data) {
34+
return super.unserialize({ data, fields })
35+
}
36+
37+
/**
38+
* Validates a given wallet instance
39+
*
40+
* @param {object[]|object|ChangeLog[]|ChangeLog|Array} data - instance to validate
41+
* @returns {string} error - null if instance is valid
42+
*/
43+
static validate (data) {
44+
return super.validate({
45+
data,
46+
fields,
47+
48+
validators: {
49+
mtsCreate: dateValidator,
50+
log: stringValidator,
51+
ip: stringValidator,
52+
userAgent: stringValidator
53+
}
54+
})
55+
}
56+
}
57+
58+
module.exports = ChangeLog

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
Currency: require('./currency'),
3030
StatusMessagesDeriv: require('./status_messages_deriv'),
3131
Login: require('./login'),
32+
ChangeLog: require('./change_log'),
3233

3334
isCollection: require('./util/is_collection')
3435
}

0 commit comments

Comments
 (0)