Skip to content

Commit f65eb5b

Browse files
karimMourradanielbaud
authored andcommitted
Connatix: Copy entire imp[i].ext (prebid#4521)
1 parent 176bb22 commit f65eb5b

File tree

3 files changed

+205
-10
lines changed

3 files changed

+205
-10
lines changed

adapters/connatix/connatix.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,20 @@ func buildRequestImp(imp *openrtb2.Imp, ext impExtIncoming, displayManagerVer st
222222
imp.BidFloor = convertedValue
223223
}
224224

225-
impExt := impExt{
226-
Connatix: impExtConnatix{
227-
PlacementId: ext.Bidder.PlacementId,
228-
ViewabilityPercentage: ext.Bidder.ViewabilityPercentage,
229-
},
225+
var incomingExt map[string]interface{}
226+
if err := jsonutil.Unmarshal(imp.Ext, &incomingExt); err != nil {
227+
incomingExt = make(map[string]interface{})
228+
}
229+
230+
delete(incomingExt, "bidder")
231+
232+
incomingExt["connatix"] = impExtConnatix{
233+
PlacementId: ext.Bidder.PlacementId,
234+
ViewabilityPercentage: ext.Bidder.ViewabilityPercentage,
230235
}
231236

232237
var err error
233-
imp.Ext, err = json.Marshal(impExt)
238+
imp.Ext, err = json.Marshal(incomingExt)
234239

235240
return err
236241
}
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
{
2+
"mockBidRequest": {
3+
"id": "some-request-id",
4+
"device": {
5+
"ua": "test-user-agent",
6+
"ip": "123.123.123.123",
7+
"language": "en",
8+
"dnt": 0
9+
},
10+
"tmax": 500,
11+
"user": {
12+
"buyeruid": "1-some-user"
13+
},
14+
"app": {
15+
"publisher": {
16+
"id": "123456789"
17+
},
18+
"cat": [
19+
"IAB22-1"
20+
],
21+
"bundle": "com.app.awesome",
22+
"name": "Awesome App",
23+
"domain": "awesomeapp.com",
24+
"id": "123456789",
25+
"ext": {
26+
"prebid": {
27+
"source": "test",
28+
"version": "1.0.0"
29+
}
30+
}
31+
},
32+
"imp": [
33+
{
34+
"id": "some-imp-id",
35+
"tagid": "some-tag-id",
36+
"banner": {
37+
"format":[
38+
{
39+
"w": 320,
40+
"h": 50
41+
}
42+
]
43+
},
44+
"ext": {
45+
"bidder": {
46+
"placementId": "some-placement-id",
47+
"viewabilityPercentage": 0.6
48+
},
49+
"random": {
50+
"data_a": {
51+
"data_1": "data_1"
52+
},
53+
"data_b": {
54+
"data_2": "data_2"
55+
}
56+
},
57+
"gpid": "test-gpid"
58+
}
59+
}
60+
]
61+
},
62+
"httpCalls": [
63+
{
64+
"expectedRequest": {
65+
"uri": "http://example.com?dc=us-east-2",
66+
"body": {
67+
"id": "some-request-id",
68+
"device": {
69+
"ua": "test-user-agent",
70+
"ip": "123.123.123.123",
71+
"language": "en",
72+
"dnt": 0
73+
},
74+
"imp": [
75+
{
76+
"id": "some-imp-id",
77+
"tagid": "some-tag-id",
78+
"banner": {
79+
"w": 320,
80+
"h": 50,
81+
"format": [
82+
{
83+
"w": 320,
84+
"h": 50
85+
}
86+
]
87+
},
88+
"displaymanagerver": "test-1.0.0",
89+
"ext": {
90+
"connatix": {
91+
"placementId": "some-placement-id",
92+
"viewabilityPercentage": 0.6
93+
},
94+
"random": {
95+
"data_a": {
96+
"data_1": "data_1"
97+
},
98+
"data_b": {
99+
"data_2": "data_2"
100+
}
101+
},
102+
"gpid": "test-gpid"
103+
}
104+
}
105+
],
106+
"app": {
107+
"id": "123456789",
108+
"name": "Awesome App",
109+
"bundle": "com.app.awesome",
110+
"domain": "awesomeapp.com",
111+
"cat": [
112+
"IAB22-1"
113+
],
114+
"publisher": {
115+
"id": "123456789"
116+
},
117+
"ext": {
118+
"prebid": {
119+
"source": "test",
120+
"version": "1.0.0"
121+
}
122+
}
123+
},
124+
"user": {
125+
"buyeruid": "1-some-user"
126+
},
127+
"tmax": 500
128+
},
129+
"impIDs": [
130+
"some-imp-id"
131+
]
132+
},
133+
"mockResponse": {
134+
"status": 200,
135+
"body": {
136+
"id": "test-response-id",
137+
"seatbid": [
138+
{
139+
"bid": [
140+
{
141+
"id": "some-bid-id",
142+
"impid": "some-imp-id",
143+
"price": 0.52,
144+
"adm": "some-test-ad",
145+
"adomain": [
146+
"test.com"
147+
],
148+
"crid": "112233",
149+
"w": 320,
150+
"h": 50,
151+
"ext": {
152+
"connatix": {
153+
"mediaType": "banner"
154+
}
155+
}
156+
}
157+
],
158+
"seat": "connatix",
159+
"group": 0
160+
}
161+
],
162+
"cur": "USD"
163+
}
164+
}
165+
}
166+
],
167+
"expectedBidResponses": [
168+
{
169+
"currency": "USD",
170+
"bids": [
171+
{
172+
"bid": {
173+
"id": "some-bid-id",
174+
"impid": "some-imp-id",
175+
"price": 0.52,
176+
"adm": "some-test-ad",
177+
"crid": "112233",
178+
"adomain": [
179+
"test.com"
180+
],
181+
"w": 320,
182+
"h": 50,
183+
"ext": {
184+
"connatix": {
185+
"mediaType": "banner"
186+
}
187+
}
188+
},
189+
"type": "banner"
190+
}
191+
]
192+
}
193+
]
194+
}

adapters/connatix/models.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type impExtIncoming struct {
1212
Bidder openrtb_ext.ExtImpConnatix `json:"bidder"`
1313
}
1414

15-
type impExt struct {
16-
Connatix impExtConnatix `json:"connatix"`
17-
}
18-
1915
type impExtConnatix struct {
2016
PlacementId string `json:"placementId,omitempty"`
2117
ViewabilityPercentage float64 `json:"viewabilityPercentage,omitempty"`

0 commit comments

Comments
 (0)