Skip to content

Commit 8a0e548

Browse files
authored
Merge pull request haxqer#4 from ClearcodeHQ/fix-order-of-remaining-structures
Fix order of remaining structures
2 parents d67a54b + c54d136 commit 8a0e548

9 files changed

+95
-86
lines changed

testdata/vast_inline_linear-duration_undefined.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AdSystem version="1.0">Acudeo Compatible</AdSystem>
66
<AdTitle>VAST 2.0 Instream Test 1</AdTitle>
77
<Creatives>
8-
<Creative AdID="601364">
8+
<Creative adId="601364">
99
<Linear>
1010
<Duration>undefined</Duration>
1111
<MediaFiles>

testdata/vast_inline_linear.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Impression>http://myTrackingURL/impression</Impression>
1111
<Impression id="foo">http://myTrackingURL/impression2</Impression>
1212
<Creatives>
13-
<Creative AdID="601364">
13+
<Creative adId="601364">
1414
<Linear>
1515
<Duration>00:00:30</Duration>
1616
<TrackingEvents>
@@ -30,7 +30,7 @@
3030
</MediaFiles>
3131
</Linear>
3232
</Creative>
33-
<Creative AdID="601364-Companion">
33+
<Creative adId="601364-Companion">
3434
<CompanionAds required="all">
3535
<Companion width="300" height="250">
3636
<StaticResource creativeType="image/jpeg">http://demo.tremormedia.com/proddev/vast/Blistex1.jpg</StaticResource>

testdata/vast_inline_nonlinear.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Error>http://myErrorURL/error</Error>
1010
<Impression>http://myTrackingURL/impression</Impression>
1111
<Creatives>
12-
<Creative AdID="602678-NonLinear">
12+
<Creative adId="602678-NonLinear">
1313
<NonLinearAds>
1414
<TrackingEvents>
1515
<Tracking event="creativeView">http://myTrackingURL/nonlinear/creativeView</Tracking>
@@ -32,7 +32,7 @@
3232
</NonLinear>
3333
</NonLinearAds>
3434
</Creative>
35-
<Creative AdID="602678-Companion">
35+
<Creative adId="602678-Companion">
3636
<CompanionAds>
3737
<Companion width="300" height="250">
3838
<StaticResource creativeType="application/x-shockwave-flash">http://demo.tremormedia.com/proddev/vast/300x250_companion_1.swf</StaticResource>

testdata/vast_wrapper_linear_1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Error>http://myErrorURL/wrapper/error</Error>
88
<Impression>http://myTrackingURL/wrapper/impression</Impression>
99
<Creatives>
10-
<Creative AdID="602833">
10+
<Creative adId="602833">
1111
<Linear>
1212
<TrackingEvents>
1313
<Tracking event="creativeView">http://myTrackingURL/wrapper/creativeView</Tracking>
@@ -31,7 +31,7 @@
3131
</VideoClicks>
3232
</Linear>
3333
</Creative>
34-
<Creative AdID="602833-NonLinearTracking">
34+
<Creative adId="602833-NonLinearTracking">
3535
<NonLinearAds>
3636
<TrackingEvents>
3737
<Tracking event="creativeView">http://myTrackingURL/wrapper/creativeView</Tracking>

testdata/vast_wrapper_linear_2.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<VASTAdTagURI>http://demo.tremormedia.com/proddev/vast/vast_inline_linear.xml</VASTAdTagURI>
77
<Impression>http://myTrackingURL/wrapper/impression</Impression>
88
<Creatives>
9-
<Creative AdID="602833">
9+
<Creative adId="602833">
1010
<Linear>
1111
<TrackingEvents>
1212
</TrackingEvents>
1313
</Linear>
1414
</Creative>
15-
<Creative AdID="602833-Companion">
15+
<Creative adId="602833-Companion">
1616
<CompanionAds>
1717
<Companion width="300" height="250">
1818
<StaticResource creativeType="image/jpeg">http://demo.tremormedia.com/proddev/vast/300x250_banner1.jpg</StaticResource>

testdata/vast_wrapper_nonlinear_1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<Error>http://myErrorURL/wrapper/error</Error>
88
<Impression>http://myTrackingURL/wrapper/impression</Impression>
99
<Creatives>
10-
<Creative AdID="602867">
10+
<Creative adId="602867">
1111
<Linear>
1212
<TrackingEvents>
1313
</TrackingEvents>
1414
</Linear>
1515
</Creative>
16-
<Creative AdID="602867-NonLinearTracking">
16+
<Creative adId="602867-NonLinearTracking">
1717
<NonLinearAds>
1818
<TrackingEvents>
1919
<Tracking event="creativeView">http://myTrackingURL/wrapper/nonlinear/creativeView/creativeView</Tracking>

