admodels

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 13

Documentation

Index

Constants

View Source
const (
	RTBRequestTypeUndefined       = types.RTBRequestTypeUndefined
	RTBRequestTypeJSON            = types.RTBRequestTypeJSON
	RTBRequestTypeXML             = types.RTBRequestTypeXML
	RTBRequestTypeProtoBUFF       = types.RTBRequestTypeProtoBUFF
	RTBRequestTypePOSTFormEncoded = types.RTBRequestTypePOSTFormEncoded
	RTBRequestTypePLAINTEXT       = types.RTBRequestTypePLAINTEXT
)

Request types

Variables

View Source
var (
	ErrAccessPointNotAllowed = errtype.Error("access point not allowed")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	IDval uint64 // Authoincrement key

	MaxDaily     billing.Money
	CurrentState AccountBalanceState

	// AccessPointsAllowed is a list of access points allowed for the account
	AccessPointsAllowed gosql.OrderedNumberArray[uint64]

	// RevenueShare it's amount of percent of the raw incode which will be shared with the publisher company
	// For example:
	//   Displayed ads for 100$
	//   Account revenue share 60%
	//   In such case the ad network have 40$
	//   The publisher have 60$
	RevenueShare float64 // % 1.0 -> 100%, 0.655 -> 65.5%
}

Account model

func (*Account) Balance

func (c *Account) Balance() billing.Money

Balance of the account

func (*Account) CommissionShareFactor

func (c *Account) CommissionShareFactor() float64

CommissionShareFactor which system get from publisher 0..1

func (*Account) DailyBudget

func (c *Account) DailyBudget() billing.Money

DailyBudget of the account

func (*Account) ID

func (c *Account) ID() uint64

ID of object

func (*Account) ObjectKey

func (c *Account) ObjectKey() uint64

ObjectKey of the target

func (*Account) RemainingSpendBalance

func (c *Account) RemainingSpendBalance() billing.Money

RemainingSpendBalance returns the remaining spend balance for the account.

func (*Account) Spend

func (c *Account) Spend() billing.Money

Spend of the account

func (*Account) TestBudgetValue

func (c *Account) TestBudgetValue() bool

TestBudgetValue tests if the account has enough balance to spend

func (*Account) TestRequest

func (c *Account) TestRequest(accessPointID uint64) error

TestRequest tests if the account has access to the access point

type AccountBalanceState

type AccountBalanceState interface {
	Balance() billing.Money
	Spend() billing.Money
}

type AdFileAsset

type AdFileAsset struct {
	ID          uint64                `json:"id,omitempty"`
	ExternalID  string                `json:"external_id,omitempty"` // ID of the asset in the source system, like VAST media file ID
	Name        string                `json:"name,omitempty"`        // Name of the asset, like "main", "banner", "icon", etc.
	AltText     string                `json:"alt_text,omitempty"`    // Alternative text for the asset, used for accessibility and as a fallback
	URL         string                `json:"url,omitempty"`         // In case of HTML5, here must be the path to directory on CDN
	Type        types.AdFileAssetType `json:"type,omitempty"`
	ContentType string                `json:"content_type,omitempty"`
	Width       int                   `json:"width,omitempty"`
	Height      int                   `json:"height,omitempty"`
	Duration    int                   `json:"duration,omitempty"` // Duration in seconds, for video assets
	Thumbs      []AdFileAssetThumb    `json:"thumbs,omitempty"`
	FocalPoint  *types.FocalPoint     `json:"focal_point,omitempty"`
}

AdFileAsset information

func (*AdFileAsset) ClosestThumbBy

func (f *AdFileAsset) ClosestThumbBy(w, h, wmin, hmin int) *AdFileAssetThumb

ClosestThumbBy returns the thumb nearest to (w, h). Thumbs that fit the size borders (IsSuits) are preferred; if none fit, the closest of all thumbs is returned. w or h <= 0 leaves that axis unbounded for the fit check and measures closeness against wmin or hmin. Equal distance keeps the smaller thumb.

func (*AdFileAsset) IsAudio

func (f *AdFileAsset) IsAudio() bool

IsAudio file type

func (*AdFileAsset) IsHTML5

func (f *AdFileAsset) IsHTML5() bool

IsHTML5 file type

func (*AdFileAsset) IsImage

func (f *AdFileAsset) IsImage() bool

IsImage file type

func (*AdFileAsset) IsVideo

func (f *AdFileAsset) IsVideo() bool

IsVideo file type

func (*AdFileAsset) ThumbBy

func (f *AdFileAsset) ThumbBy(w, h, wmin, hmin int) (th *AdFileAssetThumb)

ThumbBy size borders and specific type

type AdFileAssetThumb

type AdFileAssetThumb struct {
	URL    string                `json:"url"`
	Width  int                   `json:"w"`
	Height int                   `json:"h"`
	Type   types.AdFileAssetType `json:"type,omitempty"`
}

AdFileAssetThumb of the file

func (*AdFileAssetThumb) IsImage

func (th *AdFileAssetThumb) IsImage() bool

IsImage file type

func (AdFileAssetThumb) IsSuits

func (th AdFileAssetThumb) IsSuits(w, h, wmin, hmin int) bool

IsSuits thumb by size

func (*AdFileAssetThumb) IsVideo

func (th *AdFileAssetThumb) IsVideo() bool

IsVideo file type

type AdFileAssets

