Skip to content

Commit a51d0cf

Browse files
Merge pull request #1 from 33Across/XCH-2497_compatibility
Rename Bidder from 'ttx' to 'thirtythreeacross'
2 parents 4242290 + 80297ae commit a51d0cf

21 files changed

+168
-88
lines changed

src/main/java/org/prebid/server/bidder/ttx/TtxBidder.java renamed to src/main/java/org/prebid/server/bidder/thirtythreeacross/ThirtyThreeAcrossBidder.java

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.prebid.server.bidder.ttx;
1+
package org.prebid.server.bidder.thirtythreeacross;
22

33
import com.fasterxml.jackson.core.type.TypeReference;
44
import com.fasterxml.jackson.databind.JsonNode;
@@ -18,15 +18,19 @@
1818
import org.prebid.server.bidder.model.HttpCall;
1919
import org.prebid.server.bidder.model.HttpRequest;
2020
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;
2528
import org.prebid.server.exception.PreBidException;
2629
import org.prebid.server.json.DecodeException;
2730
import org.prebid.server.json.JacksonMapper;
2831
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;
3034
import org.prebid.server.proto.openrtb.ext.response.BidType;
3135
import org.prebid.server.util.HttpUtil;
3236

@@ -39,16 +43,16 @@
3943
import java.util.Objects;
4044
import java.util.stream.Collectors;
4145

