Documentation
¶
Overview ¶
Package openrtbnative is a reference adformat.Binding adapter (§3.2.12) associating adformat assets/fields with OpenRTB Native 1.2 asset objects — a concrete, typed replacement for the name-based guessing that adsource-openrtb currently does (see adsource-openrtb/request/v2/builder.go), and for the always-empty FormatFileRequirement.ID/FormatField.ID of the old model.
adformat's core package has zero knowledge of this package or of OpenRTB at all — Binding.Target/Params is a generic, opaque key/value pair, and everything OpenRTB-specific (constants, typed params, getters) lives here instead. Constants below are declared locally per the IAB Native Ads 1.2 spec, not reused from github.com/bsm/openrtb, so adcorelib/adformat does not gain an external dependency just to describe a format.
Index ¶
- Constants
- func DataField(id, dataType int) adformat.Binding
- func ImageAsset(id, imageType int) adformat.Binding
- func TitleField(id int) adformat.Binding
- func Validate(cfg *adformat.Config) error
- func VideoAsset(id int, protocols, apis []int) adformat.Binding
- type DataParams
- type ImageParams
- type TitleParams
- type VideoParams
Constants ¶
const ( ImageTypeIcon = 1 ImageTypeLogo = 2 ImageTypeMain = 3 )
Native asset image types (IAB Native Ads 1.2, Image Object "type").
const ( DataTypeSponsored = 1 DataTypeDesc = 2 DataTypeRating = 3 DataTypeLikes = 4 DataTypeDownloads = 5 DataTypePrice = 6 DataTypeSalePrice = 7 DataTypePhone = 8 DataTypeAddress = 9 DataTypeDescAdditional = 10 DataTypeDisplayURL = 11 DataTypeCTAText = 12 )
Native asset data types (IAB Native Ads 1.2, Data Object "type").
const Target = "openrtb_native"
Target identifies this adapter's Binding.Target value.
Variables ¶
This section is empty.
Functions ¶
func ImageAsset ¶
ImageAsset builds a Binding associating an AssetRequirement with an OpenRTB Native image asset.
func TitleField ¶
TitleField builds a Binding associating a Field with the OpenRTB Native title asset.
Types ¶
type DataParams ¶
type DataParams struct {
ID int `json:"id"`
DataType int `json:"data_type"` // DataTypeDesc/Rating/.../CTAText
}
DataParams is the Binding.Params shape for a data asset (a Field bound to a non-title OpenRTB Native data object).
type ImageParams ¶
type ImageParams struct {
ID int `json:"id"` // stable, format-author-assigned asset id (passed 1:1 into the OpenRTB request/response)
ImageType int `json:"image_type"` // ImageTypeIcon/Logo/Main
}
ImageParams is the Binding.Params shape for an image asset.
func GetImage ¶
func GetImage(a adformat.AssetRequirement) (ImageParams, bool)
GetImage decodes the openrtb_native image binding of a, if any.
type TitleParams ¶
type TitleParams struct {
ID int `json:"id"`
}
TitleParams is the Binding.Params shape for the title asset. The title's length limit is intentionally not duplicated here — it is already Field.Max (a general, protocol-agnostic property, see adformat.Field), and an adapter building an OpenRTB request reads it from there instead, so the same constraint cannot drift between the two places.
type VideoParams ¶
type VideoParams struct {
ID int `json:"id"`
Protocols []int `json:"protocols,omitempty"` // VAST versions (OpenRTB Video.Protocols)
APIs []int `json:"apis,omitempty"` // MRAID/VPAID versions (OpenRTB Video.API)
}
VideoParams is the Binding.Params shape for a video asset nested inside a native ad.
func GetVideo ¶
func GetVideo(a adformat.AssetRequirement) (VideoParams, bool)
GetVideo decodes the openrtb_native video binding of a, if any.