type AdFileAssets []*AdFileAsset

AdFileAssets contains the list of file assets

func (AdFileAssets) HasAsset

func (assets AdFileAssets) HasAsset(name string, assetType types.AdFileAssetType) bool

HasAsset returns true if the assets list has an asset with the given name

func (AdFileAssets) Len

func (assets AdFileAssets) Len() int

Len returns the length of the assets list

func (AdFileAssets) RandomAsset

func (assets AdFileAssets) RandomAsset(name string, assetType types.AdFileAssetType) *AdFileAsset

RandomAsset returns a random asset by name (main or other)

func (AdFileAssets) RandomAssetWithSize

func (assets AdFileAssets) RandomAssetWithSize(name string, assetType types.AdFileAssetType, w, h int) *AdFileAsset

RandomAssetWithSize returns a random asset by name and size (main or other)

func (AdFileAssets) RandomMain

func (assets AdFileAssets) RandomMain(assetType types.AdFileAssetType) *AdFileAsset

RandomMain returns a random main asset

func (AdFileAssets) RandomMainAsset

func (assets AdFileAssets) RandomMainAsset(assetType types.AdFileAssetType) *AdFileAsset

RandomMainAsset returns a random main asset

type Application

type Application struct {
	ID        uint64   // Authoincrement key
	Account   *Account // Account which application belongs to
	AccountID uint64   //

	URI      string                // Unical application identificator
	Type     types.ApplicationType `gorm:"type:ApplicationType" json:"type"`
	Platform types.PlatformType    `gorm:"type:PlatformType" json:"platform"`
	Premium  bool                  `json:"premium"`

	Categories   []uint
	RevenueShare float64 // % 1.0 -> 100%, 0.655 -> 65.5%
}

Application model

func ApplicationFromModel

func ApplicationFromModel(app *models.Application) Application

ApplicationFromModel convert database model to specified model

func (*Application) CommissionShareFactor

func (a *Application) CommissionShareFactor() float64

CommissionShareFactor which system get from publisher

func (*Application) ObjectKey

func (a *Application) ObjectKey() string

ObjectKey of the application

type RTBRequestType

type RTBRequestType = types.RTBRequestType

RTBRequestType contains type of representation of request information

type RTBSource

type RTBSource struct {
	ID      uint64
	Account *Account

	Protocol    string         // rtb as default
	URL         string         // RTB client request URL
	Method      string         // HTTP method GET, POST, ect; Default POST
	RequestType RTBRequestType // 1 - json, 2 - xml, 3 - ProtoBUFF, 4 - MultipleFormaData, 5 - PLAINTEXT
	Headers     gosql.NullableJSON[map[string]string]

	Options RTBSourceFlags
	Filter  basefilter.BaseFilter

	AuctionType types.AuctionType // default: 0 – first price type, 1 – second price type
	RPS         int               // 0 – unlimit
	Timeout     int               // In milliseconds

	Accuracy              float64 // Price accuracy for auction in percentages
	PriceCorrectionReduce float64 // % 100, 80%, 65.5% - 0 .. 1
	MinimalWeight         float64

	// Price limits
	MinBid billing.Money // Minimal bid value
	MaxBid billing.Money // Maximal bid value

	// TODO
	Budget      billing.Money // Budget for this source
	DailyBudget billing.Money // Daily budget for this source

	Config RTBSourceConfig
}

RTBSource describe the source of external DSP platform or similar exchange protocol. All that sources have similar options and very common prefilter configurations

func RTBSourceFromModel

func RTBSourceFromModel(cl *models.RTBSource, acc *Account) (src *RTBSource)

RTBSourceFromModel convert database model to specified model

func (*RTBSource) Domain

func (s *RTBSource) Domain() string

Domain of the source

func (*RTBSource) PriceCorrectionReduceFactor

func (s *RTBSource) 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 (*RTBSource) Test

func (s *RTBSource) Test(t types.TargetPointer) error

Test RTB source

func (*RTBSource) TestFormat

func (s *RTBSource) TestFormat(f *types.Format) bool

TestFormat available in filter

func (*RTBSource) Weight

func (s *RTBSource) Weight() float64

Weight of the source for ad selection

type RTBSourceConfig

type RTBSourceConfig = models.RTBSourceConfig

RTBSourceConfig contains configuration for the RTB source

type RTBSourceFlags

type RTBSourceFlags = models.RTBSourceFlags

RTBSourceFlags contains flags for the RTB source

type State

type State interface {
	Profit() billing.Money
	TotalProfit() billing.Money
	Spend() billing.Money
	TotalSpend() billing.Money
	Imps() uint64
	Directs() uint64
	Views() uint64
	Clicks() uint64
	Leads() uint64
	LastSyncTime() time.Time
	ServerCount() int
}

type TrafficRouter

type TrafficRouter struct {
	ID uint64

	// IDs of RTB sources to which the traffic should be routed
	RTBSourceIDs []uint64

	// Percentage of traffic to be routed
	Percent float32

	// Filter criteria for routing traffic
	Filter basefilter.BaseFilter
}

TrafficRouter represents a traffic router in the system.

func (*TrafficRouter) ObjectKey

func (d *TrafficRouter) ObjectKey() uint64

ObjectKey of the router

func (*TrafficRouter) Test

func (d *TrafficRouter) Test(target types.TargetPointer) error

Test checks if the target matches the filter criteria.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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