From b7320a2d28bfc00313858ecd2883b5f07e1f7c92 Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Sat, 17 Nov 2018 14:45:48 -0600 Subject: [PATCH] Adds base model for attributes getter --- src/models/answer.ts | 5 ++++- src/models/model.ts | 11 +++++++++++ src/models/preference.ts | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/models/model.ts diff --git a/src/models/answer.ts b/src/models/answer.ts index 35cb1c7..32c87ad 100644 --- a/src/models/answer.ts +++ b/src/models/answer.ts @@ -1,10 +1,13 @@ import { AnswerModel } from '../types/models'; import { AnswerParameters } from '../types/parameters'; +import Model from './model'; -export default class Answer implements AnswerModel { +export default class Answer extends Model implements AnswerModel { protected attributes: AnswerParameters; constructor() { + super(); + this.attributes = { question: null, value: null, diff --git a/src/models/model.ts b/src/models/model.ts new file mode 100644 index 0000000..3bf4145 --- /dev/null +++ b/src/models/model.ts @@ -0,0 +1,11 @@ +export default class Model { + protected attributes: object; + + constructor() { + this.attributes = {}; + } + + public getAttributes() { + return this.attributes; + } +} diff --git a/src/models/preference.ts b/src/models/preference.ts index 8b50fef..7924ff2 100644 --- a/src/models/preference.ts +++ b/src/models/preference.ts @@ -1,13 +1,16 @@ import { PreferenceModel } from '../types/models'; import { PreferenceParameters } from '../types/parameters'; +import Model from './model'; const NEXT_AVAILABLE = 1; const CERTAIN_DAYS = 2; -export default class Preference implements PreferenceModel { +export default class Preference extends Model implements PreferenceModel { protected attributes: PreferenceParameters; constructor() { + super(); + this.attributes = { day: null, end: null,