Documentation
¶
Index ¶
- Constants
- Variables
- func ContentMappingPreparer(response Response, item ResponseItem) *strings.Replacer
- func ContentPreparer(response Response, item ResponseItem) *strings.Replacer
- func GenSomeID() string
- func IsNil(v IsNillable) bool
- func NewAdResponseItemID() string
- func NewImpressionID() string
- func NewRequestID() string
- type AccessPoint
- type Account
- type AccountWithBudget
- type Action
- type AppInfo
- type BidRequester
- type BrowserInfo
- type CarrierInfo
- type Data
- type DeviceInfo
- type GeoInfo
- type Impression
- func (i *Impression) AccountID() uint64
- func (i *Impression) CommissionShareFactor() float64
- func (i *Impression) ContextSubType() openrtbnreq.ContextSubTypeID
- func (i *Impression) ContextType() openrtbnreq.ContextTypeID
- func (i *Impression) FormatBitset() *searchtypes.NumberBitset[uint]
- func (i *Impression) FormatByCode(code string) *types.Format
- func (i *Impression) FormatByType(tp types.FormatType) *types.Format
- func (i *Impression) Formats() (f []*types.Format)
- func (i *Impression) Get(key string) any
- func (i *Impression) IDByFormat(format *types.Format) string
- func (i *Impression) InitFormats(formats types.FormatsAccessor)
- func (i *Impression) InitFormatsByCodes(codes []string, formats types.FormatsAccessor)
- func (i *Impression) InitFormatsBySizeAndTypes(w, h, minw, minh int, formatTypes types.FormatTypeBitset, ...)
- func (i *Impression) IsDirect() bool
- func (i *Impression) IsInterstitial() bool
- func (i *Impression) IsNative() bool
- func (i *Impression) IsPush() bool
- func (i *Impression) IsStandart() bool
- func (i *Impression) MinimumPrice(action Action) billing.Money
- func (i *Impression) PlacementType() openrtbnreq.PlacementTypeID
- func (i *Impression) PurchasePrice(action Action) billing.Money
- func (i *Impression) RTBNativeRequest() *openrtbnreq.Request
- func (i *Impression) RTBNativeRequestV3() *openrtbnreq3.Request
- func (i *Impression) RequestObj() any
- func (i *Impression) Set(key string, val any)
- func (i *Impression) Size() (w, h int)
- func (i *Impression) TargetCodename() string
- func (i *Impression) TargetID() uint
- func (i *Impression) Unset(keys ...string)
- type IsNillable
- type MacroMapper
- type NoSupportError
- type OSInfo
- type RequestStrategy
- type Response
- type ResponseError
- func (r *ResponseError) AddItem(it ResponseItemCommon)
- func (r *ResponseError) Ads() []ResponseItemCommon
- func (r *ResponseError) AuctionID() string
- func (r *ResponseError) AuctionType() types.AuctionType
- func (r *ResponseError) Context(ctx ...context.Context) context.Context
- func (r *ResponseError) Count() int
- func (r *ResponseError) Error() error
- func (r *ResponseError) Get(key string) any
- func (r *ResponseError) Item(impid string) ResponseItemCommon
- func (r *ResponseError) IterAds() iter.Seq[ResponseItem]
- func (r *ResponseError) Release()
- func (r *ResponseError) Request() BidRequester
- func (r *ResponseError) Source() Source
- func (r *ResponseError) Validate() (err error)
- type ResponseItem
- type ResponseItemCommon
- type ResponseItemEmpty
- func (*ResponseItemEmpty) AccountID() uint64
- func (*ResponseItemEmpty) ActionURL() string
- func (*ResponseItemEmpty) AdID() string
- func (*ResponseItemEmpty) Asset(name string) *admodels.AdFileAsset
- func (*ResponseItemEmpty) Assets() admodels.AdFileAssets
- func (r *ResponseItemEmpty) AuctionID() string
- func (*ResponseItemEmpty) CampaignID() uint64
- func (*ResponseItemEmpty) ClickTrackerLinks() []string
- func (it *ResponseItemEmpty) CommissionShareFactor() float64
- func (*ResponseItemEmpty) ContentFields() map[string]any
- func (*ResponseItemEmpty) ContentItem(name string) any
- func (*ResponseItemEmpty) ContentItemString(name string) string
- func (it *ResponseItemEmpty) Context(ctx ...context.Context) context.Context
- func (*ResponseItemEmpty) CreativeID() string
- func (*ResponseItemEmpty) ECPM() billing.Money
- func (it *ResponseItemEmpty) ExtImpressionID() string
- func (it *ResponseItemEmpty) ExtTargetID() string
- func (*ResponseItemEmpty) FinalPrice(action Action) billing.Money
- func (it *ResponseItemEmpty) Format() *types.Format
- func (*ResponseItemEmpty) Get(key string) any
- func (*ResponseItemEmpty) Height() int
- func (*ResponseItemEmpty) ID() string
- func (it *ResponseItemEmpty) Impression() *Impression
- func (it *ResponseItemEmpty) ImpressionID() string
- func (*ResponseItemEmpty) ImpressionTrackerLinks() []string
- func (*ResponseItemEmpty) InternalAuctionCPMBid() billing.Money
- func (it *ResponseItemEmpty) IsBackup() bool
- func (it *ResponseItemEmpty) IsDirect() bool
- func (*ResponseItemEmpty) LinkID() uint64
- func (*ResponseItemEmpty) MainAsset() *admodels.AdFileAsset
- func (*ResponseItemEmpty) NetworkName() string
- func (*ResponseItemEmpty) PotentialPercent() float64
- func (*ResponseItemEmpty) PotentialPrice(action Action) billing.Money
- func (*ResponseItemEmpty) PrepareBidPrice(action Action, price billing.Money) billing.Money
- func (*ResponseItemEmpty) Price(action Action) billing.Money
- func (*ResponseItemEmpty) PriceTestMode() bool
- func (*ResponseItemEmpty) PricingModel() types.PricingModel
- func (it *ResponseItemEmpty) PriorityFormatType() types.FormatType
- func (*ResponseItemEmpty) PurchasePrice(action Action) billing.Money
- func (*ResponseItemEmpty) Second() *SecondAd
- func (*ResponseItemEmpty) SetBidPrice(action Action, price billing.Money, withCommission bool) error
- func (it *ResponseItemEmpty) Source() Source
- func (it *ResponseItemEmpty) SourceCorrectionFactor() float64
- func (it *ResponseItemEmpty) TargetCodename() string
- func (it *ResponseItemEmpty) TargetCorrectionFactor() float64
- func (*ResponseItemEmpty) Validate() error
- func (*ResponseItemEmpty) ViewTrackerLinks() []string
- func (*ResponseItemEmpty) Width() int
- type ResponseMultipleItem
- type SecondAd
- type Segment
- type SiteInfo
- type Source
- type SourceAccessor
- type SourceEmpty
- func (*SourceEmpty) AccountID() uint64
- func (*SourceEmpty) Bid(request BidRequester) Response
- func (*SourceEmpty) ID() uint64
- func (*SourceEmpty) Info() *SourceInfo
- func (*SourceEmpty) ObjectKey() uint64
- func (s *SourceEmpty) PriceCorrectionReduceFactor() float64
- func (*SourceEmpty) ProcessResponseItem(Response, ResponseItem)
- func (*SourceEmpty) Protocol() string
- func (*SourceEmpty) RequestStrategy() RequestStrategy
- func (*SourceEmpty) Test(request BidRequester) error
- type SourceFactory
- type SourceInfo
- type SourceInfoList
- type SourceIterator
- type SourceMinimal
- type SourceTesteChecker
- type SourceTester
- type SourceTimeoutSetter
- type Target
- type TargetEmpty
- func (l *TargetEmpty) Account() Account
- func (l *TargetEmpty) AccountID() uint64
- func (l *TargetEmpty) AlternativeAdCode(key string) string
- func (l *TargetEmpty) Codename() string
- func (l *TargetEmpty) CommissionShareFactor() float64
- func (l *TargetEmpty) ID() uint64
- func (l *TargetEmpty) IsAllowedSource(id uint64, types []int) bool
- func (l *TargetEmpty) ObjectKey() string
- func (l *TargetEmpty) PricingModel() types.PricingModel
- func (l *TargetEmpty) PurchasePrice(action Action) billing.Money
- func (l *TargetEmpty) RevenueShareReduceFactor() float64
- func (l *TargetEmpty) SetAccount(acc Account)
- type TypeSex
- type URLGenerator
- type User
- func (u User) AvgAge() byte
- func (u *User) BirthdayTime() time.Time
- func (u User) GenderSimbol() byte
- func (u *User) GetDataItem(name string) (v string, ok bool)
- func (u *User) GetDataItemOrDefault(name, def string) string
- func (u *User) SetDataItem(name, value string)
- func (u *User) SetSexByString(sex string)
- func (u User) Sex() TypeSex
- type VirtualTarget
- func (tw VirtualTarget) Account() Account
- func (tw VirtualTarget) Codename() string
- func (tw VirtualTarget) CommissionShareFactor() float64
- func (tw VirtualTarget) ID() uint64
- func (tw VirtualTarget) PricingModel() types.PricingModel
- func (tw VirtualTarget) PurchasePrice(a Action) billing.Money
- func (tw VirtualTarget) Target() Target
- type WinEvent
Constants ¶
const ( ContentItemLink = "link" // URL to which the ad redirects ContentItemContent = "content" // Main content of the ad ContentItemIFrameURL = "iframe_url" // URL for embedding the ad in an iframe ContentItemNotifyWinURL = "notify_win_url" // URL to notify when the ad wins an auction ContentItemNotifyDisplayURL = "notify_display_url" // URL to notify when the ad is displayed )
Content item names represent various components of an advertisement. These constants are used as keys to retrieve specific content items from an ad response.
const (
LeadAcceptCoef = 100
)
LeadAcceptCoef delimiter magic value
Variables ¶
var ( // For bidding validation ErrInvalidCur = errtype.Error("BID currency is not valid") ErrInvalidCreativeSize = errtype.Error("creative size is invalid") ErrInvalidViewType = errtype.Error("view type is invalid") ErrLowPrice = errtype.Error("BID price is lower than floor price") ErrResponseEmpty = errtype.Error("response is empty") ErrResponseSkipped = errtype.Error("response is skipped") ErrResponseNoBid = errtype.Error("response no bid") ErrResponseInvalidRequest = errtype.Error("response invalid request") ErrResponseItemEmpty = errtype.Error("response item is empty") ErrResponseItemSkipped = errtype.Error("response item is skipped") ErrResponseInvalidType = errtype.Error("invalid response type") ErrResponseInvalidGroup = errtype.Error("system not support group winners") ErrInvalidItemInitialisation = errtype.Error("invalid item initialisation") ErrSourceEmptyRejected = errtype.Error("empty source rejected") )
Set of errors
var ( // ErrNewAuctionBidIsHigherThenMaxBid is returned when a new auction bid exceeds the maximum allowed bid. ErrNewAuctionBidIsHigherThenMaxBid = errors.New("new auction bid is higher than max bid") // ErrUnsupportedAction is returned when the price of the action is not supported // by the response item (e.g. an impression-only item is asked to set a click bid). ErrUnsupportedAction = errors.New("action is not supported by the response item") )
Predefined errors used within the adtype package.
var (
ErrInvalidURL = errors.New("invalid URL value")
)
Errors
Functions ¶
func ContentMappingPreparer ¶
func ContentMappingPreparer(response Response, item ResponseItem) *strings.Replacer
ContentMappingPreparer returns a strings.Replacer that can be used to replace macros in ad content with actual values from the item's content mapping. It looks for a ContentMapping method on the item and uses it to create the replacer. If no ContentMapping is provided, it returns nil.
func ContentPreparer ¶
func ContentPreparer(response Response, item ResponseItem) *strings.Replacer
ContentPreparer returns a strings.Replacer that can be used to replace macros in ad content with actual values from the response and item. It includes standard macros like {impid}, {aucid}, {adid}, as well as any custom mappings provided by the item.
func IsNil ¶
func IsNil(v IsNillable) bool
IsNil reports whether v is an untyped nil interface or a typed nil.
func NewAdResponseItemID ¶
func NewAdResponseItemID() string
NewAdResponseItemID generates new unique ad response item ID
func NewImpressionID ¶
func NewImpressionID() string
NewImpressionID generates new unique impression ID
Types ¶
type AccessPoint ¶
type AccessPoint interface {
// ID of the access point
ID() uint64
// AccountID of the access point
AccountID() uint64
// Pricing model
PricingModel() types.PricingModel
}
AccessPoint is the DSP source
type AccountWithBudget ¶
type AccountWithBudget interface {
Account
// TestBudget of the account retuns true if the account has sufficient budget
// and greater than the specified value
TestBudget(vol billing.Money) bool
}
AccountWithBudget type represents the account model It has additional methods for testing the budget
type Action ¶
type Action int
Action type
type BidRequester ¶
type BidRequester interface {
fmt.Stringer
IsNillable
ID() string // Unique ID of the request
ExternalID() string // External ID of the request (from OpenRTB)
ProjectID() uint64 // Project ID (placeholder)
AuctionID() string // Unique ID of the auction
ExternalAuctionID() string // External ID of the auction (from OpenRTB)
AuctionType() types.AuctionType // Type of auction (first price, second price, etc)
WithFormats(types.FormatsAccessor) BidRequester // Set formats accessor
// HTTP and domain info
HTTPRequest() *fasthttp.RequestCtx // Raw HTTP context
ServiceDomain() string // Host of the request
// Request state and flags
IsDebug() bool // True if debug mode is enabled
IsSecure() bool // True if request is HTTPS
IsAdBlock() bool // True if adblock detected
IsPrivateBrowsing() bool // True if in incognito
IsRobot() bool // True if bot detected
IsProxy() bool // True if proxy detected
IsIPv6() bool // True if IP is IPv6
// Source filtering
SourceFilterCheck(id uint64) bool // Check if source ID is allowed
// Device and environment
DeviceInfo() *DeviceInfo // Full device info
BrowserInfo() *BrowserInfo // Browser info
OSInfo() *OSInfo // OS info
// App, site, geo
TrafficSourceID() uint64 // Traffic source ID
AppID() uint64 // Target app ID
AppInfo() *AppInfo // App info
SiteInfo() *SiteInfo // Site info or default
Domain() []string // Domain list
DomainName() string // Main domain or bundle name
GeoID() uint64 // Geo ID
GeoInfo() *GeoInfo // Geo info
CarrierInfo() *CarrierInfo // Carrier info
// User info
UserInfo() *User // Full user info
LanguageID() uint64 // Browser language
Keywords() []string // User keywords
Tags() []string // Combined tags
Categories() []uint64 // Categories (currently cached)
Sex() uint // Sex of the user
Age() uint // Age of the user
AccessPoint() AccessPoint // Access point information
Formats() types.BidFormater // Formats accessor
// Financial
MinECPM() billing.Money // Max of all bid floors
// Size returns the width and height of the area of visibility for the ad.
Size() (w, h int)
// TargetID of the specific point
TargetID() uint64
TargetIDs() []uint64
ExtTargetIDs() []string
// Impressions
Impressions() []*Impression // List of impressions
ImpressionUpdate(fn func(*Impression) bool) // Modify all impressions
ImpressionByID(id string) *Impression // Exact match
TargetPointers() []types.TargetPointer // TargetPointer interfaces for each impression
// Ext map manipulation
Get(key string) any // Get ext value
Set(key string, val any) // Set ext value
Unset(keys ...string) // Unset keys
Time() time.Time // Timestamp of the request
CurrentGeoTime() time.Time // Current time in the geo of the request
Validate() error // Validate request
Release() // Release resources
Context() context.Context // Request context
SetContext(ctx context.Context)
Done() <-chan struct{} // Channel that closes when context is done
}
BidRequester defines the interface for interacting with a bid request in the ad system.
type BrowserInfo ¶
type CarrierInfo ¶
type Data ¶
type Data struct {
Name string `json:"name,omitempty"`
Segment []Segment `json:"segment,omitempty"`
}
Data item segment
type DeviceInfo ¶
type Impression ¶
type Impression struct {
ID string `json:"id,omitempty"` // Internal impression ID
ExternalID string `json:"extid,omitempty"` // External impression ID (ImpID)
ExternalTargetID string `json:"exttrgid"` // External zone/unit/spot ID (tagid)
Request any `json:"request,omitempty"` // Contains subrequest from RTB or another protocol
Target Target `json:"target,omitempty"`
BidFloorCPM billing.Money `json:"bid_floor,omitempty"`
PurchaseImpPrice billing.Money `json:"purchase_imp_price,omitempty"`
PurchaseViewPrice billing.Money `json:"purchase_view_price,omitempty"`
// Ad position
Pos int `json:"pos,omitempty"` // 5.4 Ad Position
Count int `json:"cnt,omitempty"` // Count of places for multiple banners
Interstitial bool `json:"intr,omitempty"` // Interstitial or full screen display
Push bool `json:"push,omitempty"` // Push notification
// Sizes and position on the screen
X int `json:"x,omitempty"`
Y int `json:"y,omitempty"`
Width int `json:"w,omitempty"`
Height int `json:"h,omitempty"`
WidthMax int `json:"wm,omitempty"`
HeightMax int `json:"hm,omitempty"`
// Additional identifiers
SubID1 string `json:"subid1,omitempty"`
SubID2 string `json:"subid2,omitempty"`
SubID3 string `json:"subid3,omitempty"`
SubID4 string `json:"subid4,omitempty"`
SubID5 string `json:"subid5,omitempty"`
// Format types for impression
FormatTypes types.FormatTypeBitset `json:"-"`
FormatCodes []string `json:"-"`
Ext map[string]any `json:"ext,omitempty"`
// contains filtered or unexported fields
}
Impression target object represents impression place which can be used for the ad placement
func (*Impression) AccountID ¶
func (i *Impression) AccountID() uint64
AccountID returns the account ID
func (*Impression) CommissionShareFactor ¶
func (i *Impression) CommissionShareFactor() float64
CommissionShareFactor which system get from publisher from 0 to 1
func (*Impression) ContextSubType ¶
func (i *Impression) ContextSubType() openrtbnreq.ContextSubTypeID
ContextSubType IDs 7.4 @link https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-Native-Ads-Specification-1-1_2016.pdf
func (*Impression) ContextType ¶
func (i *Impression) ContextType() openrtbnreq.ContextTypeID
ContextType IDs 7.3 @link https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-Native-Ads-Specification-1-1_2016.pdf
func (*Impression) FormatBitset ¶
func (i *Impression) FormatBitset() *searchtypes.NumberBitset[uint]
FormatBitset of IDs
func (*Impression) FormatByCode ¶
func (i *Impression) FormatByCode(code string) *types.Format
FormatCodes of impression
func (*Impression) FormatByType ¶
func (i *Impression) FormatByType(tp types.FormatType) *types.Format
FormatByType of formats
func (*Impression) IDByFormat ¶
func (i *Impression) IDByFormat(format *types.Format) string
IDByFormat return specific ID to link format
func (*Impression) InitFormats ¶
func (i *Impression) InitFormats(formats types.FormatsAccessor)
InitFormats initialize formats by size and types or by codes
func (*Impression) InitFormatsByCodes ¶
func (i *Impression) InitFormatsByCodes(codes []string, formats types.FormatsAccessor)
InitFormatsByCodes initialize formats by codes
func (*Impression) InitFormatsBySizeAndTypes ¶
func (i *Impression) InitFormatsBySizeAndTypes(w, h, minw, minh int, formatTypes types.FormatTypeBitset, formats types.FormatsAccessor)
Init internal information
func (*Impression) IsDirect ¶
func (i *Impression) IsDirect() bool
IsDirect returns true if the impression is direct
func (*Impression) IsInterstitial ¶
func (i *Impression) IsInterstitial() bool
IsInterstitial returns true if the impression is interstitial
func (*Impression) IsNative ¶
func (i *Impression) IsNative() bool
IsNative returns true if the impression is native
func (*Impression) IsPush ¶
func (i *Impression) IsPush() bool
IsPush returns true if the impression is push notification
func (*Impression) IsStandart ¶
func (i *Impression) IsStandart() bool
IsStandart returns true if the impression is standart
func (*Impression) MinimumPrice ¶
func (i *Impression) MinimumPrice(action Action) billing.Money
MinimumPrice return the minimum price for the action
func (*Impression) PlacementType ¶
func (i *Impression) PlacementType() openrtbnreq.PlacementTypeID
PlacementType IDs 7.5 @link https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-Native-Ads-Specification-1-1_2016.pdf
func (*Impression) PurchasePrice ¶
func (i *Impression) PurchasePrice(action Action) billing.Money
PurchasePrice return the price of need to pay for the action to the connected network or application if price is fixed
func (*Impression) RTBNativeRequest ¶
func (i *Impression) RTBNativeRequest() *openrtbnreq.Request
RTBNativeRequest object
func (*Impression) RTBNativeRequestV3 ¶
func (i *Impression) RTBNativeRequestV3() *openrtbnreq3.Request
RTBNativeRequestV3 object
func (*Impression) RequestObj ¶
func (i *Impression) RequestObj() any
RequestObj return the request object related to the impression
func (*Impression) Size ¶
func (i *Impression) Size() (w, h int)
Size of the area of visibility for the ad
func (*Impression) TargetCodename ¶
func (i *Impression) TargetCodename() string
TargetCodename returns the target codename
type IsNillable ¶
type IsNillable interface {
IsNil() bool
}
IsNillable describes a type that can report whether it is a typed nil. Implementations must be nil-safe: a nil receiver must return true without panicking.
type MacroMapper ¶
type MacroMapper struct {
AuctionID string
AuctionType string
ImpID string
ClickID string
CampaignID string
AdID string
Platform string
PriceModel string
Country string
City string
Latitude string
Longitude string
Language string
Domain string
AppID string
ZoneID string
ZoneCode string
UUID string
SessionID string
UserIP string
CarrierID string
DeviceType string
DeviceID string
DeviceName string
OSID string
OSName string
BrowserID string
BrowserName string
Price float64
}
MacroMapper is a struct that contains the macro mapper for the ad content
type RequestStrategy ¶
type RequestStrategy int
RequestStrategy defines politics of request sending
const ( // AsynchronousRequestStrategy is default strategy implies // requesting all auction participants and choising the most // profitable variant of all AsynchronousRequestStrategy RequestStrategy = iota // SingleRequestStrategy tells that if response was // received it should be performed SingleRequestStrategy )
func (RequestStrategy) IsAsynchronous ¶
func (rs RequestStrategy) IsAsynchronous() bool
func (RequestStrategy) IsSingle ¶
func (rs RequestStrategy) IsSingle() bool
type Response ¶
type Response interface {
// AuctionID response
AuctionID() string
// AuctionType of request
AuctionType() types.AuctionType
// Source of response
Source() Source
// Request information
Request() BidRequester
// Ads list
Ads() []ResponseItemCommon
// IterAds returns an iterator over the response items.
IterAds() iter.Seq[ResponseItem]
// Item by impression code
Item(impid string) ResponseItemCommon
// Count of response items
Count() int
// Validate response
Validate() error
// Error of the response
Error() error
// Context value
Context(ctx ...context.Context) context.Context
// Get context item by key
Get(key string) any
// Release response and all linked objects
Release()
}
Response type definition
type ResponseError ¶
type ResponseError struct {
// contains filtered or unexported fields
}
ResponseError from different sources
func NewErrorResponse ¶
func NewErrorResponse(request BidRequester, err error) *ResponseError
NewErrorResponse object
func (*ResponseError) AddItem ¶
func (r *ResponseError) AddItem(it ResponseItemCommon)
AddItem to response
func (*ResponseError) AuctionType ¶
func (r *ResponseError) AuctionType() types.AuctionType
AuctionType of request
func (*ResponseError) Context ¶
func (r *ResponseError) Context(ctx ...context.Context) context.Context
Context value
func (*ResponseError) Item ¶
func (r *ResponseError) Item(impid string) ResponseItemCommon
Item by impression code
func (*ResponseError) IterAds ¶
func (r *ResponseError) IterAds() iter.Seq[ResponseItem]
IterAds returns an iterator over the response items.
func (*ResponseError) Release ¶
func (r *ResponseError) Release()
Release response and all linked objects
type ResponseItem ¶
type ResponseItem interface {
ResponseItemCommon
// NetworkName returns the name of the ad network that provided the response.
NetworkName() string
// AccountID returns the unique identifier of the advertiser's account.
AccountID() uint64
// CampaignID returns the unique identifier of the advertising campaign.
CampaignID() uint64
// LinkID returns the unique identifier of the served AdLink (0 if none).
LinkID() uint64
// AdID returns the unique identifier of the advertisement.
AdID() string
// CreativeID returns the unique identifier of the creative asset used in the advertisement.
CreativeID() string
// Format returns the format information of the advertisement.
Format() *types.Format
// PricingModel returns the pricing model used for the advertisement (e.g., CPC, CPM).
PricingModel() types.PricingModel
// ContentItem retrieves the ad response data for a given content item name.
// It returns the content in its original type.
ContentItem(name string) any
// ContentItemString retrieves the ad response data for a given content item name as a string.
ContentItemString(name string) string
// ContentFields returns a map of all content fields associated with the advertisement.
ContentFields() map[string]any
// MainAsset returns the primary asset of the advertisement (e.g., image, video).
MainAsset() *admodels.AdFileAsset
// Assets returns a list of all assets associated with the advertisement.
Assets() admodels.AdFileAssets
// Source returns the source information of the advertisement response.
Source() Source
// ImpressionTrackerLinks returns traking links for impression action
ImpressionTrackerLinks() []string
// ViewTrackerLinks returns a slice of tracking URLs for view actions.
ViewTrackerLinks() []string
// ClickTrackerLinks returns a slice of tracking URLs for click actions.
ClickTrackerLinks() []string
// IsDirect indicates whether the advertisement is a direct ad type.
IsDirect() bool
// IsBackup indicates whether the advertisement is a backup ad type.
IsBackup() bool
// ActionURL returns the target URL for direct and banner click actions.
ActionURL() string
// Width returns the width of the advertisement in pixels.
Width() int
// Height returns the height of the advertisement in pixels.
Height() int
// ECPM returns the Effective Cost Per Mille (thousand impressions) value of the advertisement.
ECPM() billing.Money
// Price returns the total price for a specific action (e.g., click, lead, view).
Price(action Action) billing.Money
// SetBidPrice sets the current bid price for the given action, used for the
// external auction source. If withCommission is true, the price is treated as
// the net amount that must remain after discrepancy corrections and the
// commission share are deducted downstream (see PublisherPrice) and is grossed
// up via BidUpPrice-style calculation before being stored. If withCommission is
// false, the price is stored as given.
SetBidPrice(action Action, price billing.Money, withCommission bool) error
// PrepareBidPrice prepares the bid price for the given action by clamping it
// to the maximal allowed bid of that action (if defined). Used before storing
// or comparing a candidate bid against the current auction limits.
PrepareBidPrice(action Action, price billing.Money) billing.Money
// PurchasePrice returns the price of a specific action from an external resource (e.g., site, app, RTB).
// This represents the cost of the request for the network.
// Without the network commission.
PurchasePrice(action Action) billing.Money
// PotentialPrice returns the potential price that could be received from the source but was marked as a discrepancy.
PotentialPrice(action Action) billing.Money
// FinalPrice returns the final price for the advertisement item, including all possible commissions and corrections.
// This is the price that will be charged to the advertiser.
FinalPrice(action Action) billing.Money
// Second returns a pointer to the SecondAd, representing secondary campaigns.
Second() *SecondAd
// It represents the portion of user revenue the system receives, ranging from 0 to 1.
CommissionShareFactor() float64
// SourceCorrectionFactor returns the correction factor applied to the source.
SourceCorrectionFactor() float64
// TargetCorrectionFactor returns the correction factor applied to the target.
TargetCorrectionFactor() float64
}
ResponserItem defines the interface for a single advertisement response item. It extends ResponseItemCommon by adding methods specific to individual ads.
type ResponseItemCommon ¶
type ResponseItemCommon interface {
// ID returns the unique identifier of the current response item.
ID() string
// Impression returns the Impression object associated with this response item.
Impression() *Impression
// ImpressionID returns the unique identifier string of the Impression.
ImpressionID() string
// ExtImpressionID returns the external unique identifier of the auction bid impression.
ExtImpressionID() string
// ExtTargetID returns the external target identifier from the external network.
ExtTargetID() string
// TargetCodename returns the target placement codename.
TargetCodename() string
// InternalAuctionCPMBid provides the maximum possible CPM (Cost Per Mille) bid without any commission.
// This value is used by the system to select the best item for the auction.
InternalAuctionCPMBid() billing.Money
// PriorityFormatType returns the format type that has priority in the current ad.
PriorityFormatType() types.FormatType
// Validate checks the validity of the response item.
// It returns an error if the item is invalid.
Validate() error
// Context returns the contextual information associated with the response item.
// It can accept additional contexts to merge with the existing one.
Context(ctx ...context.Context) context.Context
// Get retrieves a value from the response item's extension map by the provided key.
// It returns nil if the key does not exist.
Get(key string) any
}
ResponseItemCommon defines the common interface for response items in an ad auction. It includes methods to access identification, pricing, validation, and contextual data.
type ResponseItemEmpty ¶
type ResponseItemEmpty struct {
Imp *Impression
Req BidRequester
Src Source
// contains filtered or unexported fields
}
ResponseItemEmpty value
func (*ResponseItemEmpty) ActionURL ¶
func (*ResponseItemEmpty) ActionURL() string
ActionURL returns target resource link for direct and banner click as well
func (*ResponseItemEmpty) AdID ¶
func (*ResponseItemEmpty) AdID() string
AdID returns the unique identifier of the advertisement.
func (*ResponseItemEmpty) Asset ¶
func (*ResponseItemEmpty) Asset(name string) *admodels.AdFileAsset
Asset by name
func (*ResponseItemEmpty) Assets ¶
func (*ResponseItemEmpty) Assets() admodels.AdFileAssets
Assets list
func (*ResponseItemEmpty) AuctionID ¶
func (r *ResponseItemEmpty) AuctionID() string
AuctionID returns ID of the current auction
func (*ResponseItemEmpty) CampaignID ¶
func (*ResponseItemEmpty) CampaignID() uint64
CampaignID number
func (*ResponseItemEmpty) ClickTrackerLinks ¶
func (*ResponseItemEmpty) ClickTrackerLinks() []string
ClickTrackerLinks returns traking links for click action
func (*ResponseItemEmpty) CommissionShareFactor ¶
func (it *ResponseItemEmpty) CommissionShareFactor() float64
CommissionShareFactor returns the multipler for commission calculation which system get from user revenue from 0 to 1
func (*ResponseItemEmpty) ContentFields ¶
func (*ResponseItemEmpty) ContentFields() map[string]any
ContentFields from advertisement object
func (*ResponseItemEmpty) ContentItem ¶
func (*ResponseItemEmpty) ContentItem(name string) any
ContentItem returns the ad response data
func (*ResponseItemEmpty) ContentItemString ¶
func (*ResponseItemEmpty) ContentItemString(name string) string
ContentItemString from the ad
func (*ResponseItemEmpty) Context ¶
func (it *ResponseItemEmpty) Context(ctx ...context.Context) context.Context
Context value
func (*ResponseItemEmpty) CreativeID ¶
func (*ResponseItemEmpty) CreativeID() string
CreativeID returns the unique identifier of the creative.
func (*ResponseItemEmpty) ExtImpressionID ¶
func (it *ResponseItemEmpty) ExtImpressionID() string
ExtImpressionID it's unique code of the auction bid impression
func (*ResponseItemEmpty) ExtTargetID ¶
func (it *ResponseItemEmpty) ExtTargetID() string
ExtTargetID of the external network
func (*ResponseItemEmpty) FinalPrice ¶
func (*ResponseItemEmpty) FinalPrice(action Action) billing.Money
FinalPrice returns final price for the item which is including all possible commissions with all corrections
func (*ResponseItemEmpty) Format ¶
func (it *ResponseItemEmpty) Format() *types.Format
Format object
func (*ResponseItemEmpty) ID ¶
func (*ResponseItemEmpty) ID() string
ID of current response item (unique code of current response)
func (*ResponseItemEmpty) Impression ¶
func (it *ResponseItemEmpty) Impression() *Impression
Impression place object
func (*ResponseItemEmpty) ImpressionID ¶
func (it *ResponseItemEmpty) ImpressionID() string
ImpressionID unique code string
func (*ResponseItemEmpty) ImpressionTrackerLinks ¶
func (*ResponseItemEmpty) ImpressionTrackerLinks() []string
ImpressionTrackerLinks returns traking links for impression action
func (*ResponseItemEmpty) InternalAuctionCPMBid ¶
func (*ResponseItemEmpty) InternalAuctionCPMBid() billing.Money
InternalAuctionCPMBid value provides maximal possible price without any comission According to this value the system can choice the best item for the auction
func (*ResponseItemEmpty) IsBackup ¶
func (it *ResponseItemEmpty) IsBackup() bool
IsBackup indicates whether the advertisement is a backup ad type.
func (*ResponseItemEmpty) LinkID ¶
func (*ResponseItemEmpty) LinkID() uint64
LinkID returns the unique identifier of the served AdLink.
func (*ResponseItemEmpty) MainAsset ¶
func (*ResponseItemEmpty) MainAsset() *admodels.AdFileAsset
MainAsset from response
func (*ResponseItemEmpty) NetworkName ¶
func (*ResponseItemEmpty) NetworkName() string
NetworkName by source
func (*ResponseItemEmpty) PotentialPercent ¶
func (*ResponseItemEmpty) PotentialPercent() float64
PotentialPercent money
func (*ResponseItemEmpty) PotentialPrice ¶
func (*ResponseItemEmpty) PotentialPrice(action Action) billing.Money
PotentialPrice wich can be received from source but was marked as descrepancy
func (*ResponseItemEmpty) PrepareBidPrice ¶
PrepareBidPrice prepares the bid price for the given action (no-op for the empty item).
func (*ResponseItemEmpty) Price ¶
func (*ResponseItemEmpty) Price(action Action) billing.Money
Price per specific action type (view, click, lead, etc)
func (*ResponseItemEmpty) PriceTestMode ¶
func (*ResponseItemEmpty) PriceTestMode() bool
PriceTestMode returns true if the price is in test mode
func (*ResponseItemEmpty) PricingModel ¶
func (*ResponseItemEmpty) PricingModel() types.PricingModel
PricingModel of advertisement
func (*ResponseItemEmpty) PriorityFormatType ¶
func (it *ResponseItemEmpty) PriorityFormatType() types.FormatType
PriorityFormatType from current Ad
func (*ResponseItemEmpty) PurchasePrice ¶
func (*ResponseItemEmpty) PurchasePrice(action Action) billing.Money
PurchasePrice gives the price of view from external resource. The cost of this request.
func (*ResponseItemEmpty) Second ¶
func (*ResponseItemEmpty) Second() *SecondAd
Second competitor campaign
func (*ResponseItemEmpty) SetBidPrice ¶
func (*ResponseItemEmpty) SetBidPrice(action Action, price billing.Money, withCommission bool) error
SetBidPrice sets the bid price for the given action (no-op for the empty item).
func (*ResponseItemEmpty) SourceCorrectionFactor ¶
func (it *ResponseItemEmpty) SourceCorrectionFactor() float64
SourceCorrectionFactor value for the source
func (*ResponseItemEmpty) TargetCodename ¶
func (it *ResponseItemEmpty) TargetCodename() string
TargetCodename of the target placement codename
func (*ResponseItemEmpty) TargetCorrectionFactor ¶
func (it *ResponseItemEmpty) TargetCorrectionFactor() float64
TargetCorrectionFactor value for the target
func (*ResponseItemEmpty) ViewTrackerLinks ¶
func (*ResponseItemEmpty) ViewTrackerLinks() []string
ViewTrackerLinks returns traking links for view action
type ResponseMultipleItem ¶
type ResponseMultipleItem interface {
ResponseItemCommon
// Ads returns a slice of ResponseItem interfaces representing individual ads within the response.
Ads() []ResponseItem
// Count returns the total number of response items (ads) in the response.
Count() int
}
ResponserMultipleItem defines the interface for handling multiple advertisement response items. It is typically used for complex banners that contain multiple ads.
type SecondAd ¶
type SecondAd struct {
ID string `json:"id,omitempty"`
Network string `json:"network,omitempty"`
SourceID uint64 `json:"source_id,omitempty"`
CampaignID uint64 `json:"campaign_id,omitempty"`
Price billing.Money `json:"price,omitempty"`
}
SecondAd description
type Source ¶
type Source interface {
SourceMinimal
// AccountID of the source driver
AccountID() uint64
SourceTesteChecker
// ID of the source driver
ID() uint64
// ObjectKey of the source driver
ObjectKey() uint64
// Protocol of the source driver
Protocol() string
// Info returns information about the source platform and the source protocol
Info() *SourceInfo
// PriceCorrectionReduceFactor which is a potential
// Returns percent from 0 to 1 for reducing of the value
// If there is 10% of price correction, it means that 10% of the final price must be ignored
PriceCorrectionReduceFactor() float64
// RequestStrategy description
RequestStrategy() RequestStrategy
}
Source of advertisement and where will be selled the traffic
func ToSource ¶
func ToSource(val SourceMinimal) Source
ToSource interface from different types of interfaces with the implementation of unsupported methods
type SourceAccessor ¶
type SourceAccessor interface {
// Iterator returns the configured queue accessor
Iterator(request BidRequester) SourceIterator
// SourceByID returns source instance
SourceByID(ctx context.Context, id uint64) (Source, error)
// SetTimeout for sourcer
SetTimeout(ctx context.Context, timeout time.Duration)
}
SourceAccessor preoritise the source access
type SourceEmpty ¶
type SourceEmpty struct {
PriceCorrectionReduce float64 // from 0 to 1
}
SourceEmpty abstraction
func (*SourceEmpty) AccountID ¶
func (*SourceEmpty) AccountID() uint64
AccountID of the source driver
func (*SourceEmpty) Bid ¶
func (*SourceEmpty) Bid(request BidRequester) Response
Bid request for standart system filter
func (*SourceEmpty) Info ¶
func (*SourceEmpty) Info() *SourceInfo
Info returns information about the source platform and the source protocol
func (*SourceEmpty) ObjectKey ¶
func (*SourceEmpty) ObjectKey() uint64
ObjectKey of the source driver
func (*SourceEmpty) PriceCorrectionReduceFactor ¶
func (s *SourceEmpty) PriceCorrectionReduceFactor() float64
PriceCorrectionReduceFactor which is a potential Returns percent from 0 to 1 for reducing of the value If there is 10% of price correction, it means that 10% of the final price must be ignored
func (*SourceEmpty) ProcessResponseItem ¶
func (*SourceEmpty) ProcessResponseItem(Response, ResponseItem)
ProcessResponseItem result or error
func (*SourceEmpty) RequestStrategy ¶
func (*SourceEmpty) RequestStrategy() RequestStrategy
RequestStrategy description
func (*SourceEmpty) Test ¶
func (*SourceEmpty) Test(request BidRequester) error
Test request before processing
type SourceFactory ¶
type SourceFactory interface {
// Info returns information about the source platform
// and the source protocol
Info() info.Platform
// Protocols returns list of supported protocols of the source
Protocols() []string
// New creates a new source instance for the given RTBSource
New(ctx context.Context, source *admodels.RTBSource, opts ...any) (SourceTester, error)
}
SourceFactory is a source factory interface
type SourceInfo ¶
type SourceInfo struct {
ID string `json:"id"`
Protocol string `json:"protocol"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Domain string `json:"domain,omitempty"`
IconURL string `json:"icon_url,omitempty"`
LogoURL string `json:"logo_url,omitempty"`
URL string `json:"url,omitempty"`
DSPDomains []string `json:"dsp_domains,omitempty"` // ["*.dsp.domain.com"]
Metadata map[string]any `json:"metadata,omitempty"`
}
SourceInfo contains information about the source platform and the source protocol It contains the name, description, domain, icon URL, logo URL, URL, DSP domains, and metadata DSP domains is a list of domains that are used to serve DSP traffic Metadata is a map of metadata about the source platform It is used to store additional information about the source platform
func (*SourceInfo) IsDSPDomain ¶
func (s *SourceInfo) IsDSPDomain(domain string) bool
IsDSPDomain checks if the domain is a DSP domain It checks if the domain is a suffix of the DSP domain or if the domain matches the DSP domain pattern
type SourceInfoList ¶
type SourceInfoList []*SourceInfo
SourceInfoList is a list of SourceInfo
func (SourceInfoList) SourceInfoByDSPDomain ¶
func (l SourceInfoList) SourceInfoByDSPDomain(domain string) *SourceInfo
SourceInfoByID returns the SourceInfo by ID
type SourceIterator ¶
SourceIterator is a source iterator
type SourceMinimal ¶
type SourceMinimal interface {
// Bid request for standart system filter
Bid(request BidRequester) Response
// ProcessResponseItem result or error
ProcessResponseItem(Response, ResponseItem)
}
SourceMinimal contains only minimal set of methods
type SourceTesteChecker ¶
type SourceTesteChecker interface {
// Test current request for compatibility.
// Returns a typed cause on rejection, or nil when the request may proceed.
Test(request BidRequester) error
}
SourceTesteChecker checker
type SourceTester ¶
type SourceTester interface {
Source
SourceTesteChecker
}
SourceTester interface
type SourceTimeoutSetter ¶
SourceTimeoutSetter interface
type Target ¶
type Target interface {
// ID of object (Zone OR SmartLink only)
ID() uint64
// Codename of the target (equal to tagid)
Codename() string
// ObjectKey of the target
ObjectKey() string
// PricingModel of the target
// Undefined as any priceing model type
PricingModel() types.PricingModel
// AlternativeAdCode returns URL or any code (HTML, XML, etc)
// for alternative ad code for the target.
// Key represents adformat code (banner, video, direct, etc)
AlternativeAdCode(key string) string
// PurchasePrice gives the price of view from external resource
PurchasePrice(action Action) billing.Money
CommissionShareFactor() float64
// Returns percent from 0 to 1 for reducing of the value
// If there is 10% of price correction, it means that 10% of the final price must be ignored
RevenueShareReduceFactor() float64
// Account object
Account() Account
}
Target type object represents the placement of the ad in the ad system. It can be a zone, smartlink, or any other
type TargetEmpty ¶
type TargetEmpty struct {
Acc Account
}
TargetEmpty model represents empty target which is used for the case when target is not specified
func (*TargetEmpty) AccountID ¶
func (l *TargetEmpty) AccountID() uint64
AccountID of current target
func (*TargetEmpty) AlternativeAdCode ¶
func (l *TargetEmpty) AlternativeAdCode(key string) string
AlternativeAdCode returns URL or any code (HTML, XML, etc)
func (*TargetEmpty) Codename ¶
func (l *TargetEmpty) Codename() string
Codename of the target (equal to tagid)
func (*TargetEmpty) CommissionShareFactor ¶
func (l *TargetEmpty) CommissionShareFactor() float64
CommissionShareFactor which system get from publisher
func (*TargetEmpty) IsAllowedSource ¶
func (l *TargetEmpty) IsAllowedSource(id uint64, types []int) bool
IsAllowedSource for targeting
func (*TargetEmpty) PricingModel ¶
func (l *TargetEmpty) PricingModel() types.PricingModel
PricingModel of the target
func (*TargetEmpty) PurchasePrice ¶
func (l *TargetEmpty) PurchasePrice(action Action) billing.Money
PurchasePrice gives the price of view from external resource
func (*TargetEmpty) RevenueShareReduceFactor ¶
func (l *TargetEmpty) RevenueShareReduceFactor() float64
RevenueShareReduceFactor correction factor to reduce target proce of the access point to avoid descrepancy Returns percent from 0 to 1 for reducing of the value If there is 10% of price correction, it means that 10% of the final price must be ignored
func (*TargetEmpty) SetAccount ¶
func (l *TargetEmpty) SetAccount(acc Account)
SetAccount for target
type URLGenerator ¶
type URLGenerator interface {
// CDNURL returns full URL to path
CDNURL(path string) string
// LibURL returns full URL to lib file path
LibURL(path string) string
// PixelURL generator from response of item
// @param js generates the JavaScript pixel type
PixelURL(event events.Type, status uint8, item ResponseItem, response Response, js bool) (string, error)
// PixelDirectURL generator from response of item
PixelDirectURL(event events.Type, status uint8, item ResponseItem, response Response, direct string) (string, error)
// PixelLead URL
PixelLead(item ResponseItem, response Response, js bool) (string, error)
// MustClickURL generator from response of item
MustClickURL(item ResponseItem, response Response) string
// ClickURL generator from response of item
ClickURL(item ResponseItem, response Response) (string, error)
// ClickRouterURL returns router pattern
ClickRouterURL() string
// DirectURL generator from response of item
DirectURL(event events.Type, item ResponseItem, response Response) (string, error)
// DirectRouterURL returns router pattern
DirectRouterURL() string
// WinURL generator from response of item
WinURL(event events.Type, status uint8, item ResponseItem, response Response) (string, error)
// BillingNoticeURL generator from response of item
BillingNoticeURL(event events.Type, status uint8, item ResponseItem, response Response) (string, error)
// WinRouterURL returns router pattern
WinRouterURL() string
}
URLGenerator of advertisement
type User ¶
type User struct {
ID string `json:"id,omitempty"` // Unique User ID
Email string `json:"email,omitempty"` // In some cases it's able the use email, and we are gonna use it
Username string `json:"username,omitempty"` // User profile name from the external service or potentional username
SessionID string `json:"sessid,omitempty"` // Unique session ID
FingerPrintID string `json:"fpid,omitempty"` //
ETag string `json:"etag,omitempty"` //
Birthday string `json:"birthday,omitempty"` // * Prefer do not use such personal information in alghoritm
AgeStart int `json:"age_start,omitempty"` // Year of birth from
AgeEnd int `json:"age_end,omitempty"` // Year of birth from
Gender string `json:"gender,omitempty"` // Gender ("M": male, "F" female, "O" Other)
Keywords string `json:"keywords,omitempty"` // Comma separated list of keywords, interests, or intent
Geo *udetect.Geo `json:"geo,omitempty"`
Data []Data `json:"data,omitempty"`
// contains filtered or unexported fields
}
User information
func (*User) BirthdayTime ¶
BirthdayTime parsed by Birthday string
func (*User) GetDataItem ¶
GetDataItem simple value by key
func (*User) GetDataItemOrDefault ¶
GetDataItemOrDefault item
func (*User) SetDataItem ¶
SetDataItem with simple *key*, *value*
type VirtualTarget ¶
type VirtualTarget struct {
// contains filtered or unexported fields
}
VirtualTarget it's a wrapper which don't have ID
func NewVirtualTarget ¶
func NewVirtualTarget(trg Target) VirtualTarget
NewVirtualTarget wrapper of exists target
func (VirtualTarget) Codename ¶
func (tw VirtualTarget) Codename() string
Codename of the target (equal to tagid)
func (VirtualTarget) CommissionShareFactor ¶
func (tw VirtualTarget) CommissionShareFactor() float64
CommissionShareFactor of current target
func (VirtualTarget) PricingModel ¶
func (tw VirtualTarget) PricingModel() types.PricingModel
PricingModel of the target Undefined as any priceing model type
func (VirtualTarget) PurchasePrice ¶
func (tw VirtualTarget) PurchasePrice(a Action) billing.Money
PurchasePrice gives the price of view from external resource
Source Files
¶
- access_point.go
- account.go
- action.go
- bidrequest_imp.go
- bidrequest_user.go
- bidrequester.go
- errors.go
- nillable.go
- prepare_content.go
- request_strategy.go
- requiestid.go
- response.go
- response_error.go
- response_item.go
- response_item_empty.go
- second_ad.go
- source.go
- source_accessor.go
- source_empty.go
- source_factory.go
- source_wrapper.go
- target.go
- target_empty.go
- target_wrapper.go
- url_generator.go
- win_event.go