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

Equativ: SmartAdserver alias with update to use mtype #4045

Merged
merged 9 commits into from
Dec 10, 2024
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"price": 0.500000,
"adm": "some-test-ad",
"crid": "crid_10",
"mtype": 1,
"h": 90,
"w": 728
}]
Expand Down Expand Up @@ -127,6 +128,7 @@
"price": 0.800000,
"adm": "some-test-ad",
"crid": "crid_11",
"mtype": 1,
"h": 150,
"w": 300
}]
Expand All @@ -149,6 +151,7 @@
"price": 0.5,
"adm": "some-test-ad",
"crid": "crid_10",
"mtype": 1,
"w": 728,
"h": 90
},
Expand All @@ -166,6 +169,7 @@
"price": 0.8,
"adm": "some-test-ad",
"crid": "crid_11",
"mtype": 1,
"w": 300,
"h": 150
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
{
"mockBidRequest": {
"id": "test-request-multi-id",
"imp": [
{
"id": "test-imp-id-1",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
1
],
"w": 1024,
"h": 576
},
"ext": {
"bidder": {
"siteId": 1,
"pageId": 2,
"formatId": 3,
"networkId": 73
}
}
},
{
"id": "test-imp-id-2",
"banner": {
"format": [
{
"w": 300,
"h": 150
}
]
},
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
1
],
"w": 920,
"h": 200
},
"ext": {
"bidder": {
"siteId": 1,
"pageId": 2,
"formatId": 4,
"networkId": 73
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://ssb.smartadserver.com/api/bid?callerId=5",
"body": {
"id": "test-request-multi-id",
"imp": [
{
"id": "test-imp-id-1",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
1
],
"w": 1024,
"h": 576
},
"ext": {
"bidder": {
"siteId": 1,
"pageId": 2,
"formatId": 3,
"networkId": 73
}
}
}
],
"site": {
"publisher": {
"id": "73"
}
}
},
"impIDs": [
"test-imp-id-1"
]
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-multi-id",
"seatbid": [
{
"seat": "smartadserver",
"bid": [
{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id-1",
"price": 0.500000,
"adm": "some-test-ad",
"crid": "crid_10",
"mtype": 1,
"w": 728,
"h": 90
}
]
}
],
"cur": "USD"
}
}
},
{
"expectedRequest": {
"uri": "https://ssb.smartadserver.com/api/bid?callerId=5",
"body": {
"id": "test-request-multi-id",
"imp": [
{
"id": "test-imp-id-2",
"banner": {
"format": [
{
"w": 300,
"h": 150
}
]
},
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
1
],
"w": 920,
"h": 200
},
"ext": {
"bidder": {
"siteId": 1,
"pageId": 2,
"formatId": 4,
"networkId": 73
}
}
}
],
"site": {
"publisher": {
"id": "73"
}
}
},
"impIDs": [
"test-imp-id-2"
]
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-multi-id",
"seatbid": [
{
"seat": "smartadserver",
"bid": [
{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e801",
"impid": "test-imp-id-2",
"price": 0.800000,
"adm": "some-test-ad",
"crid": "crid_11",
"mtype": 2,
"w": 920,
"h": 200
}
]
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id-1",
"price": 0.5,
"adm": "some-test-ad",
"crid": "crid_10",
"mtype": 1,
"w": 728,
"h": 90
},
"type": "banner"
}
]
},
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e801",
"impid": "test-imp-id-2",
"price": 0.8,
"adm": "some-test-ad",
"crid": "crid_11",
"mtype": 2,
"w": 920,
"h": 200
},
"type": "video"
}
]
}
]
}
Loading
Loading