Skip to content

Commit

Permalink
imds: Break out endpoint generation into new method and remove Object…
Browse files Browse the repository at this point in the history
…s.requireNonNull() that was added by IDE eroneously.
  • Loading branch information
Timothy M. Ace committed Jun 30, 2023
1 parent 9b635b4 commit f6e837f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/main/java/org/prebid/server/bidder/imds/ImdsBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ImdsBidder implements Bidder<BidRequest> {

public ImdsBidder(String endpointUrl, PrebidVersionProvider prebidVersionProvider, JacksonMapper mapper) {
this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl));
this.prebidVersion = Objects.requireNonNull(prebidVersionProvider.getNameVersionRecord());
this.prebidVersion = prebidVersionProvider.getNameVersionRecord();
this.mapper = Objects.requireNonNull(mapper);
}

Expand Down Expand Up @@ -83,16 +83,24 @@ public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest bidRequ
.ext(mapper.fillExtension(ExtRequest.empty(), ExtRequestImds.of(firstExtImp.getSeatId())))
.build();

return Result.of(Collections.singletonList(
return Result.of(
Collections.singletonList(
BidderUtil.defaultRequest(
outgoingRequest,
endpointUrl
.replaceAll("\\{\\{AccountID}}",
URLEncoder.encode(firstExtImp.getSeatId(), StandardCharsets.UTF_8))
.replaceAll("\\{\\{SourceId}}",
URLEncoder.encode(prebidVersion, StandardCharsets.UTF_8)),
mapper)),
errors);
outgoingRequest,
generateEndpointUrl(firstExtImp),
mapper
)
),
errors
);
}

private String generateEndpointUrl(ExtImpImds firstExtImp) {
String accountId = URLEncoder.encode(firstExtImp.getSeatId(), StandardCharsets.UTF_8);
String sourceId = URLEncoder.encode(prebidVersion, StandardCharsets.UTF_8);
return endpointUrl
.replaceAll("\\{\\{AccountID}}", accountId)
.replaceAll("\\{\\{SourceId}}", sourceId);
}

private ExtImpImds parseAndValidateExtImp(ObjectNode impExt) {
Expand Down

0 comments on commit f6e837f

Please sign in to comment.