Skip to content

Commit eff725f

Browse files
author
softcoder594
committed
optable-targeting: Code cleanup
1 parent c91eea7 commit eff725f

6 files changed

Lines changed: 16 additions & 17 deletions

File tree

extra/modules/optable-targeting/src/main/java/org/prebid/server/hooks/modules/optable/targeting/model/config/OptableTargetingProperties.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public final class OptableTargetingProperties {
1717
@JsonProperty("api-key")
1818
String apiKey;
1919

20-
@JsonProperty("user-id")
21-
String userId;
20+
String tenant;
2221

2322
String origin;
2423

extra/modules/optable-targeting/src/main/java/org/prebid/server/hooks/modules/optable/targeting/v1/core/EndpointResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
public class EndpointResolver {
44

5-
private static final String ACCOUNT_ID = "{ACCOUNT_ID}";
5+
private static final String TENANT = "{TENANT}";
66

77
private static final String ORIGIN = "{ORIGIN}";
88

99
private EndpointResolver() {
1010
}
1111

12-
public static String resolve(String endpointTemplate, String accountId, String origin) {
13-
return endpointTemplate.replace(ACCOUNT_ID, accountId)
12+
public static String resolve(String endpointTemplate, String tenant, String origin) {
13+
return endpointTemplate.replace(TENANT, tenant)
1414
.replace(ORIGIN, origin);
1515
}
1616
}

extra/modules/optable-targeting/src/main/java/org/prebid/server/hooks/modules/optable/targeting/v1/core/OptableTargeting.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public Future<TargetingResult> getTargeting(OptableTargetingProperties propertie
4343
? getOrFetchTargetingResults(
4444
properties.getCache(),
4545
properties.getApiKey(),
46-
properties.getUserId(),
46+
properties.getTenant(),
4747
properties.getOrigin(),
4848
query,
4949
attributes.getIps(), timeout)
5050
: apiClient.getTargeting(
5151
properties.getApiKey(),
52-
properties.getUserId(),
52+
properties.getTenant(),
5353
properties.getOrigin(),
5454
query,
5555
attributes.getIps(),
@@ -58,24 +58,24 @@ public Future<TargetingResult> getTargeting(OptableTargetingProperties propertie
5858
}
5959

6060
private Future<TargetingResult> getOrFetchTargetingResults(CacheProperties cacheProperties, String apiKey,
61-
String accountId, String origin,
61+
String tenant, String origin,
6262
String query, List<String> ips, long timeout) {
6363

64-
final String key = accountId + ":" +URLEncoder.encode(query, StandardCharsets.UTF_8);
64+
final String key = tenant + ":" +URLEncoder.encode(query, StandardCharsets.UTF_8);
6565

6666
return cache.get(key)
6767
.recover(err -> Future.succeededFuture(null))
6868
.compose(entry -> entry != null
6969
? Future.succeededFuture(entry)
70-
: fetchAndCacheResult(accountId, origin, cacheProperties.getTtlseconds(), apiKey,
70+
: fetchAndCacheResult(tenant, origin, cacheProperties.getTtlseconds(), apiKey,
7171
query, ips, timeout));
7272

7373
}
7474

75-
private Future<TargetingResult> fetchAndCacheResult(String accountId, String origin, int ttlSeconds, String apiKey,
75+
private Future<TargetingResult> fetchAndCacheResult(String tenant, String origin, int ttlSeconds, String apiKey,
7676
String query, List<String> ips, long timeout) {
7777

78-
return apiClient.getTargeting(apiKey, accountId, origin, query, ips, timeout)
79-
.compose(result -> cache.put(accountId + ":" + query, result, ttlSeconds).map(result));
78+
return apiClient.getTargeting(apiKey, tenant, origin, query, ips, timeout)
79+
.compose(result -> cache.put(tenant + ":" + query, result, ttlSeconds).map(result));
8080
}
8181
}

extra/modules/optable-targeting/src/main/java/org/prebid/server/hooks/modules/optable/targeting/v1/net/APIClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public APIClient(String endpoint,
5151
this.responseMapper = Objects.requireNonNull(responseMapper);
5252
}
5353

54-
public Future<TargetingResult> getTargeting(String apiKey, String accountId, String origin,
54+
public Future<TargetingResult> getTargeting(String apiKey, String tenant, String origin,
5555
String query, List<String> ips, long timeout) {
5656

5757
final MultiMap headers = HeadersMultiMap.headers()
@@ -68,7 +68,7 @@ public Future<TargetingResult> getTargeting(String apiKey, String accountId, Str
6868
}
6969

7070
final HttpRequest request = HttpRequest.builder()
71-
.uri(EndpointResolver.resolve(endpoint, accountId, origin))
71+
.uri(EndpointResolver.resolve(endpoint, tenant, origin))
7272
.query(query)
7373
.headers(headers)
7474
.build();

sample/configs/prebid-config-with-optable.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ hooks:
5050
enabled: true
5151
modules:
5252
optable-targeting:
53-
api-endpoint: https://na.edge.optable.co/v2/targeting?t={ACCOUNT_ID}&o={ORIGIN}
53+
api-endpoint: https://na.edge.optable.co/v2/targeting?t={TENANT}&o={ORIGIN}

sample/configs/sample-app-settings-optable.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ accounts:
1919
modules:
2020
optable-targeting:
2121
api-key: key
22-
user-id: optable
22+
tenant: optable
2323
origin: web-sdk-demo
2424
ppid-mapping: { "pubcid.org": "c" }
2525
adserver-targeting: true

0 commit comments

Comments
 (0)