native

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: 19 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

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 (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 (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.

Jump to

Keyboard shortcuts

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