openrtbnative

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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

View Source
const (
	ImageTypeIcon = 1
	ImageTypeMain = 3
)

Native asset image types (IAB Native Ads 1.2, Image Object "type").

View Source
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").

View Source
const Target = "openrtb_native"

Target identifies this adapter's Binding.Target value.

Variables

This section is empty.

Functions

func DataField

func DataField(id, dataType int) adformat.Binding

DataField builds a Binding associating a Field with an OpenRTB Native data asset.

func ImageAsset

func ImageAsset(id, imageType int) adformat.Binding

ImageAsset builds a Binding associating an AssetRequirement with an OpenRTB Native image asset.

func TitleField

func TitleField(id int) adformat.Binding

TitleField builds a Binding associating a Field with the OpenRTB Native title asset.

func Validate

func Validate(cfg *adformat.Config) error

Validate checks that every openrtb_native binding in cfg has a non-zero, unique (within cfg) id — the one cross-Node invariant this specific target actually needs; deliberately not part of the generic Config.Validate (§3.2.6), which knows nothing about any target.

func VideoAsset

func VideoAsset(id int, protocols, apis []int) adformat.Binding

VideoAsset builds a Binding associating an AssetRequirement with an OpenRTB Native video 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).

func GetData

func GetData(f adformat.Field) (DataParams, bool)

GetData decodes the openrtb_native data binding of f, if any.

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

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.

func GetTitle

func GetTitle(f adformat.Field) (TitleParams, bool)

GetTitle decodes the openrtb_native title binding of f, if any.

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

GetVideo decodes the openrtb_native video binding of a, if any.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL