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

New Adapter: IQX #3164

Merged
merged 7 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 15 additions & 12 deletions adapters/iqx/iqx.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,9 @@ func prepareBidResponse(seats []openrtb2.SeatBid) (*adapters.BidderResponse, []e

for _, seatBid := range seats {
for bidId, bid := range seatBid.Bid {
var bidExt bidExt
if err := json.Unmarshal(bid.Ext, &bidExt); err != nil {
errs = append(errs, &errortypes.BadServerResponse{
Message: fmt.Sprintf("Failed to parse Bid[%d].Ext: %s", bidId, err.Error()),
})
continue
}

bidType, err := openrtb_ext.ParseBidType(bidExt.Prebid.Type)
bidType, err := getMediaTypeForBid(bid)
if err != nil {
errs = append(errs, &errortypes.BadServerResponse{
Message: fmt.Sprintf("Bid[%d].Ext.Prebid.Type expects one of the following values: 'banner', 'native', 'video', got '%s'", bidId, bidExt.Prebid.Type),
})
errs = append(errs, err)
continue
}

Expand All @@ -159,3 +149,16 @@ func prepareBidResponse(seats []openrtb2.SeatBid) (*adapters.BidderResponse, []e

return bidResponse, errs
}

func getMediaTypeForBid(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("failed to parse bid mType for impression \"%s\"", bid.ImpID)
Copy link
Contributor

@onkarvhanumante onkarvhanumante Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if bid.ImpID is 2 then this will result in "failed to parse bid mType for impression \"2\". From this error message it is unclear whether 2 is mType value or index from imp array. How about refactoring error message to - failed to parse bid mtype for impression id \"2"\

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
4 changes: 4 additions & 0 deletions adapters/iqx/iqzonextest/exemplary/banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"crid": "crid1",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down Expand Up @@ -205,6 +206,7 @@
"crid": "crid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down Expand Up @@ -238,6 +240,7 @@
"crid": "crid1",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down Expand Up @@ -265,6 +268,7 @@
"crid": "crid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down
2 changes: 2 additions & 0 deletions adapters/iqx/iqzonextest/exemplary/native.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
],
"cid": "cid",
"crid": "crid",
"mtype": 4,
"ext": {
"prebid": {
"type": "native"
Expand Down Expand Up @@ -148,6 +149,7 @@
],
"cid": "cid",
"crid": "crid",
"mtype": 4,
"ext": {
"prebid": {
"type": "native"
Expand Down
2 changes: 2 additions & 0 deletions adapters/iqx/iqzonextest/exemplary/video.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
],
"cid": "cid",
"crid": "crid",
"mtype": 2,
"ext": {
"prebid": {
"type": "video"
Expand Down Expand Up @@ -188,6 +189,7 @@
],
"cid": "cid",
"crid": "crid",
"mtype": 2,
"ext": {
"prebid": {
"type": "video"
Expand Down
4 changes: 3 additions & 1 deletion adapters/iqx/iqzonextest/supplemental/empty-mediatype.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
],
"cid": "cid",
"crid": "crid",
"mtype": 1,
"w": 300,
"h": 250,
"ext": {
Expand Down Expand Up @@ -152,7 +153,7 @@
],
"expectedMakeBidsErrors": [
{
"value": "Bid[1].Ext.Prebid.Type expects one of the following values: 'banner', 'native', 'video', got ''",
"value": "failed to parse bid mType for impression \"2\"",
"comparison": "literal"
}
],
Expand All @@ -174,6 +175,7 @@
"crid": "crid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down
11 changes: 4 additions & 7 deletions adapters/iqx/iqzonextest/supplemental/invalid-mediatype.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"crid": "crid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand All @@ -136,12 +137,7 @@
"cid": "cid",
"crid": "crid",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "wrong"
}
}
"h": 250
}
],
"seat": "seat"
Expand All @@ -154,7 +150,7 @@
],
"expectedMakeBidsErrors": [
{
"value": "Bid[1].Ext.Prebid.Type expects one of the following values: 'banner', 'native', 'video', got 'wrong'",
"value": "failed to parse bid mType for impression \"2\"",
"comparison": "literal"
}
],
Expand All @@ -176,6 +172,7 @@
"crid": "crid",
"w": 300,
"h": 250,
"mtype": 1,
"ext": {
"prebid": {
"type": "banner"
Expand Down
Loading