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

Adf: banner and video media type support added #1841

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
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
31 changes: 27 additions & 4 deletions adapters/adf/adf.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,38 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R

bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))
bidResponse.Currency = response.Cur

var errors []error
for _, seatBid := range response.SeatBid {
for i := range seatBid.Bid {
for i, bid := range seatBid.Bid {
bidType, err := getMediaTypeForImp(bid.ImpID, request.Imp)
if err != nil {
errors = append(errors, err)
continue
}
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &seatBid.Bid[i],
BidType: openrtb_ext.BidTypeNative,
BidType: bidType,
})
}
}

return bidResponse, nil
return bidResponse, errors
}

func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
for _, imp := range imps {
if imp.ID == impID {
if imp.Banner != nil {
return openrtb_ext.BidTypeBanner, nil
} else if imp.Video != nil {
return openrtb_ext.BidTypeVideo, nil
} else if imp.Native != nil {
return openrtb_ext.BidTypeNative, nil
}
}
}

return "", &errortypes.BadInput{
Message: fmt.Sprintf("Failed to find supported impression \"%s\" mediatype", impID),
}
}
118 changes: 118 additions & 0 deletions adapters/adf/adftest/exemplary/multi-format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [{
"id": "test-imp-id-1",
"ext": {
"bidder": {
"mid": "828782"
}
},
"video": {
"mimes": [
"video/mp4"
],
"placement": 1
}
}, {
"id": "test-imp-id-2",
"ext": {
"bidder": {
"mid": "828783"
}
},
"banner": {
"format": [{
"w": 300,
"h": 250
}]
}
}]
},
"httpCalls": [{
"expectedRequest": {
"uri": "https://adx.adform.net/adx/openrtb",
"body": {
"id": "test-request-id",
"imp": [{
"id": "test-imp-id-1",
"ext": {
"bidder": {
"mid": "828782"
}
},
"video": {
"mimes": [
"video/mp4"
],
"placement": 1
},
"tagid": "828782"
}, {
"id": "test-imp-id-2",
"ext": {
"bidder": {
"mid": "828783"
}
},
"banner": {
"format": [{
"w": 300,
"h": 250
}]
},
"tagid": "828783"
}]
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [{
"bid": [{
"id": "test-bid-id-1",
"impid": "test-imp-id-1",
"price": 10,
"adm": "{video xml}",
"adomain": [],
"crid": "test-creative-id-1"
}]
}, {
"bid": [{
"id": "test-bid-id-2",
"impid": "test-imp-id-2",
"price": 2,
"adm": "{banner html}",
"adomain": [ "ad-domain" ],
"crid": "test-creative-id-2"
}]
}],
"cur": "EUR"
}
}
}],
"expectedBidResponses": [{
"currency": "EUR",
"bids": [{
"bid": {
"id": "test-bid-id-1",
"impid": "test-imp-id-1",
"price": 10,
"adm": "{video xml}",
"crid": "test-creative-id-1"
},
"type": "video"
}, {
"bid": {
"id": "test-bid-id-2",
"impid": "test-imp-id-2",
"price": 2,
"adm": "{banner html}",
"adomain": [ "ad-domain" ],
"crid": "test-creative-id-2"
},
"type": "banner"
}]
}]
}
95 changes: 95 additions & 0 deletions adapters/adf/adftest/exemplary/single-banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [{
"id": "test-imp-id",
"ext": {
"bidder": {
"mid": "828782"
}
},
"banner": {
"format": [{
"w": 300,
"h": 250
}]
}
}],
"site": {
"publisher": {
"id": "1"
},
"page": "some-page-url"
},
"device": {
"w": 1920,
"h": 800
}
},
"httpCalls": [{
"expectedRequest": {
"uri": "https://adx.adform.net/adx/openrtb",
"body": {
"id": "test-request-id",
"imp": [{
"id": "test-imp-id",
"ext": {
"bidder": {
"mid": "828782"
}
},
"banner": {
"format": [{
"w": 300,
"h": 250
}]
},
"tagid": "828782"
}],
"site": {
"publisher": {
"id": "1"
},
"page": "some-page-url"
},
"device": {
"w": 1920,
"h": 800
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [{
"bid": [{
"id": "test-bid-id",
"impid": "test-imp-id",
"price": 10,
"adm": "{banner html}",
"adomain": [ "test.com" ],
"crid": "test-creative-id"
}]
}],
"cur": "USD"
}
}
}],
"expectedBidResponses": [{
"currency": "USD",
"bids": [
{
"bid": {
"id": "test-bid-id",
"impid": "test-imp-id",
"price": 10,
"adm": "{banner html}",
"crid": "test-creative-id",
"adomain": [ "test.com" ]
},
"type": "banner"
}
]
}]
}
93 changes: 93 additions & 0 deletions adapters/adf/adftest/exemplary/single-video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [{
"id": "test-imp-id",
"ext": {
"bidder": {
"mid": "828782"
}
},
"video": {
"mimes": [
"video/mp4"
],
"placement": 1
}
}],
"site": {
"publisher": {
"id": "1"
},
"page": "some-page-url"
},
"device": {
"w": 1920,
"h": 800
}
},
"httpCalls": [{
"expectedRequest": {
"uri": "https://adx.adform.net/adx/openrtb",
"body": {
"id": "test-request-id",
"imp": [{
"id": "test-imp-id",
"ext": {
"bidder": {
"mid": "828782"
}
},
"video": {
"mimes": [
"video/mp4"
],
"placement": 1
},
"tagid": "828782"
}],
"site": {
"publisher": {
"id": "1"
},
"page": "some-page-url"
},
"device": {
"w": 1920,
"h": 800
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [{
"bid": [{
"id": "test-bid-id",
"impid": "test-imp-id",
"price": 10,
"adm": "{vast xml}",
"crid": "test-creative-id"
}]
}],
"cur": "USD"
}
}
}],
"expectedBidResponses": [{
"currency": "USD",
"bids": [
{
"bid": {
"id": "test-bid-id",
"impid": "test-imp-id",
"price": 10,
"adm": "{vast xml}",
"crid": "test-creative-id"
},
"type": "video"
}
]
}]
}
Loading