Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorix: add Server Region Support #1598

Merged
merged 1 commit into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/main/java/org/prebid/server/bidder/algorix/AlgorixBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class AlgorixBidder implements Bidder<BidRequest> {
new TypeReference<ExtPrebid<?, ExtImpAlgorix>>() {
};

private static final String URL_REGION_MACRO = "{HOST}";
private static final String URL_SID_MACRO = "{SID}";
private static final String URL_TOKEN_MACRO = "{TOKEN}";

Expand Down Expand Up @@ -132,6 +133,27 @@ private static boolean isValidSizeValue(Integer value) {
return value != null && value > 0;
}

/**
* get Region Info From Algorix Ext Imp
* Default For Global EP, APAC for apse EP, USE for use EP
*
* @param extImp Algorix Ext Imp
* @return Region String
*/
private static String getRegionInfo(ExtImpAlgorix extImp) {
if (Objects.isNull(extImp.getRegion())) {
return "xyz";
}
switch (extImp.getRegion()) {
case "APAC":
return "apac.xyz";
case "USE":
return "use.xyz";
default:
return "xyz";
}
}

/**
* Replace url macro
*
Expand All @@ -141,6 +163,7 @@ private static boolean isValidSizeValue(Integer value) {
*/
private static String resolveUrl(String endpoint, ExtImpAlgorix extImp) {
return endpoint
.replace(URL_REGION_MACRO, getRegionInfo(extImp))
.replace(URL_SID_MACRO, extImp.getSid())
.replace(URL_TOKEN_MACRO, extImp.getToken());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ public class ExtImpAlgorix {

@JsonProperty("appId")
String appId;

@JsonProperty("region")
String region;
}
2 changes: 1 addition & 1 deletion src/main/resources/bidder-config/algorix.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
adapters:
algorix:
endpoint: https://xyz.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN}
endpoint: https://{HOST}.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN}
meta-info:
maintainer-email: [email protected]
app-media-types:
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/static/bidder-params/algorix.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"appId": {
"type": "string",
"description": "An ID which identifies this app of the impression"
},
"region": {
"type": "string",
"description": "Server region for PBS request, null for global, APAC for SG Region, US for USE Region"
}
},
"required": ["sid", "token"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
public class AlgorixBidderTest extends VertxTest {

private static final String ENDPOINT_URL = "https://xyz.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN}";
private static final String ENDPOINT_URL = "https://{HOST}.svr-algorix.com/rtb/sa?sid={SID}&token={TOKEN}";

private AlgorixBidder algorixBidder;

Expand Down Expand Up @@ -99,7 +99,7 @@ public void makeHttpRequestsShouldCreateCorrectURL() {
assertThat(result.getValue())
.hasSize(1)
.extracting(HttpRequest::getUri)
.containsExactly("https://xyz.svr-algorix.com/rtb/sa?sid=testSid&token=testToken");
.containsExactly("https://apac.xyz.svr-algorix.com/rtb/sa?sid=testSid&token=testToken");
}

@Test
Expand Down Expand Up @@ -261,7 +261,7 @@ private static Imp givenImp(Function<Imp.ImpBuilder, Imp.ImpBuilder> impCustomiz
.id("123")
.banner(Banner.builder().id("banner_id").build())
.ext(mapper.valueToTree(ExtPrebid.of(null,
ExtImpAlgorix.of("testSid", "testToken", "testPlacementId", "testAppId")))))
ExtImpAlgorix.of("testSid", "testToken", "testPlacementId", "testAppId", "APAC")))))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"sid": "testSid",
"token": "testToken",
"placementId": "testPlacementId",
"appId": "testAppId"
"appId": "testAppId",
"region": "APAC"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"sid": "testSid",
"token": "testToken",
"placementId": "testPlacementId",
"appId": "testAppId"
"appId": "testAppId",
"region": "APAC"
}
}
}
Expand Down