42-
public class TtxBidder implements Bidder<BidRequest> {
46+
public class ThirtyThreeAcrossBidder implements Bidder<BidRequest> {
4347

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>>() {
4650
};
4751

4852
private final String endpointUrl;
4953
private final JacksonMapper mapper;
5054

51-
public TtxBidder(String endpointUrl, JacksonMapper mapper) {
55+
public ThirtyThreeAcrossBidder(String endpointUrl, JacksonMapper mapper) {
5256
this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl));
5357
this.mapper = Objects.requireNonNull(mapper);
5458
}
@@ -62,7 +66,7 @@ public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest request
6266
for (Imp imp : request.getImp()) {
6367
try {
6468
validateImp(imp);
65-
final ExtImpTtx extImpTtx = parseImpExt(imp);
69+
final ExtImpThirtyThreeAcross extImpTtx = parseImpExt(imp);
6670
final Imp updatedImp = updateImp(imp, extImpTtx);
6771
impsMap.computeIfAbsent(computeKey(updatedImp), k -> new ArrayList<>()).add(updatedImp);
6872
} catch (PreBidException e) {
@@ -84,15 +88,15 @@ private void validateImp(Imp imp) throws PreBidException {
8488
}
8589
}
8690

87-
private ExtImpTtx parseImpExt(Imp imp) throws PreBidException {
91+
private ExtImpThirtyThreeAcross parseImpExt(Imp imp) throws PreBidException {
8892
try {
8993
return mapper.mapper().convertValue(imp.getExt(), TTX_EXT_TYPE_REFERENCE).getBidder();
9094
} catch (IllegalArgumentException e) {
9195
throw new PreBidException(e.getMessage());
9296
}
9397
}
9498

95-
private Imp updateImp(Imp imp, ExtImpTtx extImpTtx) throws PreBidException {
99+
private Imp updateImp(Imp imp, ExtImpThirtyThreeAcross extImpTtx) throws PreBidException {
96100
final String productId = extImpTtx.getProductId();
97101
return imp.toBuilder()
98102
.video(updatedVideo(imp.getVideo(), productId))
@@ -144,14 +148,29 @@ private static Integer resolvePlacement(Integer videoPlacement, String productId
144148
}
145149

146150
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));
149153
return mapper.mapper().valueToTree(ttxImpExt);
150154
}
151155

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+
152170
private HttpRequest<BidRequest> createRequest(BidRequest request, List<Imp> requestImps) {
153171
final BidRequest modifiedRequest = request.toBuilder()
154172
.imp(requestImps)
173+
.ext(createReqExt())
155174
.build();
156175

157176
return HttpRequest.<BidRequest>builder()
@@ -190,17 +209,17 @@ private List<BidderBid> bidsFromResponse(BidResponse bidResponse) {
190209
.collect(Collectors.toList());
191210
}
192211

193-
private BidType getBidType(Bid
194-
bid) {
212+
private BidType getBidType(Bid bid) {
195213
try {
196-
final TtxBidExt ttxBidExt = mapper.mapper().convertValue(bid.getExt(), TtxBidExt.class);
214+
final ThirtyThreeAcrossBidExt ttxBidExt =
215+
mapper.mapper().convertValue(bid.getExt(), ThirtyThreeAcrossBidExt.class);
197216
return ttxBidExt != null ? getBidTypeByTtx(ttxBidExt.getTtx()) : BidType.banner;
198217
} catch (IllegalArgumentException e) {
199218
return BidType.banner;
200219
}
201220
}
202221

203-
private static BidType getBidTypeByTtx(TtxBidExtTtx bidExt) {
222+
private static BidType getBidTypeByTtx(ThirtyThreeAcrossBidExtTtx bidExt) {
204223
return bidExt != null && Objects.equals(bidExt.getMediaType(), "video")
205224
? BidType.video
206225
: BidType.banner;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.prebid.server.bidder.thirtythreeacross.proto;
2+
3+
import lombok.NoArgsConstructor;
4+
import lombok.Value;
5+
6+
@NoArgsConstructor(staticName = "of")
7+
@Value
8+
public class ThirtyThreeAcrossCaller {
9+
10+
final String name = "Prebid-Server-Java";
11+
final String version = "N/A";
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.prebid.server.bidder.thirtythreeacross.proto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Value;
5+
6+
@AllArgsConstructor(staticName = "of")
7+
@Value
8+
public class ThirtyThreeAcrossImpExt {
9+
10+
ThirtyThreeAcrossImpExtTtx ttx;
11+
}

src/main/java/org/prebid/server/bidder/ttx/proto/TtxImpExtTtx.java renamed to src/main/java/org/prebid/server/bidder/thirtythreeacross/proto/ThirtyThreeAcrossImpExtTtx.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package org.prebid.server.bidder.ttx.proto;
1+
package org.prebid.server.bidder.thirtythreeacross.proto;
22

33
import lombok.AllArgsConstructor;
44
import lombok.Value;
55

66
@AllArgsConstructor(staticName = "of")
77
@Value
8-
public class TtxImpExtTtx {
8+
public class ThirtyThreeAcrossImpExtTtx {
99

1010
String prod;
1111

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.prebid.server.bidder.thirtythreeacross.proto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Value;
5+
6+
@AllArgsConstructor(staticName = "of")
7+
@Value
8+
public class ThirtyThreeAcrossReqExt {
9+
10+
ThirtyThreeAcrossReqExtTtx ttx;
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.prebid.server.bidder.thirtythreeacross.proto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Value;
5+
6+
import java.util.List;
7+
8+
@AllArgsConstructor(staticName = "of")
9+
@Value
10+
public class ThirtyThreeAcrossReqExtTtx {
11+
12+
List<ThirtyThreeAcrossCaller> caller;
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.prebid.server.bidder.thirtythreeacross.response;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Value;
5+
6+
@AllArgsConstructor(staticName = "of")
7+
@Value
8+
public class ThirtyThreeAcrossBidExt {
9+
10+
ThirtyThreeAcrossBidExtTtx ttx;
11+
}

src/main/java/org/prebid/server/bidder/ttx/response/TtxBidExtTtx.java renamed to src/main/java/org/prebid/server/bidder/thirtythreeacross/response/ThirtyThreeAcrossBidExtTtx.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.prebid.server.bidder.ttx.response;
1+
package org.prebid.server.bidder.thirtythreeacross.response;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
44
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -7,7 +7,7 @@
77

88
@AllArgsConstructor(staticName = "of")
99
@Value
10-
public class TtxBidExtTtx {
10+
public class ThirtyThreeAcrossBidExtTtx {
1111

1212
@JsonProperty("mediaType")
1313
@JsonInclude(JsonInclude.Include.NON_EMPTY)

src/main/java/org/prebid/server/bidder/ttx/proto/TtxImpExt.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/org/prebid/server/bidder/ttx/response/TtxBidExt.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/org/prebid/server/proto/openrtb/ext/request/ttx/ExtImpTtx.java renamed to src/main/java/org/prebid/server/proto/openrtb/ext/request/thirtythreeacross/ExtImpThirtyThreeAcross.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.prebid.server.proto.openrtb.ext.request.ttx;
1+
package org.prebid.server.proto.openrtb.ext.request.thirtythreeacross;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import lombok.AllArgsConstructor;
@@ -9,7 +9,7 @@
99
*/
1010
@AllArgsConstructor(staticName = "of")
1111
@Value
12-
public class ExtImpTtx {
12+
public class ExtImpThirtyThreeAcross {
1313

1414
@JsonProperty("siteId")
1515
String siteId;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.prebid.server.spring.config.bidder;
22

33
import org.prebid.server.bidder.BidderDeps;
4-
import org.prebid.server.bidder.ttx.TtxBidder;
4+
import org.prebid.server.bidder.thirtythreeacross.ThirtyThreeAcrossBidder;
55
import org.prebid.server.json.JacksonMapper;
66
import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties;
77
import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler;
@@ -16,26 +16,26 @@
1616
import javax.validation.constraints.NotBlank;
1717

1818
@Configuration
19-
@PropertySource(value = "classpath:/bidder-config/ttx.yaml", factory = YamlPropertySourceFactory.class)
20-
public class TtxConfiguration {
19+
@PropertySource(value = "classpath:/bidder-config/thirtythreeacross.yaml", factory = YamlPropertySourceFactory.class)
20+
public class ThirtyThreeAcrossConfiguration {
2121

22-
private static final String BIDDER_NAME = "ttx";
22+
private static final String BIDDER_NAME = "thirtythreeacross";
2323

24-
@Bean("ttxConfigurationProperties")
25-
@ConfigurationProperties("adapters.ttx")
24+
@Bean("thirtythreeacrossConfigurationProperties")
25+
@ConfigurationProperties("adapters.thirtythreeacross")
2626
BidderConfigurationProperties configurationProperties() {
2727
return new BidderConfigurationProperties();
2828
}
2929

3030
@Bean
31-
BidderDeps ttxBidderDeps(BidderConfigurationProperties ttxConfigurationProperties,
31+
BidderDeps thirtythreeacrossBidderDeps(BidderConfigurationProperties thirtythreeacrossConfigurationProperties,
3232
@NotBlank @Value("${external-url}") String externalUrl,
3333
JacksonMapper mapper) {
3434

3535
return BidderDepsAssembler.forBidder(BIDDER_NAME)
36-
.withConfig(ttxConfigurationProperties)
36+
.withConfig(thirtythreeacrossConfigurationProperties)
3737
.usersyncerCreator(UsersyncerCreator.create(externalUrl))
38-
.bidderCreator(config -> new TtxBidder(config.getEndpoint(), mapper))
38+
.bidderCreator(config -> new ThirtyThreeAcrossBidder(config.getEndpoint(), mapper))
3939
.assemble();
4040
}
4141
}

src/main/resources/bidder-config/ttx.yaml renamed to src/main/resources/bidder-config/thirtythreeacross.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
adapters:
2-
ttx:
2+
thirtythreeacross:
33
endpoint: https://ssc.33across.com/api/v1/s2s
44
aliases:
55
'33across':

0 commit comments

Comments
 (0)