Skip to content

Commit

Permalink
[AUC-470] Equativ: Update bid type computation with Markup type
Browse files Browse the repository at this point in the history
  • Loading branch information
rneuplanche committed Nov 8, 2024
1 parent 106f6e4 commit 6b4e2d2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
25 changes: 13 additions & 12 deletions adapters/smartadserver/smartadserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (a *SmartAdserverAdapter) MakeBids(internalRequest *openrtb2.BidRequest, ex
bid := sb.Bid[i]
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: getMediaTypeForImp(bid.ImpID, internalRequest.Imp),
BidType: getBidTypeFromMarkupType(bid.MType),
})

}
Expand All @@ -172,16 +172,17 @@ func (a *SmartAdserverAdapter) BuildEndpointURL(params *openrtb_ext.ExtImpSmarta
return uri.String(), nil
}

func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType {
for _, imp := range imps {
if imp.ID == impID {
if imp.Video != nil {
return openrtb_ext.BidTypeVideo
} else if imp.Native != nil {
return openrtb_ext.BidTypeNative
}
return openrtb_ext.BidTypeBanner
}
func getBidTypeFromMarkupType(mtype openrtb2.MarkupType) openrtb_ext.BidType {
switch mtype {
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo
case openrtb2.MarkupAudio:
return openrtb_ext.BidTypeAudio
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative
default:
return openrtb_ext.BidTypeBanner
}
return openrtb_ext.BidTypeBanner
}
26 changes: 26 additions & 0 deletions adapters/smartadserver/smartadserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package smartadserver
import (
"testing"

"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v3/adapters/adapterstest"
"github.com/prebid/prebid-server/v3/config"
"github.com/prebid/prebid-server/v3/openrtb_ext"
"github.com/stretchr/testify/assert"
)

func TestJsonSamples(t *testing.T) {
Expand All @@ -18,3 +20,27 @@ func TestJsonSamples(t *testing.T) {

adapterstest.RunJSONBidderTest(t, "smartadservertest", bidder)
}

func TestGetBidTypeFromMarkupType_WhenBanner_ShouldReturnBanner(t *testing.T) {
mediaType := getBidTypeFromMarkupType(openrtb2.MarkupBanner)

assert.Equal(t, openrtb_ext.BidTypeBanner, mediaType)
}

func TestGetBidTypeFromMarkupType_WhenVideo_ShouldReturnVideo(t *testing.T) {
mediaType := getBidTypeFromMarkupType(openrtb2.MarkupVideo)

assert.Equal(t, openrtb_ext.BidTypeVideo, mediaType)
}

func TestGetBidTypeFromMarkupType_WhenAudio_ShouldReturnAudio(t *testing.T) {
mediaType := getBidTypeFromMarkupType(openrtb2.MarkupAudio)

assert.Equal(t, openrtb_ext.BidTypeAudio, mediaType)
}

func TestGetBidTypeFromMarkupType_WhenNative_ShouldReturnNative(t *testing.T) {
mediaType := getBidTypeFromMarkupType(openrtb2.MarkupNative)

assert.Equal(t, openrtb_ext.BidTypeNative, mediaType)
}

0 comments on commit 6b4e2d2

Please sign in to comment.