diff --git a/adapters/playdigo/playdigo.go b/adapters/playdigo/playdigo.go index 2a7a8a80cac..d8450bdd798 100644 --- a/adapters/playdigo/playdigo.go +++ b/adapters/playdigo/playdigo.go @@ -77,9 +77,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E continue } - if adapterReq != nil { - adapterRequests = append(adapterRequests, adapterReq) - } + adapterRequests = append(adapterRequests, adapterReq) } if len(adapterRequests) == 0 { @@ -129,7 +127,8 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R for _, seatBid := range response.SeatBid { for i := range seatBid.Bid { - bidType, err := getBidMediaType(&seatBid.Bid[i]) + bid := seatBid.Bid[i] + bidType, err := getBidType(bid) if err != nil { return nil, []error{err} } @@ -144,21 +143,18 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return bidResponse, nil } -func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { - var extBid openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &extBid) - if err != nil { - return "", fmt.Errorf("unable to deserialize imp %v bid.ext, error: %v", bid.ImpID, err) +func getBidType(bid openrtb2.Bid) (openrtb_ext.BidType, error) { + // determinate media type by bid response field mtype + switch bid.MType { + case openrtb2.MarkupBanner: + return openrtb_ext.BidTypeBanner, nil + case openrtb2.MarkupVideo: + return openrtb_ext.BidTypeVideo, nil + case openrtb2.MarkupAudio: + return openrtb_ext.BidTypeAudio, nil + case openrtb2.MarkupNative: + return openrtb_ext.BidTypeNative, nil } - if extBid.Prebid == nil { - return "", fmt.Errorf("imp %v with unknown media type", bid.ImpID) - } - - switch extBid.Prebid.Type { - case openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeVideo, openrtb_ext.BidTypeNative: - return extBid.Prebid.Type, nil - default: - return "", fmt.Errorf("invalid BidType: %s", extBid.Prebid.Type) - } + return "", fmt.Errorf("could not define media type for impression: %s", bid.ImpID) } diff --git a/adapters/playdigo/playdigotest/exemplary/endpointId.json b/adapters/playdigo/playdigotest/exemplary/endpointId.json index f1cf8a54a20..8b6cc1a253f 100644 --- a/adapters/playdigo/playdigotest/exemplary/endpointId.json +++ b/adapters/playdigo/playdigotest/exemplary/endpointId.json @@ -89,6 +89,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { @@ -118,6 +119,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { diff --git a/adapters/playdigo/playdigotest/exemplary/multi-imp.json b/adapters/playdigo/playdigotest/exemplary/multi-imp.json index 4937f741b87..571642d753f 100644 --- a/adapters/playdigo/playdigotest/exemplary/multi-imp.json +++ b/adapters/playdigo/playdigotest/exemplary/multi-imp.json @@ -110,6 +110,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { @@ -181,6 +182,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { @@ -210,6 +212,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { @@ -233,6 +236,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { diff --git a/adapters/playdigo/playdigotest/exemplary/simple-banner.json b/adapters/playdigo/playdigotest/exemplary/simple-banner.json index 05267020d00..9972f4b38be 100644 --- a/adapters/playdigo/playdigotest/exemplary/simple-banner.json +++ b/adapters/playdigo/playdigotest/exemplary/simple-banner.json @@ -89,6 +89,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { @@ -118,6 +119,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 300, "h": 250, "ext": { diff --git a/adapters/playdigo/playdigotest/exemplary/simple-native.json b/adapters/playdigo/playdigotest/exemplary/simple-native.json index ab2e7e6249e..c3d50492c42 100644 --- a/adapters/playdigo/playdigotest/exemplary/simple-native.json +++ b/adapters/playdigo/playdigotest/exemplary/simple-native.json @@ -73,6 +73,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 4, "w": 300, "h": 250, "ext": { @@ -102,6 +103,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 4, "w": 300, "h": 250, "ext": { diff --git a/adapters/playdigo/playdigotest/exemplary/simple-video.json b/adapters/playdigo/playdigotest/exemplary/simple-video.json index 0a4d6d0462d..3bdfbb22a21 100644 --- a/adapters/playdigo/playdigotest/exemplary/simple-video.json +++ b/adapters/playdigo/playdigotest/exemplary/simple-video.json @@ -87,6 +87,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 2, "ext": { "prebid": { "type": "video" @@ -115,6 +116,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 2, "ext": { "prebid": { "type": "video" diff --git a/adapters/playdigo/playdigotest/exemplary/simple-web-banner.json b/adapters/playdigo/playdigotest/exemplary/simple-web-banner.json index 57e694e95cf..dfb69f1b959 100644 --- a/adapters/playdigo/playdigotest/exemplary/simple-web-banner.json +++ b/adapters/playdigo/playdigotest/exemplary/simple-web-banner.json @@ -89,6 +89,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 468, "h": 60, "ext": { @@ -118,6 +119,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", + "mtype": 1, "w": 468, "h": 60, "ext": { diff --git a/adapters/playdigo/playdigotest/supplemental/bad_media_type.json b/adapters/playdigo/playdigotest/supplemental/bad_media_type.json index f2badaaeb40..e00ae157763 100644 --- a/adapters/playdigo/playdigotest/supplemental/bad_media_type.json +++ b/adapters/playdigo/playdigotest/supplemental/bad_media_type.json @@ -76,7 +76,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "imp test-imp-id with unknown media type", + "value": "could not define media type for impression: test-imp-id", "comparison": "literal" } ]