adtype

package
v0.0.0-...-3e353e7 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2025 License: Apache-2.0 Imports: 25 Imported by: 11

Documentation

Index

Constants

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

View Source
const (
	LeadAcceptCoef = 100
)

LeadAcceptCoef delimiter magic value

Variables

View Source
var (
	// For bidding validation
	ErrInvalidCur                = errors.New("BID currency is not valid")
	ErrInvalidCreativeSize       = errors.New("creative size is invalid")
	ErrInvalidViewType           = errors.New("view type is invalid")
	ErrLowPrice                  = errors.New("BID price is lower than floor price")
	ErrResponseEmpty             = errors.New("response is empty")
	ErrResponseSkipped           = errors.New("response is skipped")
	ErrResponseNoBid             = errors.New("response no bid")
	ErrResponseItemEmpty         = errors.New("response item is empty")
	ErrResponseItemSkipped       = errors.New("response item is skipped")
	ErrResponseInvalidType       = errors.New("invalid response type")
	ErrResponseInvalidGroup      = errors.New("system not support group winners")
	ErrInvalidItemInitialisation = errors.New("invalid item initialisation")
)

Set of errors

View Source
var (
	ErrInvalidURL = errors.New("invalid URL value")
)

Errors

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

Predefined errors used within the adtype package.

Functions

func NewAdResponseItemID

func NewAdResponseItemID() string

NewAdResponseItemID generates new unique ad response item ID

func NewImpressionID

func NewImpressionID() string

NewImpressionID generates new unique impression ID

func NewRequestID

func NewRequestID() string

NewRequestID generates new unique request ID

func PrepareURL

func PrepareURL(url string, response Response, it ResponseItem) string

PrepareURL by event

Types

type AccessPoint

type AccessPoint interface {
	// ID of the access point
	ID() uint64
}

AccessPoint is the DSP source

type Account

type Account interface {
	ID() uint64

	// CommissionShareFactor which system get from publisher 0..1
	CommissionShareFactor() float64
}

Account type represents the account model

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

const (
	ActionImpression Action = 1
	ActionImp               = ActionImpression // Alias
	ActionView       Action = 2
	ActionClick      Action = 3
	ActionLead       Action = 4
)

Campaign actions

func (Action) Int

func (a Action) Int() int

Int value of action

func (Action) IsClick

func (a Action) IsClick() bool

IsClick action type

func (Action) IsImpression

func (a Action) IsImpression() bool

IsImpression action type

func (Action) IsLead

func (a Action) IsLead() bool

IsLead action type

func (Action) IsView

func (a Action) IsView() bool

IsView action type

func (Action) String

func (a Action) String() string

type AppInfo

type AppInfo = udetect.App

type BidRequester

type BidRequester interface {
	fmt.Stringer

	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

	// 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 BrowserInfo = udetect.Browser

type CarrierInfo

type CarrierInfo = udetect.Carrier

type Data

type Data struct {
	Name    string    `json:"name,omitempty"`
	Segment []Segment `json:"segment,omitempty"`
}

Data item segment

type DeviceInfo

type DeviceInfo = udetect.Device

type GeoInfo

type GeoInfo = udetect.Geo

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

	// 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) FormatBitset

func (i *Impression) FormatBitset() *searchtypes.NumberBitset[uint]

FormatBitset of IDs

func (*Impression) FormatByType

func (i *Impression) FormatByType(tp types.FormatType) *types.Format

FormatByType of formats

func (*Impression) Formats

func (i *Impression) Formats() (f []*types.Format)

Formats models

func (*Impression) Get

func (i *Impression) Get(key string) any

Get context item by key

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) IsNative

func (i *Impression) IsNative() bool

IsNative returns true if the impression is native

func (*Impression) IsStandart

func (i *Impression) IsStandart() bool

IsStandart returns true if the impression is standart

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) Set

func (i *Impression) Set(key string, val any)

Set context item with key

func (*Impression) TargetID

func (i *Impression) TargetID() uint

TargetID returns the target ID

func (*Impression) Unset

func (i *Impression) Unset(keys ...string)

Unset context item with keys

type NoSupportError

type NoSupportError struct {
	NSField string
}

NoSupportError object

func (NoSupportError) Error

func (e NoSupportError) Error() string

Error text

type OSInfo

type OSInfo = udetect.OS

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) Ads

func (r *ResponseError) Ads() []ResponseItemCommon

