Skip to content

Commit

Permalink
iqzone get media type from mtype bid property (#3557)
Browse files Browse the repository at this point in the history
  • Loading branch information
IQZoneAdx committed Mar 7, 2024
1 parent aff3608 commit e2a9806
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
29 changes: 11 additions & 18 deletions adapters/iqzone/iqzone.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
bidResponse.Currency = response.Cur
for _, seatBid := range response.SeatBid {
for i := range seatBid.Bid {
bidType, err := getMediaTypeForImp(seatBid.Bid[i].ImpID, request.Imp)
bidType, err := getBidMediaType(&seatBid.Bid[i])
if err != nil {
return nil, []error{err}
}
Expand All @@ -126,22 +126,15 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
return bidResponse, nil
}

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
}
if imp.Banner == nil && imp.Video != nil {
return openrtb_ext.BidTypeVideo, nil
}
if imp.Banner == nil && imp.Video == nil && imp.Native != nil {
return openrtb_ext.BidTypeNative, nil
}
}
}

return "", &errortypes.BadInput{
Message: fmt.Sprintf("Failed to find impression \"%s\"", impID),
func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", fmt.Errorf("Unable to fetch mediaType in multi-format: %s", bid.ImpID)
}
}
2 changes: 2 additions & 0 deletions adapters/iqzone/iqzonetest/exemplary/endpointId.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"dealid": "test_dealid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down Expand Up @@ -119,6 +120,7 @@
"dealid": "test_dealid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down
2 changes: 2 additions & 0 deletions adapters/iqzone/iqzonetest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"dealid": "test_dealid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down Expand Up @@ -119,6 +120,7 @@
"dealid": "test_dealid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down
4 changes: 3 additions & 1 deletion adapters/iqzone/iqzonetest/exemplary/simple-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"dealid": "test_dealid",
"w": 300,
"h": 250,
"mtype": 4,
"ext": {
"prebid": {
"type": "native"
Expand Down Expand Up @@ -107,7 +108,8 @@
"prebid": {
"type": "native"
}
}
},
"mtype": 4
},
"type": "native"
}
Expand Down
2 changes: 2 additions & 0 deletions adapters/iqzone/iqzonetest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"mtype": 2,
"ext": {
"prebid": {
"type": "video"
Expand Down Expand Up @@ -114,6 +115,7 @@
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"mtype": 2,
"ext": {
"prebid": {
"type": "video"
Expand Down
2 changes: 2 additions & 0 deletions adapters/iqzone/iqzonetest/exemplary/simple-web-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"dealid": "test_dealid",
"w": 468,
"h": 60,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down Expand Up @@ -119,6 +120,7 @@
"dealid": "test_dealid",
"w": 468,
"h": 60,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}],
"expectedMakeBidsErrors": [
{
"value": "Failed to find impression \"test-imp-id\"",
"value": "Unable to fetch mediaType in multi-format: test-imp-id",
"comparison": "literal"
}
]
Expand Down

0 comments on commit e2a9806

Please sign in to comment.