adtype

package
v0.0.0-...-6775195 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: AGPL-3.0 Imports: 29 Imported by: 5

Documentation

Index

Constants

View Source
const (
	NativeAssetUndefined = iota
	NativeAssetTitle
	NativeAssetLegend
	NativeAssetMainImage
	NativeAssetIcon
	NativeAssetRating
	NativeAssetSponsored
)

Native asset IDs

View Source
const (
	ContentItemLink             = "link"
	ContentItemContent          = "content"
	ContentItemIFrameURL        = "iframe_url"
	ContentItemNotifyWinURL     = "notify_win_url"
	ContentItemNotifyDisplayURL = "notify_display_url"
)

Content item names

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

Functions

func PrepareURL

func PrepareURL(url string, response Responser, it ResponserItem) string

PrepareURL by event

func PriceRevenueShareReduceFactors

func PriceRevenueShareReduceFactors(price billing.Money, rs revenueShareReducerFactorer, remove bool) billing.Money

PriceRevenueShareReduceFactors cirrection to reduce descreancy

func PriceSourceFactors

func PriceSourceFactors(price billing.Money, src Source, remove bool) billing.Money

PriceSourceFactors currection to reduce descreancy

func PriceSystemComission

func PriceSystemComission(price billing.Money, item systemComissionFactorer, remove bool) billing.Money

PriceSystemComission = 1. - `TrafficSourceComission`

func ReturnResponse

func ReturnResponse(o *Response)

ReturnResponse back to pool

func ReturnResponseAdItem

func ReturnResponseAdItem(o *ResponseAdItem)

ReturnResponseAdItem back to pool

Types

type AccessPoint

type AccessPoint interface {
	// ID of source
	ID() uint64
}

AccessPoint is the DSP source

type BaseFilter

type BaseFilter struct {
	Secure               int8     // 0 - any, 1 - only secure, 2 - no secure
	Adblock              int8     // 0 - any, 1 - only adblock, 2 - no adblock
	PrivateBrowsing      int8     // 0 - any, 1 - only private, 2 - no private
	IP                   int8     // 0 - any, 1 - IPv4, 2 - IPv6
	Devices              []uint64 // Devices type
	OS                   []uint64
	OSExclude            []uint64
	Browsers             []uint64
	BrowsersExclude      []uint64
	Categories           []uint64
	Countries            []string
	Applications         []uint64
	ApplicationsExclude  []uint64
	Domains              []string
	DomainsExclude       []string
	Zones                []uint64
	ZonesExclude         []uint64
	ExternalZones        []string
	ExternalZonesExclude []string
}

BaseFilter object

func (*BaseFilter) Normalise

func (f *BaseFilter) Normalise()

Normalise params

func (*BaseFilter) Test

func (f *BaseFilter) Test(request *BidRequest) bool

Test base from search request

type BidRequest

type BidRequest struct {
	Ctx context.Context `json:"-"`

	ID              string                 `json:"id,omitempty"`    // Auction ID
	ExtID           string                 `json:"bidid,omitempty"` // External Auction ID
	AccessPoint     AccessPoint            `json:"-"`
	Debug           bool                   `json:"debug,omitempty"`
	AuctionType     types.AuctionType      `json:"auction_type,omitempty"`
	RequestCtx      *fasthttp.RequestCtx   `json:"-"` // HTTP request context
	Request         any                    `json:"-"` // Contains original request from RTB or another protocol
	Person          personification.Person `json:"-"`
	Imps            []Impression           `json:"imps,omitempty"`
	AppTarget       *admodels.Application  `json:"app_target,omitempty"`
	Device          *udetect.Device        `json:"device,omitempty"`
	App             *udetect.App           `json:"app,omitempty"`
	Site            *udetect.Site          `json:"site,omitempty"`
	User            *User                  `json:"user,omitempty"`
	Secure          int                    `json:"secure,omitempty"`
	Adblock         int                    `json:"adb,omitempty"`
	PrivateBrowsing int                    `json:"pb,omitempty"`
	Ext             map[string]any         `json:"ext,omitempty"`
	Timemark        time.Time              `json:"timemark,omitempty"`
	Tracer          any                    `json:"-"`
	// contains filtered or unexported fields
}

BidRequest for internal using

func (*BidRequest) Age

func (r *BidRequest) Age() uint

Age which the most relevant

func (*BidRequest) Ages

func (r *BidRequest) Ages() [2]uint

Ages which the most relevant

func (*BidRequest) AppID

func (r *BidRequest) AppID() uint64

AppID by request

func (*BidRequest) AppInfo

