From a2001bdd202621e043c6be06d71597b27d30782b Mon Sep 17 00:00:00 2001 From: prasanth Date: Wed, 8 Nov 2023 12:20:16 -0500 Subject: [PATCH 1/5] Added support for specifying media type per impression --- adapters/yieldmo/yieldmo.go | 26 ++++++++++++------- .../yieldmotest/exemplary/app-banner.json | 12 +++++++-- .../yieldmotest/exemplary/app_video.json | 12 +++++++-- .../yieldmotest/exemplary/simple-banner.json | 12 +++++++-- .../yieldmotest/exemplary/simple_video.json | 12 +++++++-- .../yieldmotest/exemplary/with_gpid.json | 12 +++++++-- 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index 795d32b884..f0a80b9400 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -30,6 +30,10 @@ type Ext struct { Gpid string `json:"gpid,omitempty"` } +type ExtBid struct { + MediaType string `json:"mediatype,omitempty"` +} + func (a *YieldmoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var adapterRequests []*adapters.RequestData @@ -138,14 +142,18 @@ func (a *YieldmoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external for _, sb := range bidResp.SeatBid { for i := range sb.Bid { + bidType, err := getMediaTypeForImp(sb.Bid[i]) + if err != nil { + continue + } + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &sb.Bid[i], - BidType: getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp), + BidType: bidType, }) } } return bidResponse, nil - } // Builder builds a new instance of the Yieldmo adapter for the given bidder with the given config. @@ -156,12 +164,12 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co return bidder, nil } -func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { - //default to video unless banner exists in impression - for _, imp := range imps { - if imp.ID == impId && imp.Banner != nil { - return openrtb_ext.BidTypeBanner - } +// Retrieve the media type corresponding to the bid from the bid.ext object +func getMediaTypeForImp(bid openrtb2.Bid) (openrtb_ext.BidType, error) { + var bidExt ExtBid + if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + return "", &errortypes.BadInput{Message: err.Error()} } - return openrtb_ext.BidTypeVideo + + return openrtb_ext.ParseBidType(bidExt.MediaType) } diff --git a/adapters/yieldmo/yieldmotest/exemplary/app-banner.json b/adapters/yieldmo/yieldmotest/exemplary/app-banner.json index e674cf1153..92609cae16 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/app-banner.json +++ b/adapters/yieldmo/yieldmotest/exemplary/app-banner.json @@ -65,7 +65,11 @@ "adm": "some-test-ad", "crid": "crid_10", "h": 250, - "w": 300 + "w": 300, + "ext": + { + "mediatype": "banner" + } } ] } @@ -87,7 +91,11 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 300, - "h": 250 + "h": 250, + "ext": + { + "mediatype": "banner" + } }, "type": "banner" } diff --git a/adapters/yieldmo/yieldmotest/exemplary/app_video.json b/adapters/yieldmo/yieldmotest/exemplary/app_video.json index e33c37f69b..6f94a30b0d 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/app_video.json +++ b/adapters/yieldmo/yieldmotest/exemplary/app_video.json @@ -63,7 +63,11 @@ "adm": "some-test-ad", "crid": "crid_10", "h": 250, - "w": 300 + "w": 300, + "ext": + { + "mediatype": "video" + } } ] } @@ -85,7 +89,11 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 300, - "h": 250 + "h": 250, + "ext": + { + "mediatype": "video" + } }, "type": "video" } diff --git a/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json b/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json index 11739ca1d3..ba2435001c 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json +++ b/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json @@ -65,7 +65,11 @@ "adm": "some-test-ad", "crid": "crid_10", "h": 250, - "w": 300 + "w": 300, + "ext": + { + "mediatype": "banner" + } } ] } @@ -87,7 +91,11 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 300, - "h": 250 + "h": 250, + "ext": + { + "mediatype": "banner" + } }, "type": "banner" } diff --git a/adapters/yieldmo/yieldmotest/exemplary/simple_video.json b/adapters/yieldmo/yieldmotest/exemplary/simple_video.json index aaf5312436..ec65bc98b6 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/simple_video.json +++ b/adapters/yieldmo/yieldmotest/exemplary/simple_video.json @@ -63,7 +63,11 @@ "adm": "some-test-ad", "crid": "crid_10", "h": 250, - "w": 300 + "w": 300, + "ext": + { + "mediatype": "video" + } } ] } @@ -85,7 +89,11 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 300, - "h": 250 + "h": 250, + "ext": + { + "mediatype": "video" + } }, "type": "video" } diff --git a/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json b/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json index bd9e911058..d155f5db67 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json +++ b/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json @@ -73,7 +73,11 @@ "adm": "some-test-ad", "crid": "crid_10", "h": 250, - "w": 300 + "w": 300, + "ext": + { + "mediatype": "banner" + } } ] } @@ -95,7 +99,11 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 300, - "h": 250 + "h": 250, + "ext": + { + "mediatype": "banner" + } }, "type": "banner" } From 3aa6fc8f34a493df03c3745b98ee2894d28623a9 Mon Sep 17 00:00:00 2001 From: ym-prasanth <80693980+ym-prasanth@users.noreply.github.com> Date: Tue, 14 Nov 2023 09:27:50 -0500 Subject: [PATCH 2/5] AS-4133 Support media type per impression - Golang prebid server adapter (#1) From c68be34da03b61c81821da331a78434d4c2883a0 Mon Sep 17 00:00:00 2001 From: ym-prasanth <80693980+ym-prasanth@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:20:37 -0500 Subject: [PATCH 3/5] CR feedback. Return explicit bid type. (#2) --- adapters/yieldmo/yieldmo.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index f0a80b9400..69841e88a2 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -171,5 +171,14 @@ func getMediaTypeForImp(bid openrtb2.Bid) (openrtb_ext.BidType, error) { return "", &errortypes.BadInput{Message: err.Error()} } - return openrtb_ext.ParseBidType(bidExt.MediaType) + switch bidExt.MediaType { + case "banner": + return openrtb_ext.BidTypeBanner, nil + case "video": + return openrtb_ext.BidTypeVideo, nil + case "native": + return openrtb_ext.BidTypeNative, nil + default: + return "", fmt.Errorf("invalid BidType: %s", bidExt.MediaType) + } } From d49eaa208d85bb46d2d682733d6f428a8d7c5cba Mon Sep 17 00:00:00 2001 From: ym-prasanth <80693980+ym-prasanth@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:25:02 -0500 Subject: [PATCH 4/5] CR feedback 2. Set media type in the bid response (#3) --- adapters/yieldmo/yieldmo.go | 11 +++++++---- .../yieldmo/yieldmotest/exemplary/app-banner.json | 1 + adapters/yieldmo/yieldmotest/exemplary/app_video.json | 1 + .../yieldmo/yieldmotest/exemplary/simple-banner.json | 1 + .../yieldmo/yieldmotest/exemplary/simple_video.json | 1 + adapters/yieldmo/yieldmotest/exemplary/with_gpid.json | 1 + 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index 69841e88a2..e6156c49ce 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -142,7 +142,7 @@ func (a *YieldmoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external for _, sb := range bidResp.SeatBid { for i := range sb.Bid { - bidType, err := getMediaTypeForImp(sb.Bid[i]) + bidType, err := getMediaTypeForImp(&sb.Bid[i]) if err != nil { continue } @@ -164,8 +164,8 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co return bidder, nil } -// Retrieve the media type corresponding to the bid from the bid.ext object -func getMediaTypeForImp(bid openrtb2.Bid) (openrtb_ext.BidType, error) { +// Retrieve the media type corresponding to the bid from the bid.ext object and set it in the response +func getMediaTypeForImp(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { var bidExt ExtBid if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { return "", &errortypes.BadInput{Message: err.Error()} @@ -173,12 +173,15 @@ func getMediaTypeForImp(bid openrtb2.Bid) (openrtb_ext.BidType, error) { switch bidExt.MediaType { case "banner": + bid.MType = openrtb2.MarkupBanner return openrtb_ext.BidTypeBanner, nil case "video": + bid.MType = openrtb2.MarkupVideo return openrtb_ext.BidTypeVideo, nil case "native": + bid.MType = openrtb2.MarkupNative return openrtb_ext.BidTypeNative, nil default: - return "", fmt.Errorf("invalid BidType: %s", bidExt.MediaType) + return "", fmt.Errorf("invalid MediaType: %s", bidExt.MediaType) } } diff --git a/adapters/yieldmo/yieldmotest/exemplary/app-banner.json b/adapters/yieldmo/yieldmotest/exemplary/app-banner.json index 92609cae16..c7b25aab64 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/app-banner.json +++ b/adapters/yieldmo/yieldmotest/exemplary/app-banner.json @@ -92,6 +92,7 @@ "crid": "crid_10", "w": 300, "h": 250, + "mtype": 1, "ext": { "mediatype": "banner" diff --git a/adapters/yieldmo/yieldmotest/exemplary/app_video.json b/adapters/yieldmo/yieldmotest/exemplary/app_video.json index 6f94a30b0d..bba1e62ac3 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/app_video.json +++ b/adapters/yieldmo/yieldmotest/exemplary/app_video.json @@ -90,6 +90,7 @@ "crid": "crid_10", "w": 300, "h": 250, + "mtype": 2, "ext": { "mediatype": "video" diff --git a/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json b/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json index ba2435001c..c83f8f0c5f 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json +++ b/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json @@ -92,6 +92,7 @@ "crid": "crid_10", "w": 300, "h": 250, + "mtype": 1, "ext": { "mediatype": "banner" diff --git a/adapters/yieldmo/yieldmotest/exemplary/simple_video.json b/adapters/yieldmo/yieldmotest/exemplary/simple_video.json index ec65bc98b6..74cda7ea8f 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/simple_video.json +++ b/adapters/yieldmo/yieldmotest/exemplary/simple_video.json @@ -90,6 +90,7 @@ "crid": "crid_10", "w": 300, "h": 250, + "mtype": 2, "ext": { "mediatype": "video" diff --git a/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json b/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json index d155f5db67..ac4d8fa215 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json +++ b/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json @@ -100,6 +100,7 @@ "crid": "crid_10", "w": 300, "h": 250, + "mtype": 1, "ext": { "mediatype": "banner" From f3b4a5c9402390bcaca48c96592f0b1acfe63586 Mon Sep 17 00:00:00 2001 From: ym-prasanth <80693980+ym-prasanth@users.noreply.github.com> Date: Mon, 27 Nov 2023 09:32:27 -0500 Subject: [PATCH 5/5] Revert "CR feedback 2. Set media type in the bid response (#3)" (#4) This reverts commit d49eaa208d85bb46d2d682733d6f428a8d7c5cba. --- adapters/yieldmo/yieldmo.go | 11 ++++------- .../yieldmo/yieldmotest/exemplary/app-banner.json | 1 - adapters/yieldmo/yieldmotest/exemplary/app_video.json | 1 - .../yieldmo/yieldmotest/exemplary/simple-banner.json | 1 - .../yieldmo/yieldmotest/exemplary/simple_video.json | 1 - adapters/yieldmo/yieldmotest/exemplary/with_gpid.json | 1 - 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index e6156c49ce..69841e88a2 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -142,7 +142,7 @@ func (a *YieldmoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external for _, sb := range bidResp.SeatBid { for i := range sb.Bid { - bidType, err := getMediaTypeForImp(&sb.Bid[i]) + bidType, err := getMediaTypeForImp(sb.Bid[i]) if err != nil { continue } @@ -164,8 +164,8 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co return bidder, nil } -// Retrieve the media type corresponding to the bid from the bid.ext object and set it in the response -func getMediaTypeForImp(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { +// Retrieve the media type corresponding to the bid from the bid.ext object +func getMediaTypeForImp(bid openrtb2.Bid) (openrtb_ext.BidType, error) { var bidExt ExtBid if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { return "", &errortypes.BadInput{Message: err.Error()} @@ -173,15 +173,12 @@ func getMediaTypeForImp(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { switch bidExt.MediaType { case "banner": - bid.MType = openrtb2.MarkupBanner return openrtb_ext.BidTypeBanner, nil case "video": - bid.MType = openrtb2.MarkupVideo return openrtb_ext.BidTypeVideo, nil case "native": - bid.MType = openrtb2.MarkupNative return openrtb_ext.BidTypeNative, nil default: - return "", fmt.Errorf("invalid MediaType: %s", bidExt.MediaType) + return "", fmt.Errorf("invalid BidType: %s", bidExt.MediaType) } } diff --git a/adapters/yieldmo/yieldmotest/exemplary/app-banner.json b/adapters/yieldmo/yieldmotest/exemplary/app-banner.json index c7b25aab64..92609cae16 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/app-banner.json +++ b/adapters/yieldmo/yieldmotest/exemplary/app-banner.json @@ -92,7 +92,6 @@ "crid": "crid_10", "w": 300, "h": 250, - "mtype": 1, "ext": { "mediatype": "banner" diff --git a/adapters/yieldmo/yieldmotest/exemplary/app_video.json b/adapters/yieldmo/yieldmotest/exemplary/app_video.json index bba1e62ac3..6f94a30b0d 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/app_video.json +++ b/adapters/yieldmo/yieldmotest/exemplary/app_video.json @@ -90,7 +90,6 @@ "crid": "crid_10", "w": 300, "h": 250, - "mtype": 2, "ext": { "mediatype": "video" diff --git a/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json b/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json index c83f8f0c5f..ba2435001c 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json +++ b/adapters/yieldmo/yieldmotest/exemplary/simple-banner.json @@ -92,7 +92,6 @@ "crid": "crid_10", "w": 300, "h": 250, - "mtype": 1, "ext": { "mediatype": "banner" diff --git a/adapters/yieldmo/yieldmotest/exemplary/simple_video.json b/adapters/yieldmo/yieldmotest/exemplary/simple_video.json index 74cda7ea8f..ec65bc98b6 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/simple_video.json +++ b/adapters/yieldmo/yieldmotest/exemplary/simple_video.json @@ -90,7 +90,6 @@ "crid": "crid_10", "w": 300, "h": 250, - "mtype": 2, "ext": { "mediatype": "video" diff --git a/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json b/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json index ac4d8fa215..d155f5db67 100644 --- a/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json +++ b/adapters/yieldmo/yieldmotest/exemplary/with_gpid.json @@ -100,7 +100,6 @@ "crid": "crid_10", "w": 300, "h": 250, - "mtype": 1, "ext": { "mediatype": "banner"