Skip to content

Commit 9e99916

Browse files
committed
Add CWire video bid type handling
1 parent 843e62f commit 9e99916

3 files changed

Lines changed: 173 additions & 1 deletion

File tree

adapters/cwire/cwire.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,28 @@ func (a *adapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.Request
9191
bidderResponse.Currency = resp.Cur
9292
for _, sb := range resp.SeatBid {
9393
for i := range sb.Bid {
94+
bidType, err := getBidType(sb.Bid[i])
95+
if err != nil {
96+
return nil, []error{err}
97+
}
9498
bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{
9599
Bid: &sb.Bid[i],
96-
BidType: openrtb_ext.BidTypeBanner,
100+
BidType: bidType,
97101
})
98102
}
99103
}
100104

101105
return bidderResponse, nil
102106
}
107+
108+
func getBidType(bid openrtb2.Bid) (openrtb_ext.BidType, error) {
109+
// determinate media type by bid response field mtype
110+
switch bid.MType {
111+
case openrtb2.MarkupBanner:
112+
return openrtb_ext.BidTypeBanner, nil
113+
case openrtb2.MarkupVideo:
114+
return openrtb_ext.BidTypeVideo, nil
115+
}
116+
117+
return "", fmt.Errorf("could not define media type for C Wire impression: %s", bid.ImpID)
118+
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"mockBidRequest": {
3+
"id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22",
4+
"cur": [
5+
"CHF"
6+
],
7+
"imp": [
8+
{
9+
"id": "103",
10+
"video": {
11+
"mimes": [
12+
"video/mp4"
13+
],
14+
"protocols": [
15+
2,
16+
5
17+
],
18+
"w": 640,
19+
"h": 480
20+
},
21+
"ext": {
22+
"bidder": {
23+
"placementId": 15,
24+
"domainId": 42
25+
}
26+
}
27+
}
28+
],
29+
"site": {
30+
"page": "http://www.foobar.com/1234.html"
31+
},
32+
"device": {
33+
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:108.0) Gecko/20100101 Firefox/108.0"
34+
},
35+
"user": {
36+
"id": "55816b39711f9b5acf3b90e313ed29e51665623f",
37+
"geo": {
38+
"country": "ch",
39+
"region": "basel-stadt",
40+
"city": "basel"
41+
}
42+
}
43+
},
44+
"httpCalls": [
45+
{
46+
"expectedRequest": {
47+
"uri": "https://cwi.re/prebid/adapter-endpoint",
48+
"headers": {
49+
"Content-Type": [
50+
"application/json;charset=utf-8"
51+
],
52+
"Accept": [
53+
"application/json"
54+
]
55+
},
56+
"body": {
57+
"id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22",
58+
"cur": [
59+
"CHF"
60+
],
61+
"imp": [
62+
{
63+
"id": "103",
64+
"video": {
65+
"mimes": [
66+
"video/mp4"
67+
],
68+
"protocols": [
69+
2,
70+
5
71+
],
72+
"w": 640,
73+
"h": 480
74+
},
75+
"ext": {
76+
"bidder": {
77+
"placementId": 15,
78+
"domainId": 42
79+
}
80+
}
81+
}
82+
],
83+
"site": {
84+
"page": "http://www.foobar.com/1234.html"
85+
},
86+
"device": {
87+
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:108.0) Gecko/20100101 Firefox/108.0"
88+
},
89+
"user": {
90+
"id": "55816b39711f9b5acf3b90e313ed29e51665623f",
91+
"geo": {
92+
"country": "ch",
93+
"region": "basel-stadt",
94+
"city": "basel"
95+
}
96+
}
97+
},
98+
"impIDs": [
99+
"103"
100+
]
101+
},
102+
"mockResponse": {
103+
"status": 200,
104+
"headers": {},
105+
"body": {
106+
"id": "80ce30c53c16e6ede735f123ef6e32361bfc7b22",
107+
"cur": "CHF",
108+
"seatbid": [
109+
{
110+
"seat": "cwire",
111+
"group": 0,
112+
"bid": [
113+
{
114+
"id": "334",
115+
"impid": "103",
116+
"price": 8.00,
117+
"crid": "9999",
118+
"adm": "<VAST version=\"3.0\"></VAST>",
119+
"w": 640,
120+
"h": 480,
121+
"nurl": "https://embed.cwi.re/delivery/prebid-server/win/334",
122+
"mtype": 2
123+
}
124+
]
125+
}
126+
]
127+
}
128+
}
129+
}
130+
],
131+
"expectedBidResponses": [
132+
{
133+
"currency": "CHF",
134+
"bids": [
135+
{
136+
"bid": {
137+
"id": "334",
138+
"impid": "103",
139+
"price": 8.00,
140+
"crid": "9999",
141+
"adm": "<VAST version=\"3.0\"></VAST>",
142+
"w": 640,
143+
"h": 480,
144+
"nurl": "https://embed.cwi.re/delivery/prebid-server/win/334",
145+
"mtype": 2
146+
},
147+
"type": "video"
148+
}
149+
]
150+
}
151+
]
152+
}

static/bidder-info/cwire.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ capabilities:
88
app:
99
mediaTypes:
1010
- banner
11+
- video
1112
site:
1213
mediaTypes:
1314
- banner
15+
- video
16+
openrtb:
17+
multiformat-supported: false
1418
userSync:
1519
iframe:
1620
url: https://prebid.cwi.re/v1/usersync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&rd={{.RedirectURL}}

0 commit comments

Comments
 (0)