func (r *BidRequest) AppInfo() *udetect.App

AppInfo object

func (*BidRequest) BrowserID

func (r *BidRequest) BrowserID() uint64

BrowserID by request

func (*BidRequest) BrowserInfo

func (r *BidRequest) BrowserInfo() *udetect.Browser

BrowserInfo data

func (*BidRequest) CarrierInfo

func (r *BidRequest) CarrierInfo() *udetect.Carrier

CarrierInfo data

func (*BidRequest) Categories

func (r *BidRequest) Categories() []uint64

Categories for request

func (*BidRequest) City

func (r *BidRequest) City() string

City by request

func (*BidRequest) DeviceID

func (r *BidRequest) DeviceID() uint64

DeviceID value

func (*BidRequest) DeviceInfo

func (r *BidRequest) DeviceInfo() *udetect.Device

DeviceInfo data

func (*BidRequest) DeviceType

func (r *BidRequest) DeviceType() uint64

DeviceType item

func (*BidRequest) Domain

func (r *BidRequest) Domain() []string

Domain of site or bundle name

func (*BidRequest) DomainName

func (r *BidRequest) DomainName() string

DomainName of site or bundle name

func (*BidRequest) ExtTargetIDs

func (r *BidRequest) ExtTargetIDs() []string

ExtTargetIDs by request

func (*BidRequest) FormatBitset

func (r *BidRequest) FormatBitset() *searchtypes.NumberBitset[uint]

FormatBitset of IDs

func (*BidRequest) FormatTypeMask

func (r *BidRequest) FormatTypeMask() types.FormatTypeBitset

FormatTypeMask of formats

func (*BidRequest) Formats

func (r *BidRequest) Formats() []*types.Format

Formats list

func (*BidRequest) Gender

func (r *BidRequest) Gender() byte

Gender which the most relevant

func (*BidRequest) GeoCode

func (r *BidRequest) GeoCode() string

GeoCode by request

func (*BidRequest) GeoID

func (r *BidRequest) GeoID() uint64

GeoID by request

func (*BidRequest) GeoInfo

func (r *BidRequest) GeoInfo() *udetect.Geo

GeoInfo data

func (*BidRequest) Get

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

Get context item by key

func (*BidRequest) HTTPRequest

func (r *BidRequest) HTTPRequest() *fasthttp.RequestCtx

HTTPRequest object

func (*BidRequest) Height

func (r *BidRequest) Height() int

Height size

func (*BidRequest) ImpressionByID

func (r *BidRequest) ImpressionByID(id string) *Impression

ImpressionByID object

func (*BidRequest) ImpressionByIDvariation

func (r *BidRequest) ImpressionByIDvariation(id string) *Impression

ImpressionByIDvariation returns impression by ID which can contains any postfix

func (*BidRequest) ImpressionUpdate

func (r *BidRequest) ImpressionUpdate(fn func(imp *Impression) bool)

ImpressionUpdate each

func (*BidRequest) Init

func (r *BidRequest) Init(formats types.FormatsAccessor)

Init basic information

func (*BidRequest) IsAdblock

func (r *BidRequest) IsAdblock() bool

IsAdblock request

func (*BidRequest) IsIPv6

func (r *BidRequest) IsIPv6() bool

IsIPv6 address

func (*BidRequest) IsPrivateBrowsing

func (r *BidRequest) IsPrivateBrowsing() bool

IsPrivateBrowsing request

func (*BidRequest) IsSecure

func (r *BidRequest) IsSecure() bool

IsSecure request

func (*BidRequest) Keywords

func (r *BidRequest) Keywords() []string

Keywords for request

func (*BidRequest) LanguageID

func (r *BidRequest) LanguageID() uint64

LanguageID value

func (*BidRequest) MinECPM

func (r *BidRequest) MinECPM() (minBid billing.Money)

MinECPM value of request acceptable

func (*BidRequest) OSID

func (r *BidRequest) OSID() uint64

OSID by request

func (*BidRequest) OSInfo

func (r *BidRequest) OSInfo() *udetect.OS

OSInfo data

func (*BidRequest) ProjectID

func (r *BidRequest) ProjectID() uint64

ProjectID value

func (*BidRequest) ServiceDomain

func (r *BidRequest) ServiceDomain() string

ServiceDomain name

func (*BidRequest) Set

func (r *BidRequest) Set(key string, val any)

Set context item with key

func (*BidRequest) SetSourceFilter

func (r *BidRequest) SetSourceFilter(ids ...uint64)

SetSourceFilter by IDs

func (*BidRequest) Sex