Ads list

func (*ResponseError) AuctionID

func (r *ResponseError) AuctionID() string

AuctionID 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) Count

func (r *ResponseError) Count() int

Count of response items

func (*ResponseError) Error

func (r *ResponseError) Error() error

Error of the response

func (*ResponseError) Get

func (r *ResponseError) Get(key string) any

Get context item by key

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

func (*ResponseError) Request

func (r *ResponseError) Request() BidRequester

Request information

func (*ResponseError) Source

func (r *ResponseError) Source() Source

Source of response

func (*ResponseError) Validate

func (r *ResponseError) Validate() (err error)

Validate response

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

	// 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

	// PriceTestMode indicates whether the price is in test mode.
	PriceTestMode() bool

	// Price returns the total price for a specific action (e.g., click, lead, view).
	Price(action Action) billing.Money

	// BidImpressionPrice returns the bid price for the external auction source.
	// The bid price is adjusted according to the source correction factor and the commission share factor.
	BidImpressionPrice() billing.Money

	// SetBidImpressionPrice sets the bid price value for external sources in an auction.
	// The system will pay this bid price.
	SetBidImpressionPrice(price billing.Money) error

	// PrepareBidImpressionPrice prepares the price for the action
	// The price is adjusted according to the source correction factor and the commission share factor
	PrepareBidImpressionPrice(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

	// CommissionShareFactor returns the multiplier used for commission calculations.
	// 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

	// 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) AccountID

func (*ResponseItemEmpty) AccountID() uint64

AccountID number

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

Asset by name

func (*ResponseItemEmpty) Assets

Assets list

func (*ResponseItemEmpty) AuctionID

func (r *ResponseItemEmpty) AuctionID() string

AuctionID returns ID of the current auction

func (*ResponseItemEmpty) BidImpressionPrice

func (*ResponseItemEmpty) BidImpressionPrice() billing.Money

BidImpressionPrice returns bid price for the external auction source. The current bid price will be adjusted according to the source correction factor and the commission share factor

func (*ResponseItemEmpty) CampaignID

func (*ResponseItemEmpty) CampaignID() uint64

CampaignID number

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) ECPM

ECPM item value

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) Get

func (*ResponseItemEmpty) Get(key string) any

Get ext field

func (*ResponseItemEmpty) Height

func (*ResponseItemEmpty) Height() int

Height of item

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() []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) IsDirect

func (it *ResponseItemEmpty) IsDirect() bool

IsDirect AD type

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) PrepareBidImpressionPrice

func (*ResponseItemEmpty) PrepareBidImpressionPrice(price billing.Money) billing.Money

PrepareBidImpressionPrice prepares the price for the action The price is adjusted according to the source correction factor and the commission share factor

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) SetBidImpressionPrice

func (*ResponseItemEmpty) SetBidImpressionPrice(price billing.Money) error

SetBidImpressionPrice value for external sources auction the system will pay

func (*ResponseItemEmpty) Source

func (it *ResponseItemEmpty) Source() Source

Source of response

func (*ResponseItemEmpty) SourceCorrectionFactor

func (it *ResponseItemEmpty) SourceCorrectionFactor() float64

SourceCorrectionFactor value for the source

func (*ResponseItemEmpty) TargetCorrectionFactor

func (it *ResponseItemEmpty) TargetCorrectionFactor() float64

TargetCorrectionFactor value for the target

func (*ResponseItemEmpty) Validate

func (*ResponseItemEmpty) Validate() error

Validate item

func (*ResponseItemEmpty) ViewTrackerLinks() []string

ViewTrackerLinks returns traking links for view action

func (*ResponseItemEmpty) Width

func (*ResponseItemEmpty) Width() int

Width of item

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

func (*SecondAd) GetCampaignID

func (s *SecondAd) GetCampaignID() uint64

GetCampaignID value

func (*SecondAd) GetECPM

func (s *SecondAd) GetECPM() billing.Money

GetECPM value

func (*SecondAd) GetPrice

func (s *SecondAd) GetPrice() billing.Money

GetPrice value

func (*SecondAd) GetSourceID

func (s *SecondAd) GetSourceID() uint64

GetSourceID value

type Segment

type Segment struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

Segment item value

type SiteInfo

type SiteInfo = udetect.Site

type Source

