Skip to content

Commit

Permalink
feat(session): add support for pause ad VAST
Browse files Browse the repository at this point in the history
- Update Session class to handle pause ad requests
- Add getPauseAdVast method to Session class
  • Loading branch information
AxelHolst committed Jul 1, 2024
1 parent 6eb8cde commit 89078af
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion api/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { VastBuilder } = require("../utils/vast-maker");
const { VmapBuilder } = require("../utils/vmap-maker");
const { v4: uuid } = require("uuid");
const constants = require("../utils/constants");
const { PauseAdVastBuilder } = require("../utils/pause-ad-vast-maker");

class Session {
// Public Fields
Expand All @@ -18,6 +19,7 @@ class Session {
#user;
#vastXml;
#vmapXml;
#pauseAdVast;
#eventTracker;

constructor(params) {
Expand All @@ -33,7 +35,16 @@ class Session {
this.#clientRequest = new ClientRequest(params);
this.#eventTracker = new EventTracker();

if (this.responseFormat === constants.RESPONSE_FORMATS.VMAP) {
if (this.responseFormat === constants.RESPONSE_FORMATS.PAUSE_AD) {
const pauseAdObj = PauseAdVastBuilder({
sessionId: this.sessionId,
adserverHostname: this.host,
width: params.width,
height: params.height,
version: params.v || null,
});
this.#pauseAdVast = pauseAdObj.xml;
} else if (this.responseFormat === constants.RESPONSE_FORMATS.VMAP) {
// Create VMAP object.
let vmapObj;
vmapObj = VmapBuilder({
Expand Down Expand Up @@ -74,6 +85,10 @@ class Session {
return this.#user.getUserId();
}

getPauseAdVast() {
return this.#pauseAdVast;
}

getXmlResponse() {
if (this.#vastXml) {
return this.getVastXml();
Expand Down

0 comments on commit 89078af

Please sign in to comment.