func (r *BidRequest) Sex() uint

Sex by request

func (*BidRequest) SiteInfo

func (r *BidRequest) SiteInfo() *udetect.Site

SiteInfo object

func (*BidRequest) Size

func (r *BidRequest) Size() (width, height int)

Size of the area of visibility

func (*BidRequest) SourceFilterCheck

func (r *BidRequest) SourceFilterCheck(id uint64) bool

SourceFilterCheck returns the list of available sources

func (*BidRequest) String

func (r *BidRequest) String() (res string)

String implements of fmt.Stringer interface

func (*BidRequest) Tags

func (r *BidRequest) Tags() []string

Tags list

func (*BidRequest) TargetID

func (r *BidRequest) TargetID() uint64

TargetID value

func (*BidRequest) TargetIDs

func (r *BidRequest) TargetIDs() []uint64

TargetIDs by request

func (*BidRequest) Time

func (r *BidRequest) Time() time.Time

Time of request

func (*BidRequest) Unset

func (r *BidRequest) Unset(keys ...string)

Unset context item with keys

func (*BidRequest) UserInfo

func (r *BidRequest) UserInfo() *User

UserInfo data

func (*BidRequest) Validate

func (r *BidRequest) Validate() error

Validate request by currency

func (*BidRequest) Width

func (r *BidRequest) Width() int

Width size

type Data

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

Data item segment

type Impression

