diff --git a/adapters/trustedstack/trustedstack.go b/adapters/trustedstack/trustedstack.go index abb95bf7c4a..ef38fad5abf 100644 --- a/adapters/trustedstack/trustedstack.go +++ b/adapters/trustedstack/trustedstack.go @@ -82,31 +82,12 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co func getMediaTypeForImp(bid *openrtb2.Bid, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType, err := getBidMediaTypeFromMtype(bid) - if err == nil { - return mediaType, nil - } - - for _, imp := range imps { - if imp.ID == bid.ImpID { - switch { - case imp.Banner != nil && imp.Video == nil && imp.Audio == nil && imp.Native == nil: - mediaType = openrtb_ext.BidTypeBanner - case imp.Banner == nil && imp.Video != nil && imp.Audio == nil && imp.Native == nil: - mediaType = openrtb_ext.BidTypeVideo - case imp.Banner == nil && imp.Video == nil && imp.Audio != nil && imp.Native == nil: - mediaType = openrtb_ext.BidTypeAudio - case imp.Banner == nil && imp.Video == nil && imp.Audio == nil && imp.Native != nil: - mediaType = openrtb_ext.BidTypeNative - } + if err != nil { + return "", &errortypes.BadInput{ + Message: err.Error(), } } - - if mediaType != "" { - return mediaType, nil - } - return "", &errortypes.BadInput{ - Message: fmt.Sprintf("Failed to find impression \"%s\"", bid.ImpID), - } + return mediaType, nil } func getBidMediaTypeFromMtype(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { diff --git a/adapters/trustedstack/trustedstacktest/exemplary/multi-imps.json b/adapters/trustedstack/trustedstacktest/exemplary/multi-imps.json index f1a39db0c14..dc22967dce8 100644 --- a/adapters/trustedstack/trustedstacktest/exemplary/multi-imps.json +++ b/adapters/trustedstack/trustedstacktest/exemplary/multi-imps.json @@ -100,7 +100,8 @@ "adm": "some-test-ad", "crid": "test-crid", "h": 50, - "w": 320 + "w": 320, + "mtype": 1 } ] } @@ -123,7 +124,8 @@ "adm": "some-test-ad", "crid": "test-crid", "w": 320, - "h": 50 + "h": 50, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-audio-mtype.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-audio-mtype.json deleted file mode 100644 index 1c2e17e07be..00000000000 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-audio-mtype.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "audio": { - "mimes": ["audio/mp3"], - "protocols": [2, 5] - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "audio": { - "mimes": [ - "audio/mp3" - ], - "protocols": [ - 2, - 5 - ] - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "impIDs":["1"] - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "cur": "USD", - "seatbid": [ - { - "seat": "trustedstack", - "bid": [ - { - "id": "test-bid-id", - "impid": "1", - "price": 2.50, - "adm": "some-test-ad", - "crid": "test-crid", - "mtype": 3 - } - ] - } - ] - } - } - } - ], - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "1", - "price": 2.50, - "adm": "some-test-ad", - "crid": "test-crid", - "mtype": 3 - }, - "type": "audio" - } - ] - } - ] -} diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-audio.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-audio.json index ced6e88793e..1c2e17e07be 100644 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-audio.json +++ b/adapters/trustedstack/trustedstacktest/exemplary/simple-audio.json @@ -60,7 +60,8 @@ "impid": "1", "price": 2.50, "adm": "some-test-ad", - "crid": "test-crid" + "crid": "test-crid", + "mtype": 3 } ] } @@ -79,7 +80,8 @@ "impid": "1", "price": 2.50, "adm": "some-test-ad", - "crid": "test-crid" + "crid": "test-crid", + "mtype": 3 }, "type": "audio" } diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-banner-mtype.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-banner-mtype.json deleted file mode 100644 index c0fb7519a33..00000000000 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-banner-mtype.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "banner": { - "format": [ - { - "w": 320, - "h": 50 - } - ] - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "banner": { - "format": [ - { - "w": 320, - "h": 50 - } - ] - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "impIDs":["1"] - }, - - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "trustedstack", - "bid": [ - { - "id": "test-bid-id", - "impid": "1", - "price": 1.50, - "adm": "some-test-ad", - "crid": "test-crid", - "h": 50, - "w": 320, - "mtype": 1 - } - ] - } - ], - "cur": "USD" - } - } - } - ], - - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "1", - "price": 1.50, - "adm": "some-test-ad", - "crid": "test-crid", - "w": 320, - "h": 50, - "mtype": 1 - }, - "type": "banner" - } - ] - } - ] -} diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-banner.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-banner.json index 36563006d87..c0fb7519a33 100644 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-banner.json +++ b/adapters/trustedstack/trustedstacktest/exemplary/simple-banner.json @@ -1,99 +1,101 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "1", + "banner": { + "format": [ { - "id": "1", - "banner": { - "format": [ - { - "w": 320, - "h": 50 - } - ] - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } + "w": 320, + "h": 50 } - ] - }, + ] + }, + "ext": { + "bidder": { + "cid": "8CUTSTCID", + "crid": "999999999" + } + } + } + ] + }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "banner": { - "format": [ - { - "w": 320, - "h": 50 - } - ] - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "impIDs":["1"] - }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "1", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + } + ] + }, + "ext": { + "bidder": { + "cid": "8CUTSTCID", + "crid": "999999999" + } + } + } + ] + }, + "impIDs":["1"] + }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "trustedstack", - "bid": [ - { - "id": "test-bid-id", - "impid": "1", - "price": 1.50, - "adm": "some-test-ad", - "crid": "test-crid", - "h": 50, - "w": 320 - } - ] - } - ], - "cur": "USD" + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "trustedstack", + "bid": [ + { + "id": "test-bid-id", + "impid": "1", + "price": 1.50, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 50, + "w": 320, + "mtype": 1 } + ] } + ], + "cur": "USD" } - ], + } + } + ], - "expectedBidResponses": [ + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "1", - "price": 1.50, - "adm": "some-test-ad", - "crid": "test-crid", - "w": 320, - "h": 50 - }, - "type": "banner" - } - ] + "bid": { + "id": "test-bid-id", + "impid": "1", + "price": 1.50, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 320, + "h": 50, + "mtype": 1 + }, + "type": "banner" } - ] + ] + } + ] } diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-native-mtype.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-native-mtype.json deleted file mode 100644 index 7af9ce8eba7..00000000000 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-native-mtype.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "native": { - "request": "sample-native-request" - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "native": { - "request": "sample-native-request" - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "impIDs":["1"] - }, - - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "trustedstack", - "bid": [ - { - "id": "test-bid-id", - "impid": "1", - "price": 1.50, - "adm": "some-test-ad", - "crid": "test-crid", - "h": 50, - "w": 320, - "mtype": 4 - } - ] - } - ], - "cur": "USD" - } - } - } - ], - - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "1", - "price": 1.50, - "adm": "some-test-ad", - "crid": "test-crid", - "w": 320, - "h": 50, - "mtype": 4 - }, - "type": "native" - } - ] - } - ] -} diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-native.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-native.json index b873e69aff3..7af9ce8eba7 100644 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-native.json +++ b/adapters/trustedstack/trustedstacktest/exemplary/simple-native.json @@ -56,7 +56,8 @@ "adm": "some-test-ad", "crid": "test-crid", "h": 50, - "w": 320 + "w": 320, + "mtype": 4 } ] } @@ -79,7 +80,8 @@ "adm": "some-test-ad", "crid": "test-crid", "w": 320, - "h": 50 + "h": 50, + "mtype": 4 }, "type": "native" } diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-video-mtype.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-video-mtype.json deleted file mode 100644 index 65357342234..00000000000 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-video-mtype.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "video": { - "mimes": [ - "video/mp4" - ], - "protocols": [ - 2, - 5 - ], - "w": 320, - "h": 480 - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "video": { - "mimes": [ - "video/mp4" - ], - "protocols": [ - 2, - 5 - ], - "w": 320, - "h": 480 - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "impIDs":["1"] - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "cur": "USD", - "seatbid": [ - { - "seat": "trustedstack", - "bid": [ - { - "id": "test-bid-id", - "impid": "1", - "price": 2.50, - "adm": "some-test-ad", - "crid": "test-crid", - "w": 320, - "h": 480, - "mtype": 2 - } - ] - } - ] - } - } - } - ], - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "1", - "price": 2.50, - "adm": "some-test-ad", - "crid": "test-crid", - "w": 320, - "h": 480, - "mtype": 2 - }, - "type": "video" - } - ] - } - ] -} diff --git a/adapters/trustedstack/trustedstacktest/exemplary/simple-video.json b/adapters/trustedstack/trustedstacktest/exemplary/simple-video.json index 00985c4bb0a..65357342234 100644 --- a/adapters/trustedstack/trustedstacktest/exemplary/simple-video.json +++ b/adapters/trustedstack/trustedstacktest/exemplary/simple-video.json @@ -1,102 +1,104 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "1", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 320, + "h": 480 + }, + "ext": { + "bidder": { + "cid": "8CUTSTCID", + "crid": "999999999" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", + "body": { + "id": "test-request-id", + "imp": [ { - "id": "1", - "video": { - "mimes": [ - "video/mp4" - ], - "protocols": [ - 2, - 5 - ], - "w": 320, - "h": 480 - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } + "id": "1", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 320, + "h": 480 + }, + "ext": { + "bidder": { + "cid": "8CUTSTCID", + "crid": "999999999" } + } } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://example.trustedstack.com/rtb/prebid?src=http%3A%2F%2Fhosturl.com", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "1", - "video": { - "mimes": [ - "video/mp4" - ], - "protocols": [ - 2, - 5 - ], - "w": 320, - "h": 480 - }, - "ext": { - "bidder": { - "cid": "8CUTSTCID", - "crid": "999999999" - } - } - } - ] - }, - "impIDs":["1"] - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "cur": "USD", - "seatbid": [ - { - "seat": "trustedstack", - "bid": [ - { - "id": "test-bid-id", - "impid": "1", - "price": 2.50, - "adm": "some-test-ad", - "crid": "test-crid", - "w": 320, - "h": 480 - } - ] - } - ] + ] + }, + "impIDs":["1"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "trustedstack", + "bid": [ + { + "id": "test-bid-id", + "impid": "1", + "price": 2.50, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 320, + "h": 480, + "mtype": 2 } + ] } + ] } - ], - "expectedBidResponses": [ + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "1", - "price": 2.50, - "adm": "some-test-ad", - "crid": "test-crid", - "w": 320, - "h": 480 - }, - "type": "video" - } - ] + "bid": { + "id": "test-bid-id", + "impid": "1", + "price": 2.50, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 320, + "h": 480, + "mtype": 2 + }, + "type": "video" } - ] + ] + } + ] } diff --git a/adapters/trustedstack/trustedstacktest/supplemental/ivalid-req-200-incorrect-response-mtype.json b/adapters/trustedstack/trustedstacktest/supplemental/ivalid-req-200-incorrect-response-mtype.json index 4eca9acc382..0b1dfbb5c66 100644 --- a/adapters/trustedstack/trustedstacktest/supplemental/ivalid-req-200-incorrect-response-mtype.json +++ b/adapters/trustedstack/trustedstacktest/supplemental/ivalid-req-200-incorrect-response-mtype.json @@ -94,14 +94,15 @@ "bid": [ { "id": "randomid", - "impid": "wrong-imp-id", + "impid": "test-imp-id", "price": 0.500000, "adid": "12345678", "adm": "some-test-ad", "cid": "987", "crid": "12345678", "h": 250, - "w": 300 + "w": 300, + "mtype": 5 } ] } @@ -117,7 +118,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "Failed to find impression \"wrong-imp-id\"", + "value": "unable to fetch mediaType for imp: test-imp-id", "comparison": "literal" } ] diff --git a/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-bid-response-from-trustedstack.json b/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-bid-response-from-trustedstack.json index eee284db672..a2388abea37 100644 --- a/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-bid-response-from-trustedstack.json +++ b/adapters/trustedstack/trustedstacktest/supplemental/valid-req-200-bid-response-from-trustedstack.json @@ -101,7 +101,8 @@ "cid": "987", "crid": "12345678", "h": 250, - "w": 300 + "w": 300, + "mtype": 1 } ] } @@ -123,7 +124,8 @@ "cid": "987", "crid": "12345678", "h": 250, - "w": 300 + "w": 300, + "mtype": 1 }, "type": "banner" }]