Documentation
¶
Overview ¶
Package native implements the OpenRTB bid response item for native ad formats. Native ads deliver structured data (title, image, link, etc.) that is rendered by the publisher according to its own design guidelines.
Index ¶
- Variables
- type ResponseBidItem
- func (it *ResponseBidItem) ActionURL() string
- func (it *ResponseBidItem) Assets() admodels.AdFileAssets
- func (it *ResponseBidItem) ClickTrackerLinks() []string
- func (it *ResponseBidItem) ContentFields() map[string]any
- func (it *ResponseBidItem) ContentItem(name string) any
- func (it *ResponseBidItem) ContentItemString(name string) string
- func (it *ResponseBidItem) ImpressionTrackerLinks() []string
- func (it *ResponseBidItem) MainAsset(assetType types.AdFileAssetType) *admodels.AdFileAsset
- func (it *ResponseBidItem) SetContentItem(name string, value any) error
Constants ¶
This section is empty.
Variables ¶
var ErrMissingRequiredAsset = errors.New("missing required native asset")
ErrMissingRequiredAsset is returned when a required native asset declared in the format config is absent from the bid response.
Functions ¶
This section is empty.
Types ¶
type ResponseBidItem ¶
type ResponseBidItem struct {
common.BaseBidItem
// Native-specific fields
Native *natresp.Response `json:"native,omitempty"`
ActionLink string `json:"action_link,omitempty"`
Data map[string]any `json:"data,omitempty"`
// contains filtered or unexported fields
}
ResponseBidItem is the bid response item for native ad formats. It implements adtype.ResponseItem and provides access to the decoded native assets, link, trackers, and pricing information.
func New ¶
func New(req adtype.BidRequester, src adtype.Source, bid *openrtb.Bid, imp *adtype.Impression, format *types.Format, rules rtbrules.RTBRuler) (*ResponseBidItem, error)
New creates a ResponseBidItem for a native bid. It decodes the JSON native markup from the OpenRTB Bid, maps asset IDs to content fields, and validates that all required format assets are present in the response.
func (*ResponseBidItem) ActionURL ¶
func (it *ResponseBidItem) ActionURL() string
ActionURL returns the main click-through URL from the native response link.
func (*ResponseBidItem) Assets ¶
func (it *ResponseBidItem) Assets() admodels.AdFileAssets
Assets returns the file assets extracted from the native bid response.
func (*ResponseBidItem) ClickTrackerLinks ¶
func (it *ResponseBidItem) ClickTrackerLinks() []string
ClickTrackerLinks returns third-party tracker URLs fired on click.
func (*ResponseBidItem) ContentFields ¶
func (it *ResponseBidItem) ContentFields() map[string]any
ContentFields returns a map of all content fields for the native ad, keyed by the format field names defined in the format configuration.
func (*ResponseBidItem) ContentItem ¶
func (it *ResponseBidItem) ContentItem(name string) any
ContentItem returns the ad response data for the given field name.
func (*ResponseBidItem) ContentItemString ¶
func (it *ResponseBidItem) ContentItemString(name string) string
ContentItemString returns the string value of a named content field.
func (*ResponseBidItem) ImpressionTrackerLinks ¶
func (it *ResponseBidItem) ImpressionTrackerLinks() []string
ImpressionTrackerLinks returns tracking links fired on impression.
func (*ResponseBidItem) MainAsset ¶
func (it *ResponseBidItem) MainAsset(assetType types.AdFileAssetType) *admodels.AdFileAsset
MainAsset returns the primary file asset matched against the format configuration.
func (*ResponseBidItem) SetContentItem ¶
func (it *ResponseBidItem) SetContentItem(name string, value any) error
SetContentItem sets the value of a named content field in the bid response. It updates the native response structure and the Data map, and also adds any associated file assets to the assets slice.