type Impression struct {
	ID                string          `json:"id,omitempty"`                  // Internal impression ID
	ExtID             string          `json:"extid,omitempty"`               // External impression ID (ImpID)
	ExtTargetID       string          `json:"exttrgid"`                      // External zone ID (tagid)
	Request           any             `json:"request,omitempty"`             // Contains subrequest from RTB or another protocol
	Target            admodels.Target `json:"target,omitempty"`              //
	BidFloor          billing.Money   `json:"bid_floor,omitempty"`           //
	PurchaseViewPrice billing.Money   `json:"purchase_view_price,omitempty"` //
	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"`  // Position on the site screen
	Y    int `json:"y,omitempty"`  //
	W    int `json:"w,omitempty"`  //
	H    int `json:"h,omitempty"`  //
	WMax int `json:"wm,omitempty"` //
	HMax 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:"-"`

	Ext map[string]any `json:"ext,omitempty"`
	// contains filtered or unexported fields
}

Impression target

func (*Impression) AccountID

func (i *Impression) AccountID() uint64

AccountID number

func (*Impression) ComissionShareFactor

func (i *Impression) ComissionShareFactor() float64

ComissionShareFactor 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) Init

func (i *Impression) Init(formats types.FormatsAccessor)

Init internal information

func (*Impression) IsDirect

func (i *Impression) IsDirect() bool

IsDirect value

func (*Impression) IsNative

func (i *Impression) IsNative() bool

IsNative target support

func (*Impression) IsStandart

func (i *Impression) IsStandart() bool

IsStandart target support

func (*Impression) RTBNativeRequest

func (i *Impression) RTBNativeRequest() (r *openrtbnreq.Request)

RTBNativeRequest object

func (*Impression) RevenueShareFactor

func (i *Impression) RevenueShareFactor() float64

RevenueShareFactor value for the publisher company

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 value

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 PriceFactor

type PriceFactor uint32

PriceFactor defines action to calculate the factor

const (
	NonePriceFactor            PriceFactor = 0x0000
	AllPriceFactors            PriceFactor = 0xffffffff
	SourcePriceFactor          PriceFactor = 0x0001
	SystemComissionPriceFactor PriceFactor = 0x0002
	TargetReducePriceFactor    PriceFactor = 0x0004
)

func PriceFactorFromList

func PriceFactorFromList(factors ...PriceFactor) (f PriceFactor)

PriceFactorFromList create factor from list

func (PriceFactor) Add

func (f PriceFactor) Add(price billing.Money, it ResponserItem) (comissions billing.Money)

Add comissions to price and rеturns comissions with positive sign `+`

func (PriceFactor) Remove

func (f PriceFactor) Remove(price billing.Money, it ResponserItem) (comissions billing.Money)

Remove comissions from price and rеturns comissions with negative sign `-`

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 struct {
	// contains filtered or unexported fields
}

Response from different sources

func BorrowResponse

func BorrowResponse(request *BidRequest, source Source, items []ResponserItemCommon, err error) *Response

BorrowResponse object

func NewErrorResponse

func NewErrorResponse(request *BidRequest, err error) *Response

NewErrorResponse object

func NewResponse

func NewResponse(request *BidRequest, source Source, items []ResponserItemCommon, err error) *Response

NewResponse common object

func (*Response) AddItem

func (r *Response) AddItem(it ResponserItemCommon)

AddItem to response

func (*Response) Ads

func (r *Response) Ads() []ResponserItemCommon

Ads list

func (*Response) AuctionID

func (r *Response) AuctionID() string

AuctionID response

func (*Response) AuctionType

func (r *Response) AuctionType() types.AuctionType

AuctionType of request

func (*Response) Context

func (r *Response) Context(ctx ...context.Context) context.Context

Context value

func (*Response) Count

func (r *Response) Count() int

Count of response items

func (*Response) Error

func (r *Response) Error() error

Error of the response

func (*Response) Get

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

Get context item by key

func (*Response) Item

func (r *Response) Item(impid string) ResponserItemCommon

Item by impression code

func (*Response) Request

func (r *Response) Request() *BidRequest

Request information

func (*Response) Source

func (r *Response) Source() Source

Source of response

func (*Response) Validate

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

Validate response

type ResponseAdItem

type ResponseAdItem struct {
	Ctx    context.Context `json:"-"`
	ItemID string          `json:"id"`

	Src Source      `json:"source,omitempty"`
	Req *BidRequest `json:"request,omitempty"`
	Imp *Impression `json:"impression,omitempty"` // Impression Unique

	Campaign *admodels.Campaign `json:"campaign,omitempty"`
	Ad       *admodels.Ad       `json:"ad,omitempty"`
	AdBid    *admodels.AdBid    `json:"ad_bid,omitempty"`
	AdLink   admodels.AdLink    `json:"ad_link,omitempty"`

	BidECPM     billing.Money `json:"bid_ecpm,omitempty"`   //
	BidPrice    billing.Money `json:"bid_price,omitempty"`  // Max RTB bid price (CPM only)
	AdPrice     billing.Money `json:"price,omitempty"`      // New price of advertisement target action (click, lead, impression)
	AdLeadPrice billing.Money `json:"lead_price,omitempty"` //
	CPMBidPrice billing.Money `json:"cpm_bid,omitempty"`    // This param can update only price predictor
	SecondAd    SecondAd      `json:"second_ad,omitempty"`  //
}

ResponseAdItem for select from storage

func BorrowResponseAdItem

func BorrowResponseAdItem() *ResponseAdItem

BorrowResponseAdItem object

func (*ResponseAdItem) AccountID

func (it *ResponseAdItem) AccountID() uint64

AccountID number

func (*ResponseAdItem) ActionURL

func (it *ResponseAdItem) ActionURL() string

ActionURL for direct baners

func (it *ResponseAdItem) AdDirectLink() string

AdDirectLink of the ad

func (*ResponseAdItem) AdID

func (it *ResponseAdItem) AdID() uint64

AdID number

func (*ResponseAdItem) AdIDString

func (it *ResponseAdItem) AdIDString() string

AdIDString References the ad to be served if the bid wins.

func (*ResponseAdItem) Asset

func (it *ResponseAdItem) Asset(name string) *admodels.AdAsset

Asset by name

func (*ResponseAdItem) Assets

func (it *ResponseAdItem) Assets() admodels.AdAssets

Assets list

func (*ResponseAdItem) AuctionCPMBid

func (it *ResponseAdItem) AuctionCPMBid() billing.Money

AuctionCPMBid value price without any comission Can be replaced on comission only

func (*ResponseAdItem) AuctionID

func (it *ResponseAdItem) AuctionID() string

AuctionID response

func (*ResponseAdItem) CPMPrice

func (it *ResponseAdItem) CPMPrice(removeFactors ...PriceFactor) (price billing.Money)

CPMPrice value price value for DSP auction

func (*ResponseAdItem) CampaignID

func (it *ResponseAdItem) CampaignID() uint64

CampaignID number

func (*ResponseAdItem) CampaignIDString

func (it *ResponseAdItem) CampaignIDString() string

CampaignIDString that appears with the Ad markup.

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

ClickTrackerLinks returns third-party tracker URLs to be fired on click of the URL

func (*ResponseAdItem) ComissionShareFactor

func (it *ResponseAdItem) ComissionShareFactor() float64

ComissionShareFactor which system get from publisher

func (*ResponseAdItem) ContentFields

func (it *ResponseAdItem) ContentFields() map[string]any

ContentFields from advertisement object

func (*ResponseAdItem) ContentItem

func (it *ResponseAdItem) ContentItem(name string) any

ContentItem returns the ad response data

func (*ResponseAdItem) ContentItemString

func (it *ResponseAdItem) ContentItemString(name string) string

ContentItemString from the ad

func (*ResponseAdItem) Context

func (it *ResponseAdItem) Context(ctx ...context.Context) (c context.Context)

Context value

func (*ResponseAdItem) CreativeIDString

func (it *ResponseAdItem) CreativeIDString() string

CreativeIDString for reporting content issues or defects. This could also be used as a reference to a creative ID that is posted with an exchange.

func (*ResponseAdItem) ECPM

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

ECPM item value

func (*ResponseAdItem) ExtImpressionID

func (it *ResponseAdItem) ExtImpressionID() string

ExtImpressionID unique code of RTB response

func (*ResponseAdItem) ExtTargetID

func (it *ResponseAdItem) ExtTargetID() string

ExtTargetID of the external network

func (*ResponseAdItem) Format

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

Format object model

func (*ResponseAdItem) Get

func (it *ResponseAdItem) Get(key string) any

Get ext field

func (*ResponseAdItem) Height

func (it *ResponseAdItem) Height() int

Height of AD

func (*ResponseAdItem) ID

func (it *ResponseAdItem) ID() string

ID of current response item (unique code of current response)

func (*ResponseAdItem) Impression

func (it *ResponseAdItem) Impression() *Impression

Impression place object

func (*ResponseAdItem) ImpressionID

func (it *ResponseAdItem) ImpressionID() string

ImpressionID unique code string

func (*ResponseAdItem) IsDirect

func (it *ResponseAdItem) IsDirect() bool

IsDirect response item

func (*ResponseAdItem) MainAsset

func (it *ResponseAdItem) MainAsset() *admodels.AdAsset

MainAsset from response

func (*ResponseAdItem) NetworkName

func (it *ResponseAdItem) NetworkName() string

NetworkName by source

func (*ResponseAdItem) PotentialPrice

func (it *ResponseAdItem) PotentialPrice(action admodels.Action) billing.Money

PotentialPrice wich can be received from source but was marked as descrepancy

func (*ResponseAdItem) Price

func (it *ResponseAdItem) Price(action admodels.Action, removeFactors ...PriceFactor) (price billing.Money)

Price for specific action if supported `click`, `lead`, `view` returns total price of the action

func (*ResponseAdItem) PricingModel

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

PricingModel of advertisement

func (*ResponseAdItem) PriorityFormatType

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

PriorityFormatType from current Ad

func (*ResponseAdItem) ProjectID

func (it *ResponseAdItem) ProjectID() uint64

ProjectID number

func (*ResponseAdItem) PurchasePrice

func (it *ResponseAdItem) PurchasePrice(action admodels.Action, removeFactors ...PriceFactor) billing.Money

PurchasePrice gives the price of view from external resource. The cost of this request.

func (*ResponseAdItem) Request

func (it *ResponseAdItem) Request() *BidRequest

Request information

func (*ResponseAdItem) RevenueShareFactor

func (it *ResponseAdItem) RevenueShareFactor() float64

RevenueShareFactor amount %

func (*ResponseAdItem) Second

func (it *ResponseAdItem) Second() *SecondAd

Second campaigns

func (*ResponseAdItem) SetCPMPrice

func (it *ResponseAdItem) SetCPMPrice(price billing.Money, includeFactors ...PriceFactor)

SetCPMPrice update of DSP auction value

func (*ResponseAdItem) Source

func (it *ResponseAdItem) Source() Source

Source of response

func (*ResponseAdItem) TargetID

func (it *ResponseAdItem) TargetID() uint64

TargetID number

func (*ResponseAdItem) TargetIDString

func (it *ResponseAdItem) TargetIDString() string

TargetIDString number

func (*ResponseAdItem) Validate

func (it *ResponseAdItem) Validate() error

Validate item

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

ViewTrackerLinks returns traking links for view action

func (*ResponseAdItem) Width

func (it *ResponseAdItem) Width() int

Width of AD

type ResponseEmpty

type ResponseEmpty struct {
	ItemID string
	Req    *BidRequest
	Src    Source
	Imp    *Impression
	Bid    *openrtb.Bid
	Err    error
	// contains filtered or unexported fields
}

ResponseEmpty object

func NewEmptyResponse

func NewEmptyResponse(request *BidRequest, src Source, err error) *ResponseEmpty

NewEmptyResponse by bid request

func (ResponseEmpty) Ads

Ads list

func (ResponseEmpty) AuctionCPMBid

func (r ResponseEmpty) AuctionCPMBid() billing.Money

AuctionCPMBid value price without any comission

func (ResponseEmpty) AuctionID

func (r ResponseEmpty) AuctionID() string

AuctionID response

func (ResponseEmpty) AuctionType

func (r ResponseEmpty) AuctionType() types.AuctionType

AuctionType of request

func (ResponseEmpty) CPMBid

func (r ResponseEmpty) CPMBid() billing.Money

CPMBid value

func (*ResponseEmpty) Context

func (r *ResponseEmpty) Context(ctx ...context.Context) context.Context

Context value

func (ResponseEmpty) Count

func (r ResponseEmpty) Count() int

Count of response items

func (ResponseEmpty) Error

func (r ResponseEmpty) Error() error

Error of the response

func (ResponseEmpty) ExtImpressionID

func (r ResponseEmpty) ExtImpressionID() string

ExtImpressionID it's unique code of the auction bid impression

func (ResponseEmpty) ExtTargetID

func (r ResponseEmpty) ExtTargetID() string

ExtTargetID of the external network

func (*ResponseEmpty) Get

func (r *ResponseEmpty) Get(key string) (res any)

Get ext field

func (ResponseEmpty) ID

func (r ResponseEmpty) ID() string

ID of current response item (unique code of current response)

func (ResponseEmpty) Impression

func (r ResponseEmpty) Impression() *Impression

Impression place object

func (ResponseEmpty) ImpressionID

func (r ResponseEmpty) ImpressionID() string

ImpressionID unique code string

func (ResponseEmpty) Item

Item by impression code

func (ResponseEmpty) LeadPrice

func (r ResponseEmpty) LeadPrice() billing.Money

LeadPrice summ

func (ResponseEmpty) Price

func (r ResponseEmpty) Price() billing.Money

Price of whole response

func (ResponseEmpty) PriorityFormatType

func (r ResponseEmpty) PriorityFormatType() types.FormatType

PriorityFormatType from current Ad

func (ResponseEmpty) Request

func (r ResponseEmpty) Request() *BidRequest

Request information

func (ResponseEmpty) Source

func (r ResponseEmpty) Source() Source

Source of response

func (ResponseEmpty) Validate

func (r ResponseEmpty) Validate() error

Validate response

type ResponseItemBlock

type ResponseItemBlock struct {
	Items []ResponserItem
	// contains filtered or unexported fields
}

ResponseItemBlock group of simple items

func (*ResponseItemBlock) Ads

func (i *ResponseItemBlock) Ads() []ResponserItem

Ads list

func (*ResponseItemBlock) AuctionCPMBid

func (i *ResponseItemBlock) AuctionCPMBid() (bid billing.Money)

AuctionCPMBid value price without any comission

func (*ResponseItemBlock) Context

func (i *ResponseItemBlock) Context(ctx ...context.Context) context.Context

Context value

func (*ResponseItemBlock) Count

func (i *ResponseItemBlock) Count() int

Count of response items

func (*ResponseItemBlock) ExtImpressionID

func (i *ResponseItemBlock) ExtImpressionID() string

ExtImpressionID it's unique code of the auction bid impression

func (*ResponseItemBlock) ExtTargetID

func (i *ResponseItemBlock) ExtTargetID() string

ExtTargetID of the external network

func (*ResponseItemBlock) Get

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

Get ext field

func (*ResponseItemBlock) ID

func (i *ResponseItemBlock) ID() string

ID of current response item (unique code of current response)

func (*ResponseItemBlock) Impression

func (i *ResponseItemBlock) Impression() *Impression

Impression place object

func (*ResponseItemBlock) ImpressionID

func (i *ResponseItemBlock) ImpressionID() string

ImpressionID code

func (*ResponseItemBlock) Price

func (i *ResponseItemBlock) Price(action admodels.Action) (price billing.Money)

Price of whole response

func (*ResponseItemBlock) PriorityFormatType

func (i *ResponseItemBlock) PriorityFormatType() types.FormatType

PriorityFormatType from current Ad

func (*ResponseItemBlock) Validate

func (i *ResponseItemBlock) Validate() (err error)

Validate response

type ResponseItemEmpty

type ResponseItemEmpty struct{}

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() uint64

AdID number

func (*ResponseItemEmpty) Asset

func (*ResponseItemEmpty) Asset(name string) *admodels.AdAsset

Asset by name

func (*ResponseItemEmpty) Assets

Assets list

func (*ResponseItemEmpty) AuctionCPMBid

func (*ResponseItemEmpty) AuctionCPMBid() billing.Money

AuctionCPMBid value price without any comission

func (*ResponseItemEmpty) CPMPrice

func (*ResponseItemEmpty) CPMPrice(removeFactors ...PriceFactor) billing.Money

CPMPrice value price value for DSP auction

func (*ResponseItemEmpty) CampaignID

func (*ResponseItemEmpty) CampaignID() uint64

CampaignID number

func (*ResponseItemEmpty) ClickTrackerLinks() []string

ClickTrackerLinks returns traking links for click action

func (*ResponseItemEmpty) ComissionShareFactor

func (*ResponseItemEmpty) ComissionShareFactor() float64

ComissionShareFactor 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 (*ResponseItemEmpty) Context(ctx ...context.Context) context.Context

Context value

func (*ResponseItemEmpty) ECPM

ECPM item value

func (*ResponseItemEmpty) ExtImpressionID

func (*ResponseItemEmpty) ExtImpressionID() string

ExtImpressionID it's unique code of the auction bid impression

func (*ResponseItemEmpty) ExtTargetID

func (*ResponseItemEmpty) ExtTargetID() string

ExtTargetID of the external network

func (*ResponseItemEmpty) Format

func (*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 (*ResponseItemEmpty) Impression() *Impression

Impression place object

func (*ResponseItemEmpty) ImpressionID

func (*ResponseItemEmpty) ImpressionID() string

ImpressionID unique code string

func (*ResponseItemEmpty) IsDirect

func (*ResponseItemEmpty) IsDirect() bool

IsDirect AD type

func (*ResponseItemEmpty) MainAsset

func (*ResponseItemEmpty) MainAsset() *admodels.AdAsset

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 admodels.Action) billing.Money

PotentialPrice wich can be received from source but was marked as descrepancy

func (*ResponseItemEmpty) Price

func (*ResponseItemEmpty) Price(action admodels.Action, removeFactors ...PriceFactor) billing.Money

Price summ

func (*ResponseItemEmpty) PricingModel

func (*ResponseItemEmpty) PricingModel() types.PricingModel

PricingModel of advertisement

func (*ResponseItemEmpty) PriorityFormatType

func (*ResponseItemEmpty) PriorityFormatType() types.FormatType

PriorityFormatType from current Ad

func (*ResponseItemEmpty) PurchasePrice

func (*ResponseItemEmpty) PurchasePrice(action admodels.Action, removeFactors ...PriceFactor) billing.Money

PurchasePrice gives the price of view from external resource. The cost of this request.

func (*ResponseItemEmpty) RevenuePercent

func (*ResponseItemEmpty) RevenuePercent() float64

RevenuePercent money

func (*ResponseItemEmpty) RevenueShareFactor

func (*ResponseItemEmpty) RevenueShareFactor() float64

RevenueShareFactor returns the multipler for company revenue calculation per action from 0 to 1

func (*ResponseItemEmpty) Second

func (*ResponseItemEmpty) Second() *SecondAd

Second campaigns

func (*ResponseItemEmpty) SetCPMPrice

func (*ResponseItemEmpty) SetCPMPrice(price billing.Money, includeFactors ...PriceFactor)

SetCPMPrice update of DSP auction value

func (*ResponseItemEmpty) Source

func (*ResponseItemEmpty) Source() Source

Source of response

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 Responser

type Responser interface {
	// AuctionID response
	AuctionID() string

	// AuctionType of request
	AuctionType() types.AuctionType

	// Source of response
	Source() Source

	// Request information
	Request() *BidRequest

	// Ads list
	Ads() []ResponserItemCommon

	// Item by impression code
	Item(impid string) ResponserItemCommon

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

Responser type

type ResponserItem

type ResponserItem interface {
	ResponserItemCommon

	// AdID number
	AdID() uint64

	// AccountID number
	AccountID() uint64

	// CampaignID number
	CampaignID() uint64

	// Format object
	Format() *types.Format

	// PricingModel of the response advertisement
	PricingModel() types.PricingModel

	// ContentItem returns the ad response data
	ContentItem(name string) any

	// ContentItemString from the ad
	ContentItemString(name string) string

	// ContentFields from advertisement object
	ContentFields() map[string]any

	// MainAsset from response
	MainAsset() *admodels.AdAsset

	// Asset by name
	Asset(name string) *admodels.AdAsset

	// Assets list
	Assets() admodels.AdAssets

	// Source of response
	Source() Source

	// ViewTrackerLinks returns traking links for view action
	ViewTrackerLinks() []string

	// ClickTrackerLinks returns traking links for click action
	ClickTrackerLinks() []string

	// NetworkName by source
	NetworkName() string

	// Price for specific action if supported `click`, `lead`, `view`
	// returns total price of the action
	Price(action admodels.Action, removeFactors ...PriceFactor) billing.Money

	// SetCPMPrice update of DSP auction value
	SetCPMPrice(price billing.Money, includeFactors ...PriceFactor)

	// CPMPrice value price value for DSP auction
	CPMPrice(removeFactors ...PriceFactor) billing.Money

	// PurchasePrice gives the price of view from external resource.
	// The cost of this request.
	PurchasePrice(action admodels.Action, removeFactors ...PriceFactor) billing.Money

	// PotentialPrice wich can be received from source but was marked as descrepancy
	PotentialPrice(action admodels.Action) billing.Money

	// Second campaigns
	Second() *SecondAd

	// ECPM item value
	ECPM() billing.Money

	// RevenueShareFactor returns the multipler for company
	// revenue calculation per action from 0 to 1
	RevenueShareFactor() float64

	// ComissionShareFactor returns the multipler for commission
	// calculation which system get from user revenue from 0 to 1
	ComissionShareFactor() float64

	// IsDirect AD type
	IsDirect() bool

	// ActionURL returns target resource link for direct and banner click as well
	ActionURL() string

	// Width of item
	Width() int

	// Height of item
	Height() int
}

ResponserItem for single AD

type ResponserItemCommon

type ResponserItemCommon interface {
	// ID of current response item (unique code of current response)
	ID() string

	// Impression place object
	Impression() *Impression

	// ImpressionID unique code string
	ImpressionID() string

	// ExtImpressionID it's unique code of the auction bid impression
	ExtImpressionID() string

	// ExtTargetID of the external network
	ExtTargetID() string

	// AuctionCPMBid value price without any comission
	AuctionCPMBid() billing.Money

	// PriorityFormatType from current Ad
	PriorityFormatType() types.FormatType

	// Validate item
	Validate() error

	// Context value
	Context(ctx ...context.Context) context.Context

	// Get ext field
	Get(key string) any
}

ResponserItemCommon interface

type ResponserMultipleItem

type ResponserMultipleItem interface {
	ResponserItemCommon

	// Ads list response
	Ads() []ResponserItem

	// Count of response items
	Count() int
}

ResponserMultipleItem interface for complex banners

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 Source

type Source interface {
	SourceMinimal

	// ID of the source driver
	ID() uint64

	// ObjectKey of the source driver
	ObjectKey() uint64

	// Protocol of the source driver
	Protocol() string

	// Test request before processing
	Test(request *BidRequest) bool

	// 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 *BidRequest) SourceIterator

	// SourceByID returns source instance
	SourceByID(id uint64) (Source, error)

	// SetTimeout for sourcer
	SetTimeout(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 *BidRequest) Responser

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(Responser, ResponserItem)

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 *BidRequest) bool

Test request before processing

type SourceIterator

type SourceIterator interface {
	// Next returns source interface according to strategy
	Next() Source
}

SourceIterator returns next source from the scope

type SourceMinimal

type SourceMinimal interface {
	// Bid request for standart system filter
	Bid(request *BidRequest) Responser

	// ProcessResponseItem result or error
	ProcessResponseItem(Responser, ResponserItem)
}

SourceMinimal contains only minimal set of methods

type SourceTesteChecker

type SourceTesteChecker interface {
	// Test current request for compatibility
	Test(request *BidRequest) 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 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 ResponserItem, response Responser, js bool) (string, error)

	// PixelDirectURL generator from response of item
	PixelDirectURL(event events.Type, status uint8, item ResponserItem, response Responser, direct string) (string, error)

	// PixelLead URL
	PixelLead(item ResponserItem, response Responser, js bool) (string, error)

	// MustClickURL generator from response of item
	MustClickURL(item ResponserItem, response Responser) string

	// ClickURL generator from response of item
	ClickURL(item ResponserItem, response Responser) (string, error)

	// ClickRouterURL returns router pattern
	ClickRouterURL() string

	// DirectURL generator from response of item
	DirectURL(event events.Type, item ResponserItem, response Responser) (string, error)

	// DirectRouterURL returns router pattern
	DirectRouterURL() string

	// WinURL generator from response of item
	WinURL(event events.Type, status uint8, item ResponserItem, response Responser) (string, error)

	// BillingNoticeURL generator from response of item
	BillingNoticeURL(event events.Type, status uint8, item ResponserItem, response Responser) (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) 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) RTBObject

func (u User) RTBObject() *openrtb.User

RTBObject of User

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