@@ -19,30 +19,32 @@ type Impression struct {
1919 Tagid * string `json:"tagid,omitempty"` // Identifier for specific ad placement or ad tag
2020 Bidfloor * float32 `json:"bidfloor,omitempty"` // Bid floor for this impression in CPM
2121 Bidfloorcur * string `json:"bidfloorcur,omitempty"` // Currency of bid floor
22+ Secure * int `json:"secure,omitempty"` // Flag to indicate whether the impression requires secure HTTPS URL creative assets and markup.
2223 Iframebuster []string `json:"iframebuster,omitempty"` // Array of names for supportediframe busters.
24+ Pmp * Pmp `json:"pmp,omitempty"` // A reference to the PMP object containing any Deals eligible for the impression object.
2325 Ext Extensions `json:"ext,omitempty"`
2426}
2527
2628// Validation errors
2729var (
28- invalidImpId = errors .New ("openrtb parse: impression ID missing" )
29- invalidImpBoV = errors .New ("openrtb parse: impression has neither a banner nor video" )
30- invalidImpBaV = errors .New ("openrtb parse: impression has banner and video" )
30+ ErrInvalidImpID = errors .New ("openrtb parse: impression ID missing" )
31+ ErrInvalidImpBoV = errors .New ("openrtb parse: impression has neither a banner nor video" )
32+ ErrInvalidImpBaV = errors .New ("openrtb parse: impression has banner and video" )
3133)
3234
3335// Validates the `imp` object
3436func (imp * Impression ) Valid () (bool , error ) {
3537
3638 if imp .Id == nil {
37- return false , invalidImpId
39+ return false , ErrInvalidImpID
3840 } else if imp .Banner != nil && imp .Video != nil {
39- return false , invalidImpBaV
41+ return false , ErrInvalidImpBaV
4042 } else if imp .Video != nil {
4143 if ok , err := imp .Video .Valid (); ! ok {
4244 return ok , err
4345 }
4446 } else if imp .Banner == nil {
45- return false , invalidImpBoV
47+ return false , ErrInvalidImpBoV
4648 }
4749
4850 return true , nil
@@ -86,19 +88,13 @@ func (imp *Impression) SetId(id string) *Impression {
8688}
8789
8890// Set the Banner
89- func (imp * Impression ) SetBanner (b Banner ) * Impression {
90- if imp .Banner == nil {
91- imp .Banner = new (Banner )
92- }
93- * imp .Banner = b
91+ func (imp * Impression ) SetBanner (b * Banner ) * Impression {
92+ imp .Banner = b
9493 return imp
9594}
9695
9796// Set the Video
98- func (imp * Impression ) SetVideo (v Video ) * Impression {
99- if imp .Video == nil {
100- imp .Video = new (Video )
101- }
102- * imp .Video = v
97+ func (imp * Impression ) SetVideo (v * Video ) * Impression {
98+ imp .Video = v
10399 return imp
104100}
0 commit comments