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

mf multi-format test #63

Merged
merged 1 commit into from
Sep 12, 2024
Merged
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
14 changes: 14 additions & 0 deletions adapters/mobilefuse/mobilefuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"text/template"

"github.com/buger/jsonparser"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
Expand All @@ -27,6 +28,10 @@ type BidExt struct {
Mf ExtMf `json:"mf"`
}

type ContextData struct {
MspPlacementId []string `json:"msp_placement_id,omitempty"`
}

// Builder builds a new instance of the MobileFuse adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) {
template, err := template.New("endpointTemplate").Parse(config.Endpoint)
Expand Down Expand Up @@ -115,6 +120,15 @@ func (adapter *MobileFuseAdapter) makeRequest(bidRequest *openrtb2.BidRequest) (
return nil, errs
}

if result, dataType, _, err := jsonparser.Get(bidRequest.Imp[0].Ext, "context", "data"); err == nil && dataType == jsonparser.Object {
var ctx ContextData
err := json.Unmarshal(result, &ctx)
if err == nil && len(ctx.MspPlacementId) > 0 && ctx.MspPlacementId[0] == "msp-android-article-inside-display-prod3" {
validImps[0].Banner = &openrtb2.Banner{Format: validImps[0].Banner.Format, API: validImps[0].Banner.API}
validImps[0].Banner.Format = append(validImps[0].Banner.Format, openrtb2.Format{W: 320, H: 50})
}
}

mobileFuseBidRequest := *bidRequest
mobileFuseBidRequest.Imp = validImps
body, err := json.Marshal(mobileFuseBidRequest)
Expand Down
Loading