openrtb
Version:
A Javascript library which builds and validates OpenRTB objects
86 lines (72 loc) • 2.21 kB
JavaScript
var RtbObject = require('../rtbObject');
var PublisherBuilder = require('./publisher').builder;
var ContentBuilder = require('./content').builder;
var removeEmptyValues = require('../utils').removeEmptyValues;
var App = function(storeurl, cat, id, name, publisher, bundle, domain, content){
this.storeurl = storeurl;
this.cat = cat;
this.id = id;
this.name = name;
this.bundle = bundle;
this.domain = domain;
this.publisher = publisher;
this.content = content;
};
App.prototype = Object.create(RtbObject.prototype);
var AppBuilder = function(){};
AppBuilder.prototype.storeurl = function(storeurl){
this._storeurl = storeurl;
return this;
};
AppBuilder.prototype.cat = function(cat){
this._cat = cat;
return this;
};
AppBuilder.prototype.id = function(id){
this._id = id;
return this;
};
AppBuilder.prototype.name = function(name){
this._name = name;
return this;
};
AppBuilder.prototype.bundle = function(bundle){
this._bundle = bundle;
return this;
};
AppBuilder.prototype.domain = function(domain){
this._domain = domain;
return this;
};
AppBuilder.prototype.publisher = function(publisher){
var builder = new PublisherBuilder();
this._publisher = builder
.id(publisher.id)
.name(publisher.name)
.build();
return this;
};
AppBuilder.prototype.content = function(content){
var builder = new ContentBuilder();
this._content = builder
.id(content.id)
.episode(content.episode)
.title(content.title)
.series(content.series)
.season(content.season)
.url(content.url)
.cat(content.cat)
.videoquality(content.videoquality)
.context(content.context)
.language(content.language)
.build();
return this;
};
AppBuilder.prototype.build = function() {
var app = new App(this._storeurl, this._cat, this._id, this._name, this._publisher, this._bundle, this._domain, this._content);
return removeEmptyValues(app);
};
module.exports = {
object: App,
builder: AppBuilder
};