-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_rtb_options.go
68 lines (57 loc) · 1.56 KB
/
request_rtb_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package adsourceopenrtb
import (
"time"
"github.com/geniusrabbit/adcorelib/admodels/types"
)
// BidRequestRTBOptions of request build
type BidRequestRTBOptions struct {
OpenNative struct {
Ver string
}
FormatFilter func(f *types.Format) bool
Currency []string
TimeMax time.Duration
AuctionType types.AuctionType
BidFloor float64
}
func (opts *BidRequestRTBOptions) openNativeVer() string {
return opts.OpenNative.Ver
}
func (opts *BidRequestRTBOptions) currencies() []string {
if len(opts.Currency) > 0 {
return opts.Currency
}
return []string{"USD"}
}
// BidRequestRTBOption set function
type BidRequestRTBOption func(opts *BidRequestRTBOptions)
// WithRTBOpenNativeVersion set version
func WithRTBOpenNativeVersion(ver string) BidRequestRTBOption {
return func(opts *BidRequestRTBOptions) {
opts.OpenNative.Ver = ver
}
}
// WithFormatFilter set custom method
func WithFormatFilter(f func(f *types.Format) bool) BidRequestRTBOption {
return func(opts *BidRequestRTBOptions) {
opts.FormatFilter = f
}
}
// WithMaxTimeDuration of the request
func WithMaxTimeDuration(duration time.Duration) BidRequestRTBOption {
return func(opts *BidRequestRTBOptions) {
opts.TimeMax = duration
}
}
// WithAuctionType set type of auction
func WithAuctionType(auction types.AuctionType) BidRequestRTBOption {
return func(opts *BidRequestRTBOptions) {
opts.AuctionType = auction
}
}
// WithBidFloor set minimal bid value
func WithBidFloor(bidFloor float64) BidRequestRTBOption {
return func(opts *BidRequestRTBOptions) {
opts.BidFloor = max(bidFloor, 0)
}
}