type Source interface {
	SourceMinimal
	SourceTesteChecker

	// ID of the source driver
	ID() uint64

	// ObjectKey of the source driver
	ObjectKey() uint64

	// Protocol of the source driver
	Protocol() string

	// 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) Bid

func (*SourceEmpty) Bid(request BidRequester) Response

Bid request for standart system filter

func (*SourceEmpty) ID

func (*SourceEmpty) ID() uint64

ID of the source driver

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) Protocol

func (*SourceEmpty) Protocol() string

Protocol of the source driver

func (*SourceEmpty) RequestStrategy

func (*SourceEmpty) RequestStrategy() RequestStrategy

RequestStrategy description

func (*SourceEmpty) Test

func (*SourceEmpty) Test(request BidRequester) bool

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 SourceIterator

type SourceIterator = iter.Seq2[float32, Source]

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
	Test(request BidRequester) bool
}

SourceTesteChecker checker

type SourceTester

type SourceTester interface {
	Source
	SourceTesteChecker
}

SourceTester interface

type SourceTimeoutSetter

type SourceTimeoutSetter interface {
	// SetTimeout for sourcer
	SetTimeout(timeout time.Duration)
}

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 of current target from 0 to 1
	CommissionShareFactor() 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
	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) Account

func (l *TargetEmpty) Account() Account

Account object

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) ID

func (l *TargetEmpty) ID() uint64

ID of object

func (*TargetEmpty) IsAllowedSource

func (l *TargetEmpty) IsAllowedSource(id uint64, types []int) bool

IsAllowedSource for targeting

func (*TargetEmpty) ObjectKey

func (l *TargetEmpty) ObjectKey() string

ObjectKey of the target

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 TypeSex

type TypeSex uint8

TypeSex type

const (
	UserSexUndefined TypeSex = 0
	UserSexMale      TypeSex = 1
	UserSexFemale    TypeSex = 2
)

User sex enum

func SexByString

func SexByString(sex string) (t TypeSex)

SexByString returns the type Sex

func (TypeSex) Code

func (s TypeSex) Code() string

Code from the sex

func (TypeSex) String

func (s TypeSex) String() string

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) AvgAge

func (u User) AvgAge() byte

AvgAge number

func (*User) BirthdayTime

func (u *User) BirthdayTime() time.Time

BirthdayTime parsed by Birthday string

func (User) GenderSimbol

func (u User) GenderSimbol() byte

GenderSimbol returns the first letter

func (*User) GetDataItem

func (u *User) GetDataItem(name string) (v string, ok bool)

GetDataItem simple value by key

func (*User) GetDataItemOrDefault

func (u *User) GetDataItemOrDefault(name, def string) string

GetDataItemOrDefault item

func (*User) SetDataItem

func (u *User) SetDataItem(name, value string)

SetDataItem with simple *key*, *value*

func (*User) SetSexByString

func (u *User) SetSexByString(sex string)

SetSexByString text value

func (User) Sex

func (u User) Sex() TypeSex

Sex constant

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) Account

func (tw VirtualTarget) Account() Account

Account object

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) ID

func (tw VirtualTarget) ID() uint64

ID of object (Zone OR SmartLink only)

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

func (VirtualTarget) Target

func (tw VirtualTarget) Target() Target

Target object accessor

type WinEvent

type WinEvent struct {
	Time     time.Time `json:"t,omitempty"`
	Counter  int       `json:"c,omitempty"`
	URL      string    `json:"u"`
	Data     any       `json:"d,omitempty"`
	Response string    `json:"-"`
	Error    error     `json:"-"`
	Status   int       `json:"-"`
}

WinEvent models

func WinEventDecode

func WinEventDecode(data string, ext ...any) (*WinEvent, error)

WinEventDecode from bytes

func (*WinEvent) CanContinue

func (e *WinEvent) CanContinue() bool

CanContinue try

func (*WinEvent) Decode

func (e *WinEvent) Decode(data string) error

Decode URL object

func (*WinEvent) Encode

func (e *WinEvent) Encode() (string, error)

Encode URL object

func (*WinEvent) Inc

func (e *WinEvent) Inc() *WinEvent

Inc event counter

func (*WinEvent) Ping

func (e *WinEvent) Ping() bool

Ping client server request about win

func (*WinEvent) Reset

func (e *WinEvent) Reset() *WinEvent

Reset event counter

func (*WinEvent) Validate

func (e *WinEvent) Validate() error

Validate event object

Jump to

Keyboard shortcuts

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