common

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

Documentation

Overview

Package common provides BaseBidItem — the shared struct and method set that is common to every per-format RTB bid response item (banner, direct, native, vast). Concrete response types embed BaseBidItem by value and implement only the format-specific methods (ContentItem, trackers, asset extraction, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MainAssetOf

func MainAssetOf(format *types.Format, assets admodels.AdFileAssets, assetType types.AdFileAssetType) *admodels.AdFileAsset

MainAssetOf returns the primary file asset matched against the format configuration. Call this from concrete types that maintain their own assets slice.

Types

type BaseBidItem

type BaseBidItem struct {
	ItemID string `json:"id"`

	// Request and impression data
	Src adtype.Source       `json:"source,omitempty"`
	Req adtype.BidRequester `json:"request,omitempty"`
	Imp *adtype.Impression  `json:"impression,omitempty"`

	// Format of response advertisement item
	FormatType types.FormatType `json:"format_type,omitempty"`
	RespFormat *types.Format    `json:"format,omitempty"`

	// External response data from RTB source
	Bid *openrtb.Bid `json:"bid,omitempty"`

	PriceScope prices.PriceScope `json:"price_scope,omitempty"`

	// Competitive second AD
	SecondAd adtype.SecondAd `json:"second_ad,omitempty"`
	// contains filtered or unexported fields
}

BaseBidItem contains all fields and method implementations that are shared by every format-specific RTB bid response item. Embed this struct by value:

type ResponseBidItem struct {
    common.BaseBidItem
    // format-specific fields …
}

func (*BaseBidItem) AccountID

func (it *BaseBidItem) AccountID() uint64

AccountID returns the account ID from the ad source.

func (*BaseBidItem) AdID

func (it *BaseBidItem) AdID() string

AdID returns the system advertisement ID (always empty for RTB).

func (*BaseBidItem) Assets

func (it *BaseBidItem) Assets() admodels.AdFileAssets

Assets returns nil — banner and direct bid items carry no file assets. Concrete types that do have assets (native, vast) override this method.

func (*BaseBidItem) CampaignID

func (it *BaseBidItem) CampaignID() uint64

CampaignID returns the campaign ID (always 0 for RTB sources).

func (it *BaseBidItem) ClickTrackerLinks() []string

ClickTrackerLinks returns third-party tracker URLs fired on click. Returns nil by default; overridden by banner, native, and vast.

func (*BaseBidItem) CommissionShareFactor

func (it *BaseBidItem) CommissionShareFactor() float64

CommissionShareFactor returns the commission fraction (0..1) taken from the publisher.

func (*BaseBidItem) ContentMapping

func (it *BaseBidItem) ContentMapping() map[string]string

ContentMapping returns a map that can be used to prepare ad markup content

func (*BaseBidItem) Context

func (it *BaseBidItem) Context(ctx ...context.Context) context.Context

Context gets or sets the context associated with this bid item.

func (*BaseBidItem) CreativeID

func (it *BaseBidItem) CreativeID() string

CreativeID returns the creative ID from the RTB bid.

func (*BaseBidItem) ECPM

func (it *BaseBidItem) ECPM() billing.Money

ECPM returns the effective cost per mille for this bid.

func (*BaseBidItem) ExtImpressionID

func (it *BaseBidItem) ExtImpressionID() string

ExtImpressionID returns the external (RTB) impression identifier.

func (*BaseBidItem) ExtTargetID

func (it *BaseBidItem) ExtTargetID() string

ExtTargetID returns the external target identifier.

func (*BaseBidItem) FinalPrice

func (it *BaseBidItem) FinalPrice(action adtype.Action) billing.Money

FinalPrice returns the price after all corrections and commissions for the given action.

func (*BaseBidItem) FixedPurchasePrice

func (it *BaseBidItem) FixedPurchasePrice(action adtype.Action) billing.Money

FixedPurchasePrice returns the fixed purchase price for the given action from the impression.

func (*BaseBidItem) Format

func (it *BaseBidItem) Format() *types.Format

Format returns the matched format object for this bid item.

func (*BaseBidItem) Get

func (it *BaseBidItem) Get(key string) (res any)

Get retrieves a value from the item context by key.

func (*BaseBidItem) Height

func (it *BaseBidItem) Height() int

Height returns the creative height in pixels.

func (*BaseBidItem) ID

func (it *BaseBidItem) ID() string

ID returns the unique identifier of the response item.

func (*BaseBidItem) Impression

func (it *BaseBidItem) Impression() *adtype.Impression

Impression returns the impression object associated with this bid item.

func (*BaseBidItem) ImpressionID

func (it *BaseBidItem) ImpressionID() string

ImpressionID returns the unique impression identifier.

func (it *BaseBidItem) ImpressionTrackerLinks() []string

ImpressionTrackerLinks returns tracking links fired on impression. Returns nil by default; overridden by banner, native, and vast.

func (*BaseBidItem) InternalAuctionCPMBid

func (it *BaseBidItem) InternalAuctionCPMBid() billing.Money

InternalAuctionCPMBid returns the maximal possible price without any commission.

func (*BaseBidItem) IsBackup

func (it *BaseBidItem) IsBackup() bool

IsBackup always returns false for RTB bid items.

func (*BaseBidItem) IsDirect

func (it *BaseBidItem) IsDirect() bool

IsDirect reports whether the impression is a direct ad format. Overridden by direct (always true) and vast (always false).

func (*BaseBidItem) LinkID

func (it *BaseBidItem) LinkID() uint64

LinkID returns the AdLink ID (always 0 for RTB sources).

func (*BaseBidItem) MainAsset

MainAsset returns nil for types that carry no file assets. Concrete types that do have assets (native, vast) override this method.

func (*BaseBidItem) Markup

func (it *BaseBidItem) Markup() (string, error)

Markup returns the rendered ad markup string. Returns empty string by default; format-specific types may override when they pre-render markup.

func (*BaseBidItem) PotentialPrice

func (it *BaseBidItem) PotentialPrice(action adtype.Action) billing.Money

PotentialPrice returns the maximal price which the advertiser could have paid for the action.

func (*BaseBidItem) PrepareBidPrice

func (it *BaseBidItem) PrepareBidPrice(action adtype.Action, p billing.Money) billing.Money

PrepareBidPrice prepares the bid price for the given action by clamping it to the maximal allowed bid of that action (if defined).

func (*BaseBidItem) Price

func (it *BaseBidItem) Price(action adtype.Action) billing.Money

Price returns the total price for the given action (impression, click, lead, view).

func (*BaseBidItem) PriceTestMode

func (it *BaseBidItem) PriceTestMode() bool

PriceTestMode always returns false for RTB bid items.

func (*BaseBidItem) PricingModel

func (it *BaseBidItem) PricingModel() types.PricingModel

PricingModel returns CPM as the pricing model for all RTB bid items.

func (*BaseBidItem) PriorityFormatType

func (it *BaseBidItem) PriorityFormatType() types.FormatType

PriorityFormatType returns the primary format type. Concrete types may override this when the format is always fixed (e.g. direct always returns FormatDirectType).

func (*BaseBidItem) PurchasePrice

func (it *BaseBidItem) PurchasePrice(action adtype.Action) billing.Money

PurchasePrice returns the actual cost of the given action for the system.

func (*BaseBidItem) RTBCategories

func (it *BaseBidItem) RTBCategories() []string

RTBCategories returns the IAB content categories declared in the bid.

func (*BaseBidItem) Second

func (it *BaseBidItem) Second() *adtype.SecondAd

Second returns the competitive second ad slot.

func (*BaseBidItem) SetBidPrice

func (it *BaseBidItem) SetBidPrice(action adtype.Action, bid billing.Money, withCommission bool) error

SetBidPrice sets the current bid price for the given action. If withCommission is true, the price is grossed up by the discrepancy corrections and the commission share before being stored.

func (*BaseBidItem) Source

func (it *BaseBidItem) Source() adtype.Source

Source returns the ad source associated with this bid.

func (*BaseBidItem) SourceCorrectionFactor

func (it *BaseBidItem) SourceCorrectionFactor() float64

SourceCorrectionFactor returns the price correction factor for this RTB source.

func (*BaseBidItem) TargetCodename

func (it *BaseBidItem) TargetCodename() string

TargetCodename returns the codename of the target placement.

func (*BaseBidItem) TargetCorrectionFactor

func (it *BaseBidItem) TargetCorrectionFactor() float64

TargetCorrectionFactor returns the revenue-share reduction factor for the target.

func (*BaseBidItem) Validate

func (it *BaseBidItem) Validate() error

Validate checks that all required fields are populated.

func (it *BaseBidItem) ViewTrackerLinks() []string

ViewTrackerLinks returns tracking links fired on a viewable impression. Returns nil by default; overridden by banner and vast.

func (*BaseBidItem) Width

func (it *BaseBidItem) Width() int

Width returns the creative width in pixels.

Jump to

Keyboard shortcuts

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