Gisle Aune
6 years ago
3 changed files with 97 additions and 18 deletions
@ -0,0 +1,51 @@ |
|||
const {query} = require("../client") |
|||
|
|||
class Comment { |
|||
/** |
|||
* @param {string} id |
|||
* @param {string} subject |
|||
* @param {string} author |
|||
* @param {string} characterName |
|||
* @param {CommentCharacter} character |
|||
* @param {string | number | Date} fictionalDate |
|||
* @param {string | number | Date} createdDate |
|||
* @param {string | number | Date} editedDate |
|||
* @param {string} source |
|||
*/ |
|||
constructor(id, subject, author, characterName, character, fictionalDate, createdDate, editedDate, source) { |
|||
this.id = id |
|||
this.subject = subject |
|||
this.author = author |
|||
this.characterName = characterName |
|||
this.character = CommentCharacter.fromData(character) |
|||
this.fictionalDate = new Date(fictionalDate) |
|||
this.createdDate = new Date(createdDate) |
|||
this.editedDate = new Date(editedDate) |
|||
this.source = source |
|||
} |
|||
|
|||
static fromData(data) { |
|||
return new Comment(data.id, data.subject, data.author, data.characterName, data.character, data.fictionalDate, data.createdDate, data.editedDate, data.source) |
|||
} |
|||
} |
|||
|
|||
class CommentCharacter { |
|||
/** |
|||
* @param {string} id |
|||
* @param {string} name |
|||
* @param {string} author |
|||
* @param {string} description |
|||
*/ |
|||
constructor(id, name, author, description) { |
|||
this.id = id |
|||
this.name = name |
|||
this.author = author |
|||
this.description = description |
|||
} |
|||
|
|||
static fromData(data) { |
|||
return new CommentCharacter(data.id, data.name, data.author, data.description) |
|||
} |
|||
} |
|||
|
|||
module.exports = {Comment, CommentCharacter} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue