-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbid.go
62 lines (55 loc) · 2.06 KB
/
bid.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
package gortb
import (
"errors"
)
// Validation errors for Bid
var (
ErrMissingBidID = errors.New("bid missing required ID")
ErrMissingImpID = errors.New("bid missing required impression ID")
ErrInvalidPrice = errors.New("bid price must be greater than 0")
)
type Bid struct {
ID string `json:"id" binding:"required"`
ImpID string `json:"impid" binding:"required"`
Price float64 `json:"price" binding:"required"`
NURL string `json:"nurl,omitempty"`
BURL string `json:"burl,omitempty"`
LURL string `json:"lurl,omitempty"`
AdM string `json:"adm,omitempty"`
AdID string `json:"adid,omitempty"`
ADomain []string `json:"adomain,omitempty"`
Bundle string `json:"bundle,omitempty"`
IURL string `json:"iurl,omitempty"`
CID string `json:"cid,omitempty"`
CRID string `json:"crid,omitempty"`
Tactic string `json:"tactic,omitempty"`
Cat []string `json:"cat,omitempty"`
Attr []int `json:"attr,omitempty"`
API int `json:"api,omitempty"`
Protocol int `json:"protocol,omitempty"`
QAGMediaRating int `json:"qagmediarating,omitempty"`
Language string `json:"language,omitempty"`
DealID string `json:"dealid,omitempty"`
W int `json:"w,omitempty"`
H int `json:"h,omitempty"`
WRatio int `json:"wratio,omitempty"`
HRatio int `json:"hratio,omitempty"`
Exp int `json:"exp,omitempty"`
Ext interface{} `json:"ext,omitempty"`
}
// Validate performs validation on the Bid object according to OpenRTB 2.5 rules
func (b *Bid) Validate() error {
// Check required ID field
if b.ID == "" {
return ErrMissingBidID
}
// Check required impression ID field
if b.ImpID == "" {
return ErrMissingImpID
}
// Check required price field
if b.Price <= 0 {
return ErrInvalidPrice
}
return nil
}