testdata/vast_wrapper_nonlinear_2.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
<VASTAdTagURI>http://demo.tremormedia.com/proddev/vast/vast_inline_nonlinear3.xml</VASTAdTagURI>
77
<Impression>http://myTrackingURL/wrapper/impression</Impression>
88
<Creatives>
9-
<Creative AdID="602867">
9+
<Creative adId="602867">
1010
<Linear>
1111
<TrackingEvents>
1212
</TrackingEvents>
1313
</Linear>
1414
</Creative>
15-
<Creative AdID="602867-NonLinearTracking">
15+
<Creative adId="602867-NonLinearTracking">
1616
<NonLinearAds>
1717
<TrackingEvents>
1818
</TrackingEvents>
1919
</NonLinearAds>
2020
</Creative>
21-
<Creative AdID="602867-Companion">
21+
<Creative adId="602867-Companion">
2222
<CompanionAds>
2323
<Companion width="300" height="250">
2424
<StaticResource creativeType="image/jpeg">http://demo.tremormedia.com/proddev/vast/300x250_banner1.jpg</StaticResource>

vast.go

Lines changed: 78 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ type VAST struct {
2626
//
2727
// Each <Ad> contains a single <InLine> element or <Wrapper> element (but never both).
2828
type Ad struct {
29+
InLine *InLine `xml:",omitempty" json:",omitempty"`
30+
Wrapper *Wrapper `xml:",omitempty" json:",omitempty"`
2931
// An ad server-defined identifier string for the ad
3032
ID string `xml:"id,attr,omitempty" json:",omitempty"`
31-
32-
// Custom attr
33-
Type string `xml:"type,attr,omitempty" json:",omitempty"`
34-
3533
// A number greater than zero (0) that identifies the sequence in which
3634
// an ad should play; all <Ad> elements with sequence values are part of
3735
// a pod and are intended to be played in sequence
3836
Sequence int `xml:"sequence,attr,omitempty" json:",omitempty"`
39-
InLine *InLine `xml:",omitempty" json:",omitempty"`
40-
Wrapper *Wrapper `xml:",omitempty" json:",omitempty"`
37+
// An optional string that identifies the type of ad
38+
// Possible values –video, audio, hybrid. Assumed to be video if attribute is not present
39+
AdType string `xml:"adType,attr,omitempty" json:",omitempty"`
4140
}
4241

4342
// CDATAString ...
@@ -53,44 +52,44 @@ type CDATAString struct {
5352
type InLine struct {
5453
// The name of the ad server that returned the ad
5554
AdSystem *AdSystem
55+
// A URI representing an error-tracking pixel; this element can occur multiple
56+
// times.
57+
Errors []CDATAString `xml:"Error,omitempty" json:"Error,omitempty"`
58+
// XML node for custom extensions, as defined by the ad server. When used, a
59+
// custom element should be nested under <Extensions> to help separate custom
60+
// XML elements from VAST elements. The following example includes a custom
61+
// xml element within the Extensions element.
62+
Extensions *[]Extension `xml:"Extensions>Extension,omitempty" json:",omitempty"`
5663
// One or more URIs that directs the video player to a tracking resource file that the
5764
// video player should request when the first frame of the ad is displayed
5865
Impressions []Impression `xml:"Impression"`
66+
// Provides a value that represents a price that can be used by real-time bidding
67+
// (RTB) systems. VAST is not designed to handle RTB since other methods exist,
68+
// but this element is offered for custom solutions if needed.
69+
Pricing *Pricing `xml:",omitempty" json:",omitempty"`
5970
// Any ad server that returns a VAST containing an <InLine> ad must generate a pseudo- unique identifier
6071
// that is appropriate for all involved parties to track the lifecycle of that ad.
6172
// Example: ServerName-47ed3bac-1768-4b9a-9d0e-0b92422ab066
6273
AdServingId string `xml:",omitempty" json:",omitempty"`
6374
// The common name of the ad
6475
AdTitle CDATAString
65-
// The container for one or more <Creative> elements
66-
Creatives []Creative `xml:"Creatives>Creative"`
67-
// A string value that provides a longer description of the ad.
68-
Description *CDATAString `xml:",omitempty" json:",omitempty"`
6976
// The name of the advertiser as defined by the ad serving party.
7077
// This element can be used to prevent displaying ads with advertiser
7178
// competitors. Ad serving parties and publishers should identify how
7279
// to interpret values provided within this element. As with any optional
7380
// elements, the video player is not required to support it.
7481
Advertiser string `xml:",omitempty" json:",omitempty"`
82+
// The container for one or more <Creative> elements
83+
Creatives []Creative `xml:"Creatives>Creative"`
84+
// A string value that provides a longer description of the ad.
85+
Description *CDATAString `xml:",omitempty" json:",omitempty"`
7586
// A URI to a survey vendor that could be the survey, a tracking pixel,
7687
// or anything to do with the survey. Multiple survey elements can be provided.
7788
// A type attribute is available to specify the MIME type being served.
7889
// For example, the attribute might be set to type=”text/javascript”.
7990
// Surveys can be dynamically inserted into the VAST response as long as
8091
// cross-domain issues are avoided.
8192
Survey *CDATAString `xml:",omitempty" json:",omitempty"`
82-
// A URI representing an error-tracking pixel; this element can occur multiple
83-
// times.
84-
Errors []CDATAString `xml:"Error,omitempty" json:"Error,omitempty"`
85-
// Provides a value that represents a price that can be used by real-time bidding
86-
// (RTB) systems. VAST is not designed to handle RTB since other methods exist,
87-
// but this element is offered for custom solutions if needed.
88-
Pricing *Pricing `xml:",omitempty" json:",omitempty"`
89-
// XML node for custom extensions, as defined by the ad server. When used, a
90-
// custom element should be nested under <Extensions> to help separate custom
91-
// XML elements from VAST elements. The following example includes a custom
92-
// xml element within the Extensions element.
93-
Extensions *[]Extension `xml:"Extensions>Extension,omitempty" json:",omitempty"`
9493
}
9594

9695
// Impression is a URI that directs the video player to a tracking resource file that
@@ -125,22 +124,21 @@ type Pricing struct {
125124
type Wrapper struct {
126125
// The name of the ad server that returned the ad
127126
AdSystem *AdSystem
128-
// URL of ad tag of downstream Secondary Ad Server
129-
VASTAdTagURI CDATAString
130-
// One or more URIs that directs the video player to a tracking resource file that the
131-
// video player should request when the first frame of the ad is displayed
132-
Impressions []Impression `xml:"Impression"`
133127
// A URI representing an error-tracking pixel; this element can occur multiple
134128
// times.
135129
Errors []CDATAString `xml:"Error,omitempty" json:"Error,omitempty"`
136-
// The container for one or more <Creative> elements
137-
Creatives []CreativeWrapper `xml:"Creatives>Creative"`
138130
// XML node for custom extensions, as defined by the ad server. When used, a
139131
// custom element should be nested under <Extensions> to help separate custom
140132
// XML elements from VAST elements. The following example includes a custom
141133
// xml element within the Extensions element.
142134
Extensions []Extension `xml:"Extensions>Extension,omitempty" json:",omitempty"`
143-
135+
// One or more URIs that directs the video player to a tracking resource file that the
136+
// video player should request when the first frame of the ad is displayed
137+
Impressions []Impression `xml:"Impression"`
138+
// URL of ad tag of downstream Secondary Ad Server
139+
// The container for one or more <Creative> elements
140+
Creatives []CreativeWrapper `xml:"Creatives>Creative"`
141+
VASTAdTagURI CDATAString
144142
FallbackOnNoAd *bool `xml:"fallbackOnNoAd,attr,omitempty" json:",omitempty"`
145143
AllowMultipleAds *bool `xml:"allowMultipleAds,attr,omitempty" json:",omitempty"`
146144
FollowAdditionalWrappers *bool `xml:"followAdditionalWrappers,attr,omitempty" json:",omitempty"`
@@ -159,7 +157,7 @@ type Creative struct {
159157
// The preferred order in which multiple Creatives should be displayed
160158
Sequence int `xml:"sequence,attr,omitempty" json:",omitempty"`
161159
// Identifies the ad with which the creative is served
162-
AdID string `xml:"AdID,attr,omitempty" json:",omitempty"`
160+
AdID string `xml:"adId,attr,omitempty" json:",omitempty"`
163161
// The technology used for any included API
164162
APIFramework string `xml:"apiFramework,attr,omitempty" json:",omitempty"`
165163
// If present, provides a VAST 4.x universal ad id
@@ -207,7 +205,7 @@ type CreativeWrapper struct {
207205
// The preferred order in which multiple Creatives should be displayed
208206
Sequence int `xml:"sequence,attr,omitempty" json:",omitempty"`
209207
// Identifies the ad with which the creative is served
210-
AdID string `xml:"AdID,attr,omitempty" json:",omitempty"`
208+
AdID string `xml:"adId,attr,omitempty" json:",omitempty"`
211209
// If present, defines a linear creative
212210
Linear *LinearWrapper `xml:",omitempty" json:",omitempty"`
213211
// If defined, defines companions creatives
@@ -248,11 +246,11 @@ type Linear struct {
248246
// indicates when the skip control should be provided after the creative
249247
// begins playing.
250248
SkipOffset *Offset `xml:"skipoffset,attr,omitempty" json:",omitempty"`
251-
AdParameters *AdParameters `xml:",omitempty" json:",omitempty"`
252249
Icons *Icons `json:",omitempty"`
253250
TrackingEvents []Tracking `xml:"TrackingEvents>Tracking,omitempty" json:",omitempty"`
251+
AdParameters *AdParameters `xml:",omitempty" json:",omitempty"`
254252
// Duration in standard time format, hh:mm:ss
255-
Duration Duration
253+
Duration Duration `xml:"Duration,omitempty" json:",omitempty"`
256254
MediaFiles []MediaFile `xml:"MediaFiles>MediaFile,omitempty" json:",omitempty"`
257255
VideoClicks *VideoClicks `xml:",omitempty" json:",omitempty"`
258256
}
@@ -284,24 +282,24 @@ type Companion struct {
284282
APIFramework string `xml:"apiFramework,attr,omitempty" json:",omitempty"`
285283
// Used to match companion creative to publisher placement areas on the page.
286284
AdSlotID string `xml:"adSlotId,attr,omitempty" json:",omitempty"`
285+
// HTML to display the companion element
286+
HTMLResource *HTMLResource `xml:",omitempty" json:",omitempty"`
287+
// URL source for an IFrame to display the companion element
288+
IFrameResource *CDATAString `xml:",omitempty" json:",omitempty"`
289+
// URL to a static file, such as an image or SWF file
290+
StaticResource *StaticResource `xml:",omitempty" json:",omitempty"`
291+
// Data to be passed into the companion ads. The apiFramework defines the method
292+
// to use for communication (e.g. “FlashVar”)
293+
AdParameters *AdParameters `xml:",omitempty" json:",omitempty"`
294+
// Alt text to be displayed when companion is rendered in HTML environment.
295+
AltText string `xml:",omitempty" json:",omitempty"`
287296
// URL to open as destination page when user clicks on the the companion banner ad.
288297
CompanionClickThrough *CDATAString `xml:",omitempty" json:",omitempty"`
289298
// URLs to ping when user clicks on the the companion banner ad.
290-
CompanionClickTracking []CDATAString `xml:",omitempty" json:",omitempty"`
291-
// Alt text to be displayed when companion is rendered in HTML environment.
292-
AltText string `xml:",omitempty" json:",omitempty"`
299+
CompanionClickTracking CompanionClickTracking `xml:",omitempty" json:",omitempty"`
293300
// The creativeView should always be requested when present. For Companions
294301
// creativeView is the only supported event.
295302
TrackingEvents []Tracking `xml:"TrackingEvents>Tracking,omitempty" json:",omitempty"`
296-
// Data to be passed into the companion ads. The apiFramework defines the method
297-
// to use for communication (e.g. “FlashVar”)
298-
AdParameters *AdParameters `xml:",omitempty" json:",omitempty"`
299-
// URL to a static file, such as an image or SWF file
300-
StaticResource *StaticResource `xml:",omitempty" json:",omitempty"`
301-
// URL source for an IFrame to display the companion element
302-
IFrameResource *CDATAString `xml:",omitempty" json:",omitempty"`
303-
// HTML to display the companion element
304-
HTMLResource *HTMLResource `xml:",omitempty" json:",omitempty"`
305303
}
306304

307305
// CompanionWrapper defines a companion ad in a wrapper
@@ -365,18 +363,18 @@ type NonLinear struct {
365363
MinSuggestedDuration *Duration `xml:"minSuggestedDuration,attr,omitempty" json:",omitempty"`
366364
// The apiFramework defines the method to use for communication with the nonlinear element.
367365
APIFramework string `xml:"apiFramework,attr,omitempty" json:",omitempty"`
368-
// URLs to ping when user clicks on the the non-linear ad.
369-
NonLinearClickTracking []CDATAString `xml:",omitempty" json:",omitempty"`
370-
// URL to open as destination page when user clicks on the non-linear ad unit.
371-
NonLinearClickThrough *CDATAString `xml:",omitempty" json:",omitempty"`
372-
// Data to be passed into the video ad.
373-
AdParameters *AdParameters `xml:",omitempty" json:",omitempty"`
374-
// URL to a static file, such as an image or SWF file
375-
StaticResource *StaticResource `xml:",omitempty" json:",omitempty"`
376-
// URL source for an IFrame to display the companion element
377-
IFrameResource *CDATAString `xml:",omitempty" json:",omitempty"`
378366
// HTML to display the companion element
379367
HTMLResource *HTMLResource `xml:",omitempty" json:",omitempty"`
368+
// URL source for an IFrame to display the companion element
369+
IFrameResource *CDATAString `xml:",omitempty" json:",omitempty"`
370+
// URL to a static file, such as an image or SWF file
371+
StaticResource *StaticResource `xml:",omitempty" json:",omitempty"`
372+
// Data to be passed into the video ad.
373+
AdParameters *AdParameters `xml:",omitempty" json:",omitempty"`
374+
// URL to open as destination page when user clicks on the non-linear ad unit.
375+
NonLinearClickThrough *CDATAString `xml:",omitempty" json:",omitempty"`
376+
// URLs to ping when user clicks on the the non-linear ad.
377+
NonLinearClickTracking NonLinearClickTracking `xml:",omitempty" json:",omitempty"`
380378
}
381379

382380
// NonLinearWrapper defines a non linear ad in a wrapper
@@ -431,16 +429,18 @@ type Icon struct {
431429
Duration Duration `xml:"duration,attr"`
432430
// The apiFramework defines the method to use for communication with the icon element
433431
APIFramework string `xml:"apiFramework,attr,omitempty" json:",omitempty"`
432+
// HTML to display the companion element
433+
HTMLResource *HTMLResource `xml:",omitempty" json:",omitempty"`
434+
// URL source for an IFrame to display the companion element
435+
IFrameResource *CDATAString `xml:",omitempty" json:",omitempty"`
436+
// URL to a static file, such as an image or SWF file
437+
StaticResource *StaticResource `xml:",omitempty" json:",omitempty"`
434438
// URL to open as destination page when user clicks on the icon.
435439
IconClickThrough *CDATAString `xml:"IconClicks>IconClickThrough,omitempty" json:",omitempty"`
436440
// URLs to ping when user clicks on the the icon.
437441
IconClickTrackings []CDATAString `xml:"IconClicks>IconClickTracking,omitempty" json:",omitempty"`
438-
// URL to a static file, such as an image or SWF file
439-
StaticResource *StaticResource `xml:",omitempty" json:",omitempty"`
440-
// URL source for an IFrame to display the companion element
441-
IFrameResource *CDATAString `xml:",omitempty" json:",omitempty"`
442-
// HTML to display the companion element
443-
HTMLResource *HTMLResource `xml:",omitempty" json:",omitempty"`
442+
// A URI for the tracking resource file to be called when the icon creative is displayed.
443+
IconViewTracking *CDATAString `xml:"IconViewTracking,omitempty" json:",omitempty"`
444444
}
445445

446446
// Tracking defines an event tracking URL
@@ -532,13 +532,26 @@ type MediaFile struct {
532532
// placed in key/value pairs on the asset request).
533533
APIFramework string `xml:"apiFramework,attr,omitempty" json:",omitempty"`
534534
URI string `xml:",cdata"`
535-
// Label
536-
Label string `xml:"label,attr,omitempty" json:",omitempty"`
535+
// Optional field that helps eliminate the need to calculate the size based on bitrate and duration.
536+
FileSize int `xml:"fileSize,attr,omitempty" json:",omitempty"`
537+
// Type of media file (2D / 3D / 360 / etc).
538+
MediaType string `xml:"mediaType,attr,omitempty" json:",omitempty"`
537539
}
538540

539541
// UniversalAdID describes a VAST 4.x universal ad id.
540542
type UniversalAdID struct {
541543
IDRegistry string `xml:"idRegistry,attr"`
542-
IDValue string `xml:"idValue,attr,omitempty"`
543544
ID string `xml:",cdata"`
544545
}
546+
547+
// CompanionClickTracking element is used to track the click
548+
type CompanionClickTracking struct {
549+
// An id provided by the ad server to track the click in reports.
550+
ID string `xml:"id,attr,omitempty" json:",omitempty"`
551+
}
552+
553+
// NonLinearClickTracking element is used to track the click
554+
type NonLinearClickTracking struct {
555+
// An id provided by the ad server to track the click in reports
556+
ID string `xml:"id,attr,omitempty" json:",omitempty"`
557+
}

0 commit comments

Comments
 (0)