Skip to content

Commit e02a53a

Browse files
xdevelrgushellinux019
authored
Displayio: Add audio and native support (prebid#4728)
Co-authored-by: Roman G <46111871+rgushel@users.noreply.github.com> Co-authored-by: linux019 <anode.dev@gmail.com>
1 parent 10a021b commit e02a53a

5 files changed

Lines changed: 244 additions & 4 deletions

File tree

adapters/displayio/displayio.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (adapter *adapter) MakeBids(internalRequest *openrtb2.BidRequest, _ *adapte
130130
var bidResp openrtb2.BidResponse
131131

132132
if err := jsonutil.Unmarshal(responseData.Body, &bidResp); err != nil {
133-
msg := fmt.Sprintf("Bad server response: %d", err)
133+
msg := fmt.Sprintf("Bad server response: %v", err)
134134
return nil, []error{&errortypes.BadServerResponse{Message: msg}}
135135
}
136136

@@ -178,8 +178,14 @@ func getBidMediaTypeFromMtype(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
178178
return openrtb_ext.BidTypeBanner, nil
179179
case openrtb2.MarkupVideo:
180180
return openrtb_ext.BidTypeVideo, nil
181+
case openrtb2.MarkupAudio:
182+
return openrtb_ext.BidTypeAudio, nil
183+
case openrtb2.MarkupNative:
184+
return openrtb_ext.BidTypeNative, nil
181185
default:
182-
return "", fmt.Errorf("unexpected media type for bid: %s", bid.ImpID)
186+
return "", &errortypes.BadServerResponse{
187+
Message: fmt.Sprintf("unsupported MType %d", bid.MType),
188+
}
183189
}
184190
}
185191

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"mockBidRequest": {
3+
"app": {
4+
"id": "1011"
5+
},
6+
"id": "requestId10111011101110111011",
7+
"imp": [
8+
{
9+
"audio": {
10+
"mimes": [
11+
"audio/mpeg"
12+
]
13+
},
14+
"bidfloor": 0.5,
15+
"bidfloorcur": "USD",
16+
"id": "impId10111011101110111011",
17+
"ext": {
18+
"bidder": {
19+
"placementId": "1011",
20+
"publisherId": "101",
21+
"inventoryId": "1011"
22+
}
23+
}
24+
}
25+
]
26+
},
27+
"httpCalls": [
28+
{
29+
"expectedRequest": {
30+
"uri": "https://adapter.endpoint/?macro=101",
31+
"body": {
32+
"app": {
33+
"id": "1011"
34+
},
35+
"id": "requestId10111011101110111011",
36+
"imp": [
37+
{
38+
"audio": {
39+
"mimes": [
40+
"audio/mpeg"
41+
]
42+
},
43+
"bidfloor": 0.5,
44+
"bidfloorcur": "USD",
45+
"id": "impId10111011101110111011",
46+
"ext": {
47+
"bidder": {
48+
"placementId": "1011",
49+
"publisherId": "101",
50+
"inventoryId": "1011"
51+
}
52+
}
53+
}
54+
],
55+
"ext": {
56+
"displayio": {
57+
"placementId": "1011",
58+
"inventoryId": "1011"
59+
}
60+
}
61+
},
62+
"impIDs": [
63+
"impId10111011101110111011"
64+
]
65+
},
66+
"mockResponse": {
67+
"status": 200,
68+
"body": {
69+
"id": "requestId10111011101110111011",
70+
"seatbid": [
71+
{
72+
"bid": [
73+
{
74+
"id": "12345",
75+
"impid": "impId10111011101110111011",
76+
"price": 2,
77+
"adm": "<?xml/>",
78+
"adid": "12235",
79+
"adomain": [
80+
"domain.test"
81+
],
82+
"mtype": 3
83+
}
84+
],
85+
"seat": "displayio123",
86+
"group": 1
87+
}
88+
],
89+
"bidid": "test123",
90+
"cur": "USD"
91+
}
92+
}
93+
}
94+
],
95+
"expectedBidResponses": [
96+
{
97+
"currency": "USD",
98+
"bids": [
99+
{
100+
"bid": {
101+
"id": "12345",
102+
"impid": "impId10111011101110111011",
103+
"price": 2,
104+
"adm": "<?xml/>",
105+
"adid": "12235",
106+
"adomain": [
107+
"domain.test"
108+
],
109+
"mtype": 3
110+
},
111+
"type": "audio"
112+
}
113+
]
114+
}
115+
]
116+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
{
2+
"mockBidRequest": {
3+
"app": {
4+
"id": "1011"
5+
},
6+
"id": "requestId10111011101110111011",
7+
"imp": [
8+
{
9+
"native": {
10+
"request": "{\"ver\":\"1.1\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":50}},{\"id\":2,\"required\":0,\"data\":{\"type\":2,\"len\":100}},{\"id\":3,\"required\":1,\"img\":{\"type\":3,\"w\":480,\"h\":320}}]}",
11+
"ver": "1.1"
12+
},
13+
"bidfloor": 0.5,
14+
"bidfloorcur": "USD",
15+
"id": "impId10111011101110111011",
16+
"ext": {
17+
"bidder": {
18+
"placementId": "1011",
19+
"publisherId": "101",
20+
"inventoryId": "1011"
21+
}
22+
}
23+
}
24+
]
25+
},
26+
"httpCalls": [
27+
{
28+
"expectedRequest": {
29+
"uri": "https://adapter.endpoint/?macro=101",
30+
"body": {
31+
"app": {
32+
"id": "1011"
33+
},
34+
"id": "requestId10111011101110111011",
35+
"imp": [
36+
{
37+
"native": {
38+
"request": "{\"ver\":\"1.1\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":50}},{\"id\":2,\"required\":0,\"data\":{\"type\":2,\"len\":100}},{\"id\":3,\"required\":1,\"img\":{\"type\":3,\"w\":480,\"h\":320}}]}",
39+
"ver": "1.1"
40+
},
41+
"bidfloor": 0.5,
42+
"bidfloorcur": "USD",
43+
"id": "impId10111011101110111011",
44+
"ext": {
45+
"bidder": {
46+
"placementId": "1011",
47+
"publisherId": "101",
48+
"inventoryId": "1011"
49+
}
50+
}
51+
}
52+
],
53+
"ext": {
54+
"displayio": {
55+
"placementId": "1011",
56+
"inventoryId": "1011"
57+
}
58+
}
59+
},
60+
"impIDs": [
61+
"impId10111011101110111011"
62+
]
63+
},
64+
"mockResponse": {
65+
"status": 200,
66+
"body": {
67+
"id": "requestId10111011101110111011",
68+
"seatbid": [
69+
{
70+
"bid": [
71+
{
72+
"id": "12345",
73+
"impid": "impId10111011101110111011",
74+
"price": 2,
75+
"adm": "{}",
76+
"adid": "12235",
77+
"adomain": [
78+
"domain.test"
79+
],
80+
"mtype": 4
81+
}
82+
],
83+
"seat": "displayio123",
84+
"group": 1
85+
}
86+
],
87+
"bidid": "test123",
88+
"cur": "USD"
89+
}
90+
}
91+
}
92+
],
93+
"expectedBidResponses": [
94+
{
95+
"currency": "USD",
96+
"bids": [
97+
{
98+
"bid": {
99+
"id": "12345",
100+
"impid": "impId10111011101110111011",
101+
"price": 2,
102+
"adm": "{}",
103+
"adid": "12235",
104+
"adomain": [
105+
"domain.test"
106+
],
107+
"mtype": 4
108+
},
109+
"type": "native"
110+
}
111+
]
112+
}
113+
]
114+
}

adapters/displayio/displayiotest/supplemental/unexpected-media-type.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
],
9999
"expectedMakeBidsErrors": [
100100
{
101-
"value": "unexpected media type for bid: .*",
101+
"value": "unsupported MType .*",
102102
"comparison": "regex"
103103
}
104104
]

static/bidder-info/displayio.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ capabilities:
1010
mediaTypes:
1111
- banner
1212
- video
13+
- audio
14+
- native
1315
site:
1416
mediaTypes:
1517
- banner
16-
- video
18+
- video
19+
- audio
20+
- native

0 commit comments

Comments
 (0)