openrtb2: resolve Banner TODOs

- bring back removed fields - only deprecate, do not remove
- reuse adcom1 enums
This commit is contained in:
mxmCherry
2022-05-16 22:06:06 +03:00
parent 2d835abf5f
commit 516ccc6485
4 changed files with 46 additions and 13 deletions
+1 -1
View File
@@ -10,5 +10,5 @@ const (
ExpandableUp ExpandableDirection = 3 // Up
ExpandableDown ExpandableDirection = 4 // Down
ExpandableFullScreen ExpandableDirection = 5 // Full Screen
ExpandableSmaller ExpandableDirection = 6 // Resize/Minimize (make smaller)
ExpandableResize ExpandableDirection = 6 // Resize/Minimize (make smaller)
)
+14
View File
@@ -6,6 +6,7 @@ type PlacementPosition int8
// Placement positions.
const (
PositionUnknown PlacementPosition = 0 // Unknown
PositionAboveFold PlacementPosition = 1 // Above The Fold
PositionLocked PlacementPosition = 2 // Locked (i.e., fixed position)
PositionBelowFold PlacementPosition = 3 // Below The Fold
@@ -14,3 +15,16 @@ const (
PositionSideBar PlacementPosition = 6 // Sidebar
PositionFullScreen PlacementPosition = 7 // Fullscreen
)
// Ptr returns pointer to own value.
func (p PlacementPosition) Ptr() *PlacementPosition {
return &p
}
// Val safely dereferences pointer, returning default value (AdPositionUnknown) for nil.
func (p *PlacementPosition) Val() PlacementPosition {
if p == nil {
return PositionUnknown
}
return *p
}
+18 -12
View File
@@ -1,6 +1,10 @@
package openrtb2
import "encoding/json"
import (
"encoding/json"
"github.com/mxmCherry/openrtb/v16/adcom1"
)
// 3.2.6 Object: Banner
//
@@ -76,19 +80,15 @@ type Banner struct {
// NOTE: Deprecated in favor of the format array.
// Minimum height in device independent pixels (DIPS).
HMin int64 `json:"hmin,omitempty"`
// Attribute:
// btype
// Type:
// integer array
// Description:
// Blocked banner ad types.
// Values:
// 1 = XHTML Text Ad,
// 2 = XHTML Banner Ad,
// 3 = JavaScript Ad,
// 4 = iframe.
BType []int8 `json:"btype,omitempty"`
// Refer to BannerAdType constants.
BType []BannerAdType `json:"btype,omitempty"`
// Attribute:
// battr
@@ -96,7 +96,9 @@ type Banner struct {
// integer array
// Description:
// Blocked creative attributes. Refer to List: Creative Attributes in AdCOM 1.0.
BAttr []int64 `json:"battr,omitempty"`
// Note:
// OpenRTB <=2.5 defined only attributes with IDs 1..17.
BAttr []adcom1.CreativeAttribute `json:"battr,omitempty"`
// Attribute:
// pos
@@ -104,7 +106,7 @@ type Banner struct {
// integer
// Description:
// Ad position on screen. Refer to List: Placement Positions in AdCOM 1.0.
Pos *int8 `json:"pos,omitempty"`
Pos *adcom1.PlacementPosition `json:"pos,omitempty"`
// Attribute:
// mimes
@@ -131,7 +133,9 @@ type Banner struct {
// Description:
// Directions in which the banner may expand. Refer to List: Expandable
// Directions in AdCOM 1.0.
ExpDir []int8 `json:"expdir,omitempty"`
// Note:
// OpenRTB <=2.5 defined only directions 1..5.
ExpDir []adcom1.ExpandableDirection `json:"expdir,omitempty"`
// Attribute:
// api
@@ -141,7 +145,9 @@ type Banner struct {
// List of supported API frameworks for this impression. Refer to List: API
// Frameworks in AdCOM 1.0. If an API is not explicitly listed, it is assumed
// not to be supported.
API []int64 `json:"api,omitempty"`
// Note:
// OpenRTB <=2.5 defined only frameworks 1..6.
API []adcom1.APIFramework `json:"api,omitempty"`
// Attribute:
// id
+13
View File
@@ -0,0 +1,13 @@
package openrtb2
// BannerAdType
//
// Types of ads that can be accepted by the exchange unless restricted by publisher site settings.
type BannerAdType int8
const (
BannerAdTypeXHTMLTextAd BannerAdType = 1 // XHTML Text Ad (usually mobile)
BannerAdTypeXHTMLBannerAd BannerAdType = 2 // XHTML Banner Ad. (usually mobile)
BannerAdTypeJavaScriptAd BannerAdType = 3 // JavaScript Ad; must be valid XHTML (i.e., Script Tags Included)
BannerAdTypeIframe BannerAdType = 4 // iframe
)