1
0
Fork 0
liza/src/server/quote/ServerSideQuote.js

154 lines
3.2 KiB
JavaScript

/**
* Augments a quote with additional data for use by the quote server
*
* Copyright (C) 2017 R-T Specialty, LLC.
*
* This file is part of the Liza Data Collection Framework.
*
* liza is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var Class = require( 'easejs' ).Class,
Quote = require( '../../quote/Quote' ),
BaseQuote = require( '../../quote/BaseQuote' );
module.exports = Class( 'ServerSideQuote' )
.implement( Quote )
.extend( BaseQuote,
{
/**
* Program version
* @type {string}
*/
'private _pver': '',
/**
* Credit score reference number
* @type {number}
*/
'private _creditScoreRef': 0,
/**
* Unix timestamp containing date of first premium calculation
* @type {number}
*/
'private _rated_date': 0,
/**
* Metabucket
* @type {Bucket}
*/
'private _metabucket': null,
'public setProgramVersion': function( version )
{
this._pver = ''+( version );
return this;
},
'public getProgramVersion': function()
{
return this._pver;
},
'public setCreditScoreRef': function( ref )
{
this._creditScoreRef = +ref;
return this;
},
'public getCreditScoreRef': function()
{
return this._creditScoreRef;
},
/**
* Set the timestamp of the first time quote was rated
*
* @param {number} timestamp Unix timestamp representing first rated date
*
* @return {Quote} self
*/
'public setRatedDate': function( timestamp )
{
// do not overwrite date if it exists
if ( this._rated_date === 0 )
{
this._rated_date = ( +timestamp || 0 );
}
return this;
},
/**
* If the quote has been rated
*
* @return {boolean} has been rated
*/
'public getRatedDate': function()
{
return this._rated_date;
},
/**
* Metadata bucket
*
* @return {Bucket}
*/
'public getMetabucket': function()
{
return this._metabucket;
},
/**
* Set metadata bucket
*
* @return {ServerSideQuote} self
*/
'public setMetabucket': function( metabucket )
{
this._metabucket = metabucket;
},
/**
* Set metabucket data
*
* @param {Object} data key/value data
*
* @return {ServerSideQuote} self
*/
'public setMetadata': function( data )
{
if ( !this._metabucket )
{
throw Error( "No metabucket available for #setMetadata" );
}
this._metabucket.setValues( data );
return this;
}
} );