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

Pubmatic: Bidder Updates #3652

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

AntoxaAntoxic
Copy link
Collaborator

🔧 Type of changes

  • new bid adapter
  • bid adapter update
  • new feature
  • new analytics adapter
  • new module
  • module update
  • bugfix
  • documentation
  • configuration
  • dependency update
  • tech debt (test coverage, refactorings, etc.)

✨ What's the context?

What's the context for the changes?

🧠 Rationale behind the change

Why did you choose to make these changes? Were there any trade-offs you had to consider?

🔎 New Bid Adapter Checklist

  • verify email contact works
  • NO fully dynamic hostnames
  • geographic host parameters are NOT required
  • direct use of HTTP is prohibited - implement an existing Bidder interface that will do all the job
  • if the ORTB is just forwarded to the endpoint, use the generic adapter - define the new adapter as the alias of the generic adapter
  • cover an adapter configuration with an integration test

🧪 Test plan

How do you know the changes are safe to ship to production?

🏎 Quality check

  • Are your changes following our code style guidelines?
  • Are there any breaking changes in your code?
  • Does your test coverage exceed 90%?
  • Are there any erroneous console logs, debuggers or leftover code in your changes?

Comment on lines +133 to +155
private Pair<String, String> extractDisplayManagerFields(BidRequest request) {
final Optional<ExtApp> optionalExtApp = Optional.ofNullable(request.getApp())
.map(App::getExt);

return optionalExtApp.map(ExtApp::getPrebid)
.filter(extAppPrebid -> StringUtils.isNoneBlank(extAppPrebid.getSource(), extAppPrebid.getVersion()))
.map(extAppPrebid -> Pair.of(extAppPrebid.getSource(), extAppPrebid.getVersion()))
.or(() -> optionalExtApp
.filter(extApp -> StringUtils.isNoneBlank(
getPropertyValue(extApp, "source"),
getPropertyValue(extApp, "version")))
.map(extApp -> Pair.of(
extApp.getProperty("source").asText(),
extApp.getProperty("version").asText())))
.orElse(Pair.of(null, null));
}

private static String getPropertyValue(FlexibleExtension flexibleExtension, String propertyName) {
return Optional.ofNullable(flexibleExtension.getProperty(propertyName))
.filter(JsonNode::isValueNode)
.map(JsonNode::asText)
.orElse(null);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sims to ugly for me XD
What about this approach?

    private Pair<String, String> extractDisplayManagerFields(App app) {
        String source;
        String version;

        final ExtApp extApp = app != null ? app.getExt() : null;
        final ExtAppPrebid extAppPrebid = extApp != null ? extApp.getPrebid() : null;

        source = extAppPrebid != null ? extAppPrebid.getSource() : null;
        version = extAppPrebid != null ? extAppPrebid.getVersion() : null;
        if (StringUtils.isNoneBlank(source, version)) {
            return Pair.of(source, version);
        }

        source = getPropertyValue(extApp, "source");
        version = getPropertyValue(extApp, "version");
        return StringUtils.isNoneBlank(source, version)
                ? Pair.of(source, version)
                : Pair.of(null, null);
    }

    private static String getPropertyValue(FlexibleExtension flexibleExtension, String propertyName) {
        return Optional.ofNullable(flexibleExtension)
                .map(ext -> ext.getProperty(propertyName))
                .filter(JsonNode::isValueNode)
                .map(JsonNode::asText)
                .orElse(null);
    }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please, place methods in call order.

Comment on lines +234 to +239
.displaymanager(StringUtils.isBlank(imp.getDisplaymanager())
? displayManager
: imp.getDisplaymanager())
.displaymanagerver(StringUtils.isBlank(imp.getDisplaymanagerver())
? displayManagerVersion
: imp.getDisplaymanagerver())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                .displaymanager(StringUtils.firstNonBlank(imp.getDisplaymanager(), displayManager))
                .displaymanagerver(StringUtils.firstNonBlank(imp.getDisplaymanagerver(), displayManagerVersion))

Comment on lines +476 to +482
final ExtRequest extRequestWithoutPrebid = extRequest != null
? mapper.fillExtension(ExtRequest.empty(), extRequest.getProperties())
: ExtRequest.empty();

return extNode.isEmpty()
? extRequest
: mapper.fillExtension(extRequest == null ? ExtRequest.empty() : extRequest, extNode);
? extRequestWithoutPrebid
: mapper.fillExtension(extRequestWithoutPrebid, extNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wanna duplicate logic from GO:

        final ExtRequest newExtRequest = ExtRequest.empty();
        return extNode.isEmpty()
                ? newExtRequest
                : mapper.fillExtension(newExtRequest, extNode);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants