admodels

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

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

View Source
const (
	UserFlagCanHaveNegativeBalance = 1 << iota
)

User set of flags

Variables

Formats field set

Functions

func FormatFromModel

func FormatFromModel(format *models.Format) *types.Format

FormatFromModel object

Types

type Account

type Account struct {
	IDval uint64 // Authoincrement key

	MaxDaily     billing.Money
	CurrentState AccountBalanceState

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

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

Spend of the account

type AccountBalanceState

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

type AccountTarget

type AccountTarget struct {
	Acc *Account
}

AccountTarget wrapper for replace of epsent target object

func (AccountTarget) Account

func (c AccountTarget) Account() *Account

Account object

func (AccountTarget) AccountID

func (c AccountTarget) AccountID() uint64

AccountID of current target

func (AccountTarget) CommissionShareFactor

func (c AccountTarget) CommissionShareFactor() float64

CommissionShareFactor of current target

func (AccountTarget) ID

func (c AccountTarget) ID() uint64

ID of object (Zone OR SmartLink only)

func (AccountTarget) ProjectID

func (c AccountTarget) ProjectID() uint64

ProjectID number

func (AccountTarget) Size

func (c AccountTarget) Size() (w, h int)

Size default of target item

type AdFileAsset

type AdFileAsset struct {
	ID          uint64                `json:"id,omitempty"`
	Name        string                `json:"name,omitempty"` // Name of the asset, like "main", "banner", "icon", etc.
	URL         string                `json:"url,omitempty"`  // In case of HTML5, hare 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"`
	Thumbs      []AdFileAssetThumb
}

AdFileAsset information

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

func (assets AdFileAssets) Asset(name string) *AdFileAsset

Asset by name

func (AdFileAssets) AssetBanner

func (assets AdFileAssets) AssetBanner(w, h int) *AdFileAsset

AssetBanner by fixed size

func (AdFileAssets) Len

func (assets AdFileAssets) Len() int

Len of the assets list

func (AdFileAssets) Main

func (assets AdFileAssets) Main() *AdFileAsset

Main asset of the list

type AdFlag

type AdFlag uint8

AdFlag option state type

const (
	AdFlagIsPremium AdFlag = 0x01
	AdFlagActive    AdFlag = 0x02
	AdFlagInsecure  AdFlag = 0x04
	AdFlagAsPopover AdFlag = 0x08
)

Ad flag option types

func (AdFlag) IsActive

func (af AdFlag) IsActive() bool

func (AdFlag) IsInsecure

func (af AdFlag) IsInsecure() bool

func (AdFlag) IsPopover

func (af AdFlag) IsPopover() bool

func (AdFlag) IsPremium

func (af AdFlag) IsPremium() bool

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 CampaignFlagType

type CampaignFlagType uint8

CampaignFlagType type of the flags

const (
	CampaignFlagActive  CampaignFlagType = 1 << iota // 0x01
	CampaignFlagDeleted                              //
	CampaignFlagPrivate                              // Private campaigns not avalable for publick usage
	CampaignFlagPremium
	CampaignFlagHasWeighedAds
)

Flags set

func (CampaignFlagType) HasWeighedAds

func (f CampaignFlagType) HasWeighedAds() bool

func (CampaignFlagType) IsActive

func (f CampaignFlagType) IsActive() bool

func (CampaignFlagType) IsDeleted

func (f CampaignFlagType) IsDeleted() bool

func (CampaignFlagType) IsPremium

func (f CampaignFlagType) IsPremium() bool

func (CampaignFlagType) IsPrivate

func (f CampaignFlagType) IsPrivate() bool

type GeoBid

type GeoBid struct {
	Code [2]byte
	Bid  billing.Money
}

GeoBid item

func (*GeoBid) GeoLess

func (b *GeoBid) GeoLess(bid *GeoBid) bool

GeoLess campare

func (*GeoBid) GeoLessCode

func (b *GeoBid) GeoLessCode(code [2]byte) bool

GeoLessCode campare

type GeoBidSlice

type GeoBidSlice []GeoBid

GeoBidSlice type

func (GeoBidSlice) IndexOf

func (a GeoBidSlice) IndexOf(code [2]byte) int

IndexOf by country code (only for ordered)

func (GeoBidSlice) Len

func (a GeoBidSlice) Len() int

func (GeoBidSlice) Less

func (a GeoBidSlice) Less(i, j int) bool

func (GeoBidSlice) Swap

func (a GeoBidSlice) Swap(i, j int)

type NamedErrorWrapper

type NamedErrorWrapper struct {
	// contains filtered or unexported fields
}

NamedErrorWrapper type

func NewNamedErrorWrapper

func NewNamedErrorWrapper(name string, err error) NamedErrorWrapper

NewNamedErrorWrapper returns new error object

func (NamedErrorWrapper) Error

func (err NamedErrorWrapper) Error() string

func (NamedErrorWrapper) GetName

func (err NamedErrorWrapper) GetName() string

GetName of the error

func (NamedErrorWrapper) OriginalError

func (err NamedErrorWrapper) OriginalError() error

OriginalError of the wrapper

type Project

type Project struct {
	ID     uint64
	UserID uint64

	Balance  billing.Money
	MaxDaily billing.Money
	Spent    billing.Money

	RevenueShare float64 // From 0 to 1 -> 100%
}

Project model

func (*Project) CommissionShareFactor

func (p *Project) CommissionShareFactor() float64

CommissionShareFactor which system get from publisher 0..1

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  types.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 gosql.NullableJSON[any]
}

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

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 RTBSourceFlags

type RTBSourceFlags = models.RTBSourceFlags

type State

type State interface {
	Profit() billing.Money
	TotalProfit() billing.Money
	Spend() billing.Money
	TotalSpend() billing.Money
	TestSpend() billing.Money
	Imps() uint64
	Views() uint64
	Clicks() uint64
	Leads() uint64
}

type TrafficRouter

type TrafficRouter struct {
	ID uint64

	RTBSourceIDs []uint64

	// Percentage of traffic to be routed
	Percent float32

	Filter types.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) bool

Test checks if the target matches the filter criteria.

type User

type User struct {
	ID      uint64
	Balance int64
	Flags   uint64 // CanHaveNegativeBalance, IsSuperuser, Trusted
}

User model

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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