From 3c6525ef95470cb33f16d79b5c727129c36ecd93 Mon Sep 17 00:00:00 2001 From: John Gainfort Jr Date: Mon, 17 Jul 2017 11:00:09 -0600 Subject: [PATCH 1/4] change VastAd creatives to match closer to library type --- types/vast-client/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/vast-client/index.d.ts b/types/vast-client/index.d.ts index 9886554e88..639b940a04 100644 --- a/types/vast-client/index.d.ts +++ b/types/vast-client/index.d.ts @@ -231,9 +231,14 @@ export interface VastError { ERRORCODE: string; } +export interface VastCreative { + 0: VastCreativeLinear, + 1: VastCreativeCompanion +} + export interface VastAd { advertiser: any; - creatives: VastCreativeLinear | VastCreativeCompanion[]; + creatives: VastCreative[]; description: string; errorURLTemplates: string[]; extensions: VastAdExtension[]; From 9abaa3c05f16baae0f4a4efe087ae581f02d7806 Mon Sep 17 00:00:00 2001 From: John Gainfort Jr Date: Mon, 17 Jul 2017 11:02:03 -0600 Subject: [PATCH 2/4] removing VastAd.creative as an array and using object index signature instead --- types/vast-client/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vast-client/index.d.ts b/types/vast-client/index.d.ts index 639b940a04..7b01df7cd5 100644 --- a/types/vast-client/index.d.ts +++ b/types/vast-client/index.d.ts @@ -238,7 +238,7 @@ export interface VastCreative { export interface VastAd { advertiser: any; - creatives: VastCreative[]; + creatives: VastCreative; description: string; errorURLTemplates: string[]; extensions: VastAdExtension[]; From f565abfe39eb44d830e7a13993d28564b55ee42c Mon Sep 17 00:00:00 2001 From: John Gainfort Jr Date: Mon, 17 Jul 2017 11:04:20 -0600 Subject: [PATCH 3/4] fixed lint error --- types/vast-client/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/vast-client/index.d.ts b/types/vast-client/index.d.ts index 7b01df7cd5..79de29c6b0 100644 --- a/types/vast-client/index.d.ts +++ b/types/vast-client/index.d.ts @@ -232,8 +232,8 @@ export interface VastError { } export interface VastCreative { - 0: VastCreativeLinear, - 1: VastCreativeCompanion + 0: VastCreativeLinear; + 1: VastCreativeCompanion; } export interface VastAd { From de39637f41244812a0399a8affb4623d5313faa1 Mon Sep 17 00:00:00 2001 From: John Gainfort Jr Date: Mon, 17 Jul 2017 15:06:39 -0600 Subject: [PATCH 4/4] updated VastCreative interface and its extensions --- types/vast-client/index.d.ts | 59 ++++++++++++++++++-------- types/vast-client/vast-client-tests.ts | 7 +++ 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/types/vast-client/index.d.ts b/types/vast-client/index.d.ts index 79de29c6b0..680e1e2dd8 100644 --- a/types/vast-client/index.d.ts +++ b/types/vast-client/index.d.ts @@ -232,13 +232,36 @@ export interface VastError { } export interface VastCreative { - 0: VastCreativeLinear; - 1: VastCreativeCompanion; + id: string; + adId: string; + trackingEvents: VastTrackingEvents; + apiFramework: any; + sequence: any; + type: string; +} + +export interface VastCreativeLinear extends VastCreative { + adParameters: any; + duration: number; + icons: string[]; + mediaFiles: VastMediaFile[]; + skipDelay: boolean; + videoClickThroughURLTemplate: string; + videoClickTrackingURLTemplates: string[]; + videoCustomClickURLTempaltes: string[]; +} + +export interface VastCreativeNonLinear extends VastCreative { + variations: VastNonLinearAd[]; +} + +export interface VastCreativeCompanion extends VastCreative { + variations: VastCompanionAd[]; } export interface VastAd { advertiser: any; - creatives: VastCreative; + creatives: VastCreative[]; description: string; errorURLTemplates: string[]; extensions: VastAdExtension[]; @@ -271,22 +294,22 @@ export interface VastAdChildAttributes { name: string; } -export interface VastCreativeLinear { - adParameters: any; - duration: number; - icons: string[]; - mediaFiles: VastMediaFile[]; - skipDelay: boolean; - trackingEvents: VastTrackingEvents; +export interface VastNonLinearAd { + nonLinearClickTrackingURLTemplates: string[]; + nonLinearClickThroughURLTemplate: string; + adParameters: string; type: string; - videoClickThroughURLTemplate: string; - videoClickTrackingURLTemplates: string[]; - videoCustomClickURLTempaltes: string[]; -} - -export interface VastCreativeCompanion { - type: string; - variations: VastCompanionAd[]; + iframeResource: string; + htmlResource: string; + id: string; + width: string; + height: string; + expandedWidth: string; + expandedHeight: string; + scalablle: boolean; + maintainAspectRatio: boolean; + minSuggestedDuration: number; + apiFramework: any; } export interface VastCompanionAd { diff --git a/types/vast-client/vast-client-tests.ts b/types/vast-client/vast-client-tests.ts index eed1416c7a..aadf2c8370 100644 --- a/types/vast-client/vast-client-tests.ts +++ b/types/vast-client/vast-client-tests.ts @@ -5,6 +5,13 @@ function cb(response: DMVAST.VastResponse, error: Error): void { if (error) return; // process the VAST response const ads: DMVAST.VastAd[] = response.ads; + const linearCreative = response.ads[0].creatives.filter(creative => { + return creative.type === 'linear'; + }); + if (linearCreative && linearCreative.length > 0) { + const creative = linearCreative[0] as DMVAST.VastCreativeLinear; + const mediaFiles = creative.mediaFiles; + } } // CLIENT