1
- package org .prebid .server .bidder .ttx ;
1
+ package org .prebid .server .bidder .thirtythreeacross ;
2
2
3
3
import com .fasterxml .jackson .core .type .TypeReference ;
4
4
import com .fasterxml .jackson .databind .JsonNode ;
18
18
import org .prebid .server .bidder .model .HttpCall ;
19
19
import org .prebid .server .bidder .model .HttpRequest ;
20
20
import org .prebid .server .bidder .model .Result ;
21
- import org .prebid .server .bidder .ttx .proto .TtxImpExt ;
22
- import org .prebid .server .bidder .ttx .proto .TtxImpExtTtx ;
23
- import org .prebid .server .bidder .ttx .response .TtxBidExt ;
24
- import org .prebid .server .bidder .ttx .response .TtxBidExtTtx ;
21
+ import org .prebid .server .bidder .thirtythreeacross .proto .ThirtyThreeAcrossCaller ;
22
+ import org .prebid .server .bidder .thirtythreeacross .proto .ThirtyThreeAcrossImpExt ;
23
+ import org .prebid .server .bidder .thirtythreeacross .proto .ThirtyThreeAcrossImpExtTtx ;
24
+ import org .prebid .server .bidder .thirtythreeacross .proto .ThirtyThreeAcrossReqExt ;
25
+ import org .prebid .server .bidder .thirtythreeacross .proto .ThirtyThreeAcrossReqExtTtx ;
26
+ import org .prebid .server .bidder .thirtythreeacross .response .ThirtyThreeAcrossBidExt ;
27
+ import org .prebid .server .bidder .thirtythreeacross .response .ThirtyThreeAcrossBidExtTtx ;
25
28
import org .prebid .server .exception .PreBidException ;
26
29
import org .prebid .server .json .DecodeException ;
27
30
import org .prebid .server .json .JacksonMapper ;
28
31
import org .prebid .server .proto .openrtb .ext .ExtPrebid ;
29
- import org .prebid .server .proto .openrtb .ext .request .ttx .ExtImpTtx ;
32
+ import org .prebid .server .proto .openrtb .ext .request .ExtRequest ;
33
+ import org .prebid .server .proto .openrtb .ext .request .thirtythreeacross .ExtImpThirtyThreeAcross ;
30
34
import org .prebid .server .proto .openrtb .ext .response .BidType ;
31
35
import org .prebid .server .util .HttpUtil ;
32
36
39
43
import java .util .Objects ;
40
44
import java .util .stream .Collectors ;
41
45
42
- public class TtxBidder implements Bidder <BidRequest > {
46
+ public class ThirtyThreeAcrossBidder implements Bidder <BidRequest > {
43
47
44
- private static final TypeReference <ExtPrebid <?, ExtImpTtx >> TTX_EXT_TYPE_REFERENCE =
45
- new TypeReference <ExtPrebid <?, ExtImpTtx >>() {
48
+ private static final TypeReference <ExtPrebid <?, ExtImpThirtyThreeAcross >> TTX_EXT_TYPE_REFERENCE =
49
+ new TypeReference <ExtPrebid <?, ExtImpThirtyThreeAcross >>() {
46
50
};
47
51
48
52
private final String endpointUrl ;
49
53
private final JacksonMapper mapper ;
50
54
51
- public TtxBidder (String endpointUrl , JacksonMapper mapper ) {
55
+ public ThirtyThreeAcrossBidder (String endpointUrl , JacksonMapper mapper ) {
52
56
this .endpointUrl = HttpUtil .validateUrl (Objects .requireNonNull (endpointUrl ));
53
57
this .mapper = Objects .requireNonNull (mapper );
54
58
}
@@ -62,7 +66,7 @@ public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest request
62
66
for (Imp imp : request .getImp ()) {
63
67
try {
64
68
validateImp (imp );
65
- final ExtImpTtx extImpTtx = parseImpExt (imp );
69
+ final ExtImpThirtyThreeAcross extImpTtx = parseImpExt (imp );
66
70
final Imp updatedImp = updateImp (imp , extImpTtx );
67
71
impsMap .computeIfAbsent (computeKey (updatedImp ), k -> new ArrayList <>()).add (updatedImp );
68
72
} catch (PreBidException e ) {
@@ -84,15 +88,15 @@ private void validateImp(Imp imp) throws PreBidException {
84
88
}
85
89
}
86
90
87
- private ExtImpTtx parseImpExt (Imp imp ) throws PreBidException {
91
+ private ExtImpThirtyThreeAcross parseImpExt (Imp imp ) throws PreBidException {
88
92
try {
89
93
return mapper .mapper ().convertValue (imp .getExt (), TTX_EXT_TYPE_REFERENCE ).getBidder ();
90
94
} catch (IllegalArgumentException e ) {
91
95
throw new PreBidException (e .getMessage ());
92
96
}
93
97
}
94
98
95
- private Imp updateImp (Imp imp , ExtImpTtx extImpTtx ) throws PreBidException {
99
+ private Imp updateImp (Imp imp , ExtImpThirtyThreeAcross extImpTtx ) throws PreBidException {
96
100
final String productId = extImpTtx .getProductId ();
97
101
return imp .toBuilder ()
98
102
.video (updatedVideo (imp .getVideo (), productId ))
@@ -144,14 +148,29 @@ private static Integer resolvePlacement(Integer videoPlacement, String productId
144
148
}
145
149
146
150
private ObjectNode createImpExt (String productId , String zoneId , String siteId ) {
147
- final TtxImpExt ttxImpExt = TtxImpExt .of (
148
- TtxImpExtTtx .of (productId , StringUtils .isNotEmpty (zoneId ) ? zoneId : siteId ));
151
+ final ThirtyThreeAcrossImpExt ttxImpExt = ThirtyThreeAcrossImpExt .of (
152
+ ThirtyThreeAcrossImpExtTtx .of (productId , StringUtils .isNotEmpty (zoneId ) ? zoneId : siteId ));
149
153
return mapper .mapper ().valueToTree (ttxImpExt );
150
154
}
151
155
156
+ private ExtRequest createReqExt () {
157
+ final List <ThirtyThreeAcrossCaller > ttxCaller = new ArrayList <>();
158
+ ttxCaller .add (ThirtyThreeAcrossCaller .of ());
159
+
160
+ final ExtRequest ttxReqExt = mapper .fillExtension (
161
+ ExtRequest .empty (),
162
+ ThirtyThreeAcrossReqExt .of (
163
+ ThirtyThreeAcrossReqExtTtx .of (ttxCaller )
164
+ )
165
+ );
166
+
167
+ return ttxReqExt ;
168
+ }
169
+
152
170
private HttpRequest <BidRequest > createRequest (BidRequest request , List <Imp > requestImps ) {
153
171
final BidRequest modifiedRequest = request .toBuilder ()
154
172
.imp (requestImps )
173
+ .ext (createReqExt ())
155
174
.build ();
156
175
157
176
return HttpRequest .<BidRequest >builder ()
@@ -190,17 +209,17 @@ private List<BidderBid> bidsFromResponse(BidResponse bidResponse) {
190
209
.collect (Collectors .toList ());
191
210
}
192
211
193
- private BidType getBidType (Bid
194
- bid ) {
212
+ private BidType getBidType (Bid bid ) {
195
213
try {
196
- final TtxBidExt ttxBidExt = mapper .mapper ().convertValue (bid .getExt (), TtxBidExt .class );
214
+ final ThirtyThreeAcrossBidExt ttxBidExt =
215
+ mapper .mapper ().convertValue (bid .getExt (), ThirtyThreeAcrossBidExt .class );
197
216
return ttxBidExt != null ? getBidTypeByTtx (ttxBidExt .getTtx ()) : BidType .banner ;
198
217
} catch (IllegalArgumentException e ) {
199
218
return BidType .banner ;
200
219
}
201
220
}
202
221
203
- private static BidType getBidTypeByTtx (TtxBidExtTtx bidExt ) {
222
+ private static BidType getBidTypeByTtx (ThirtyThreeAcrossBidExtTtx bidExt ) {
204
223
return bidExt != null && Objects .equals (bidExt .getMediaType (), "video" )
205
224
? BidType .video
206
225
: BidType .banner ;
0 commit comments