From cfb4cea6eac4cae231c06249d826aeef2c0b48c7 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 28 Oct 2020 18:08:06 +0000 Subject: [PATCH 01/18] add video support --- adapters/33across/33across.go | 68 ++++++++++- .../33across/exemplary/multi-format.json | 103 ++++++++++++++++ .../33across/exemplary/simple-video.json | 110 ++++++++++++++++++ .../33across/33across/params/race/video.json | 6 + static/bidder-info/33across.yaml | 2 + 5 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 adapters/33across/33across/exemplary/multi-format.json create mode 100644 adapters/33across/33across/exemplary/simple-video.json create mode 100644 adapters/33across/33across/params/race/video.json diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 5c1b31eeb8c..337d8c20137 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -24,6 +24,13 @@ type ext struct { Zoneid string `json:"zoneid,omitempty"` } +type bidExt struct { + Ttx bidTtxExt `json:"ttx,omitempty"` +} +type bidTtxExt struct { + MediaType string `json:mediaType,omitempty` +} + // MakeRequests create the object for TTX Reqeust. func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error @@ -99,6 +106,19 @@ func preprocess(request *openrtb.BidRequest) error { } } + // Validate Video if it exists + if imp.Video != nil { + videoCopy, err := validateVideoParams(imp.Video, impExt.Ttx.Prod) + + if err != nil { + return &errortypes.BadInput{ + Message: err.Error(), + } + } + + imp.Video = videoCopy + } + imp.Ext = impExtJSON siteCopy := *request.Site siteCopy.ID = ttxExt.SiteId @@ -135,9 +155,18 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReque for _, sb := range bidResp.SeatBid { for i := range sb.Bid { + var bidExt bidExt + var bidType openrtb_ext.BidType + + if err := json.Unmarshal(sb.Bid[i].Ext, &bidExt); err != nil { + bidType = openrtb_ext.BidTypeBanner + } else { + bidType = getBidType(bidExt) + } + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &sb.Bid[i], - BidType: "banner", + BidType: bidType, }) } } @@ -145,6 +174,43 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReque } +func validateVideoParams(video *openrtb.Video, prod string) (*openrtb.Video, error) { + videoCopy := video + if videoCopy.W == 0 || + videoCopy.H == 0 || + videoCopy.Protocols == nil || + videoCopy.MIMEs == nil || + videoCopy.PlaybackMethod == nil { + + return nil, &errortypes.BadInput{ + Message: "One or more invalid or missing video field(s) w, h, protocols, mimes, playbackmethod", + } + } + + if videoCopy.Placement == 0 { + videoCopy.Placement = 2 + } + + if prod == "instream" { + videoCopy.Placement = 1 + + if videoCopy.StartDelay == nil { + videoCopy.StartDelay = openrtb.StartDelay.Ptr(0) + } + } + + return videoCopy, nil +} + +func getBidType(ext bidExt) openrtb_ext.BidType { + if ext.Ttx.MediaType == "video" { + return openrtb_ext.BidTypeVideo + } + + return openrtb_ext.BidTypeBanner +} + +// New33AcrossBidder configures bidder endpoint func New33AcrossBidder(endpoint string) *TtxAdapter { return &TtxAdapter{ endpoint: endpoint, diff --git a/adapters/33across/33across/exemplary/multi-format.json b/adapters/33across/33across/exemplary/multi-format.json new file mode 100644 index 00000000000..db15955ca87 --- /dev/null +++ b/adapters/33across/33across/exemplary/multi-format.json @@ -0,0 +1,103 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "inview" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "placement": 2, + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "ttx": { + "prod": "inview" + } + } + } + ], + "site": { + "id": "fake-site-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728 + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 728, + "h": 90 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/33across/33across/exemplary/simple-video.json b/adapters/33across/33across/exemplary/simple-video.json new file mode 100644 index 00000000000..55337b92827 --- /dev/null +++ b/adapters/33across/33across/exemplary/simple-video.json @@ -0,0 +1,110 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "placement": 1, + "startdelay": -2, + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "instream" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "placement": 1, + "startdelay": -2, + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "ttx": { + "prod": "instream" + } + } + } + ], + "site": { + "id": "fake-site-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "ext": { + "ttx": { + "mediaType": "video" + } + } + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "ext": { + "ttx": { + "mediaType": "video" + } + } + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/33across/33across/params/race/video.json b/adapters/33across/33across/params/race/video.json new file mode 100644 index 00000000000..9df849ad94b --- /dev/null +++ b/adapters/33across/33across/params/race/video.json @@ -0,0 +1,6 @@ +{ + "productId": "siab", + "siteId": "33across", + "zoneId": "33AcrossZone" + } + \ No newline at end of file diff --git a/static/bidder-info/33across.yaml b/static/bidder-info/33across.yaml index 84ba6d68611..67e6996accf 100644 --- a/static/bidder-info/33across.yaml +++ b/static/bidder-info/33across.yaml @@ -4,6 +4,8 @@ capabilities: app: mediaTypes: - banner + - video site: mediaTypes: - banner + - video From b37978ecbeabab71f7b5ad38c913d079c69ead9b Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 4 Nov 2020 14:26:12 -0500 Subject: [PATCH 02/18] renamed folder for tests per code review from Prebid --- .../{33across => 33acrosstest}/exemplary/multi-format.json | 0 .../{33across => 33acrosstest}/exemplary/optional-params.json | 0 .../{33across => 33acrosstest}/exemplary/simple-banner.json | 0 .../{33across => 33acrosstest}/exemplary/simple-video.json | 0 .../33across/{33across => 33acrosstest}/params/race/banner.json | 0 .../33across/{33across => 33acrosstest}/params/race/video.json | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename adapters/33across/{33across => 33acrosstest}/exemplary/multi-format.json (100%) rename adapters/33across/{33across => 33acrosstest}/exemplary/optional-params.json (100%) rename adapters/33across/{33across => 33acrosstest}/exemplary/simple-banner.json (100%) rename adapters/33across/{33across => 33acrosstest}/exemplary/simple-video.json (100%) rename adapters/33across/{33across => 33acrosstest}/params/race/banner.json (100%) rename adapters/33across/{33across => 33acrosstest}/params/race/video.json (100%) diff --git a/adapters/33across/33across/exemplary/multi-format.json b/adapters/33across/33acrosstest/exemplary/multi-format.json similarity index 100% rename from adapters/33across/33across/exemplary/multi-format.json rename to adapters/33across/33acrosstest/exemplary/multi-format.json diff --git a/adapters/33across/33across/exemplary/optional-params.json b/adapters/33across/33acrosstest/exemplary/optional-params.json similarity index 100% rename from adapters/33across/33across/exemplary/optional-params.json rename to adapters/33across/33acrosstest/exemplary/optional-params.json diff --git a/adapters/33across/33across/exemplary/simple-banner.json b/adapters/33across/33acrosstest/exemplary/simple-banner.json similarity index 100% rename from adapters/33across/33across/exemplary/simple-banner.json rename to adapters/33across/33acrosstest/exemplary/simple-banner.json diff --git a/adapters/33across/33across/exemplary/simple-video.json b/adapters/33across/33acrosstest/exemplary/simple-video.json similarity index 100% rename from adapters/33across/33across/exemplary/simple-video.json rename to adapters/33across/33acrosstest/exemplary/simple-video.json diff --git a/adapters/33across/33across/params/race/banner.json b/adapters/33across/33acrosstest/params/race/banner.json similarity index 100% rename from adapters/33across/33across/params/race/banner.json rename to adapters/33across/33acrosstest/params/race/banner.json diff --git a/adapters/33across/33across/params/race/video.json b/adapters/33across/33acrosstest/params/race/video.json similarity index 100% rename from adapters/33across/33across/params/race/video.json rename to adapters/33across/33acrosstest/params/race/video.json From e248833a135b76db238f3de2d36d8942a097b8d0 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 4 Nov 2020 14:50:03 -0500 Subject: [PATCH 03/18] updated path to renamed test folder --- adapters/33across/33across_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/33across/33across_test.go b/adapters/33across/33across_test.go index ccdcbf9cc2c..9856f8f9f6a 100644 --- a/adapters/33across/33across_test.go +++ b/adapters/33across/33across_test.go @@ -7,5 +7,5 @@ import ( ) func TestJsonSamples(t *testing.T) { - adapterstest.RunJSONBidderTest(t, "33across", New33AcrossBidder("http://ssc.33across.com")) + adapterstest.RunJSONBidderTest(t, "33acrosstest", New33AcrossBidder("http://ssc.33across.com")) } From 820fb302c74d09e790337e1b25df39ca162cf5d3 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Fri, 6 Nov 2020 03:27:21 +0000 Subject: [PATCH 04/18] Added more unit tests --- adapters/33across/33across.go | 22 ++-- .../exemplary/bidresponse-defaults.json | 100 ++++++++++++++++ .../exemplary/instream-video-defaults.json | 108 ++++++++++++++++++ .../exemplary/outstream-video-defaults.json | 107 +++++++++++++++++ .../33acrosstest/exemplary/simple-banner.json | 14 ++- .../supplemental/status-not-ok.json | 67 +++++++++++ .../supplemental/video-validation-fail.json | 32 ++++++ 7 files changed, 441 insertions(+), 9 deletions(-) create mode 100644 adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json create mode 100644 adapters/33across/33acrosstest/exemplary/instream-video-defaults.json create mode 100644 adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json create mode 100644 adapters/33across/33acrosstest/supplemental/status-not-ok.json create mode 100644 adapters/33across/33acrosstest/supplemental/video-validation-fail.json diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 337d8c20137..8efd6c8fd51 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -56,6 +56,14 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Request errs = append(errs, err) } + if reqCopy.Imp[0].Banner == nil && reqCopy.Imp[0].Video == nil { + errs = append(errs, &errortypes.BadInput{ + Message: "At least one of [banner, video] formats must be defined in Imp. None found", + }) + + return nil, errs + } + // Last Step reqJSON, err := json.Marshal(reqCopy) if err != nil { @@ -106,24 +114,24 @@ func preprocess(request *openrtb.BidRequest) error { } } + imp.Ext = impExtJSON + siteCopy := *request.Site + siteCopy.ID = ttxExt.SiteId + request.Site = &siteCopy + // Validate Video if it exists if imp.Video != nil { videoCopy, err := validateVideoParams(imp.Video, impExt.Ttx.Prod) + imp.Video = videoCopy + if err != nil { return &errortypes.BadInput{ Message: err.Error(), } } - - imp.Video = videoCopy } - imp.Ext = impExtJSON - siteCopy := *request.Site - siteCopy.ID = ttxExt.SiteId - request.Site = &siteCopy - return nil } diff --git a/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json b/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json new file mode 100644 index 00000000000..bb0e6585fd0 --- /dev/null +++ b/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json @@ -0,0 +1,100 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "placement": 1, + "startdelay": -2, + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "instream" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "placement": 1, + "startdelay": -2, + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "ttx": { + "prod": "instream" + } + } + } + ], + "site": { + "id": "fake-site-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "h": 90, + "w": 728 + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "w": 728, + "h": 90 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json b/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json new file mode 100644 index 00000000000..479b197077a --- /dev/null +++ b/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json @@ -0,0 +1,108 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "instream" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "placement": 1, + "startdelay": 0, + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "ttx": { + "prod": "instream" + } + } + } + ], + "site": { + "id": "fake-site-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "ext": { + "ttx": { + "mediaType": "video" + } + } + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "ext": { + "ttx": { + "mediaType": "video" + } + } + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json b/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json new file mode 100644 index 00000000000..c0c31168684 --- /dev/null +++ b/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json @@ -0,0 +1,107 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "siab" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [2], + "placement": 2, + "playbackmethod": [2], + "mimes": ["foo", "bar"] + }, + "ext": { + "ttx": { + "prod": "siab" + } + } + } + ], + "site": { + "id": "fake-site-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "ext": { + "ttx": { + "mediaType": "video" + } + } + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "ext": { + "ttx": { + "mediaType": "video" + } + } + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/33across/33acrosstest/exemplary/simple-banner.json b/adapters/33across/33acrosstest/exemplary/simple-banner.json index 074badade07..d8c215c06ae 100644 --- a/adapters/33across/33acrosstest/exemplary/simple-banner.json +++ b/adapters/33across/33acrosstest/exemplary/simple-banner.json @@ -56,7 +56,12 @@ "adm": "some-test-ad", "crid": "crid_10", "h": 90, - "w": 728 + "w": 728, + "ext": { + "ttx": { + "mediaType": "banner" + } + } }] } ], @@ -78,7 +83,12 @@ "adm": "some-test-ad", "crid": "crid_10", "w": 728, - "h": 90 + "h": 90, + "ext": { + "ttx": { + "mediaType": "banner" + } + } }, "type": "banner" } diff --git a/adapters/33across/33acrosstest/supplemental/status-not-ok.json b/adapters/33across/33acrosstest/supplemental/status-not-ok.json new file mode 100644 index 00000000000..98fe01c2e50 --- /dev/null +++ b/adapters/33across/33acrosstest/supplemental/status-not-ok.json @@ -0,0 +1,67 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "bidder": { + "siteId": "fake-invalid-site-id", + "productId": "inview" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "ttx": { + "prod": "inview" + } + } + } + ], + "site": { + "id": "fake-invalid-site-id" + } + } + }, + "mockResponse": { + "status": 400, + "body": { + "error": { + "message": "Validation failed", + "details": [ + { + "message": "site.id is invalid" + } + ] + } + } + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/33across/33acrosstest/supplemental/video-validation-fail.json b/adapters/33across/33acrosstest/supplemental/video-validation-fail.json new file mode 100644 index 00000000000..97cb79bd26c --- /dev/null +++ b/adapters/33across/33acrosstest/supplemental/video-validation-fail.json @@ -0,0 +1,32 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90 + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "siab" + } + } + } + ], + "site": {} + }, + + "expectedMakeRequestsErrors": [ + { + "value": "One or more invalid or missing video field(s) w, h, protocols, mimes, playbackmethod", + "comparison": "literal" + }, + { + "value": "At least one of [banner, video] formats must be defined in Imp. None found", + "comparison": "literal" + } + ] +} From 67e04cd49a017572a485ac914b16b46d236f17c6 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Mon, 9 Nov 2020 14:25:13 -0500 Subject: [PATCH 05/18] Added a newline between structs --- adapters/33across/33across.go | 1 + 1 file changed, 1 insertion(+) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 8efd6c8fd51..40099a204e0 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -27,6 +27,7 @@ type ext struct { type bidExt struct { Ttx bidTtxExt `json:"ttx,omitempty"` } + type bidTtxExt struct { MediaType string `json:mediaType,omitempty` } From 8725d452af72a2cf8db628b4ec94fe9c795cba31 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Tue, 1 Dec 2020 00:26:21 -0500 Subject: [PATCH 06/18] breaking up multi-imps --- adapters/33across/33across.go | 79 ++++++++++--------- .../exemplary/bidresponse-defaults.json | 7 +- .../exemplary/instream-video-defaults.json | 7 +- .../33acrosstest/exemplary/multi-format.json | 7 +- .../exemplary/optional-params.json | 4 +- .../exemplary/outstream-video-defaults.json | 7 +- .../33acrosstest/exemplary/simple-banner.json | 7 +- .../33acrosstest/exemplary/simple-video.json | 7 +- .../supplemental/status-not-ok.json | 7 +- .../supplemental/video-validation-fail.json | 4 - 10 files changed, 64 insertions(+), 72 deletions(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 40099a204e0..8fc56f93ce1 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -37,39 +37,39 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters var errs []error var adapterRequests []*adapters.RequestData - adapterReq, errors := a.makeRequest(request) - if adapterReq != nil { - adapterRequests = append(adapterRequests, adapterReq) + // Break up multi-imp request into multiple external requests since we don't + // support SRA + for i := 0; i < len(request.Imp); i++ { + adapterReq, err := a.makeRequest(request, request.Imp[i]) + if adapterReq != nil { + adapterRequests = append(adapterRequests, adapterReq) + } + if err != nil { + errs = append(errs, err) + } } - errs = append(errs, errors...) - return adapterRequests, errors + return adapterRequests, errs } // Update the request object to include custom value // site.id -func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { - var errs []error +func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) { + var imps []openrtb.Imp - // Make a copy as we don't want to change the original request - reqCopy := *request - if err := preprocess(&reqCopy); err != nil { - errs = append(errs, err) - } - - if reqCopy.Imp[0].Banner == nil && reqCopy.Imp[0].Video == nil { - errs = append(errs, &errortypes.BadInput{ - Message: "At least one of [banner, video] formats must be defined in Imp. None found", - }) + reqCopy := request + impCopy, err := makeImps(imp) - return nil, errs + if err != nil { + return nil, err } + reqCopy.Imp = append(imps, impCopy) + // Last Step reqJSON, err := json.Marshal(reqCopy) if err != nil { - errs = append(errs, err) - return nil, errs + return nil, err } headers := http.Header{} @@ -80,22 +80,28 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Request Uri: a.endpoint, Body: reqJSON, Headers: headers, - }, errs + }, nil } -// Mutate the request to get it ready to send to ttx. -func preprocess(request *openrtb.BidRequest) error { - var imp = &request.Imp[0] +func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { + impCopy := imp + + if impCopy.Banner == nil && impCopy.Video == nil { + return openrtb.Imp{}, &errortypes.BadInput{ + Message: fmt.Sprintf("Imp ID %s must have at one of [Banner, Video] defined", impCopy.ID), + } + } + var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { - return &errortypes.BadInput{ + if err := json.Unmarshal(impCopy.Ext, &bidderExt); err != nil { + return openrtb.Imp{}, &errortypes.BadInput{ Message: err.Error(), } } var ttxExt openrtb_ext.ExtImp33across if err := json.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil { - return &errortypes.BadInput{ + return openrtb.Imp{}, &errortypes.BadInput{ Message: err.Error(), } } @@ -104,36 +110,35 @@ func preprocess(request *openrtb.BidRequest) error { impExt.Ttx.Prod = ttxExt.ProductId // Add zoneid if it's defined + impExt.Ttx.Zoneid = ttxExt.SiteId + if len(ttxExt.ZoneId) > 0 { impExt.Ttx.Zoneid = ttxExt.ZoneId } impExtJSON, err := json.Marshal(impExt) if err != nil { - return &errortypes.BadInput{ + return openrtb.Imp{}, &errortypes.BadInput{ Message: err.Error(), } } - imp.Ext = impExtJSON - siteCopy := *request.Site - siteCopy.ID = ttxExt.SiteId - request.Site = &siteCopy + impCopy.Ext = impExtJSON // Validate Video if it exists - if imp.Video != nil { - videoCopy, err := validateVideoParams(imp.Video, impExt.Ttx.Prod) + if impCopy.Video != nil { + videoCopy, err := validateVideoParams(impCopy.Video, impExt.Ttx.Prod) - imp.Video = videoCopy + impCopy.Video = videoCopy if err != nil { - return &errortypes.BadInput{ + return impCopy, &errortypes.BadInput{ Message: err.Error(), } } } - return nil + return impCopy, nil } // MakeBids make the bids for the bid response. diff --git a/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json b/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json index bb0e6585fd0..0b35020ae57 100644 --- a/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json +++ b/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json @@ -44,14 +44,13 @@ }, "ext": { "ttx": { - "prod": "instream" + "prod": "instream", + "zoneid": "fake-site-id" } } } ], - "site": { - "id": "fake-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json b/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json index 479b197077a..2759879d578 100644 --- a/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json +++ b/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json @@ -42,14 +42,13 @@ }, "ext": { "ttx": { - "prod": "instream" + "prod": "instream", + "zoneid": "fake-site-id" } } } ], - "site": { - "id": "fake-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/exemplary/multi-format.json b/adapters/33across/33acrosstest/exemplary/multi-format.json index db15955ca87..17bdbcb58ce 100644 --- a/adapters/33across/33acrosstest/exemplary/multi-format.json +++ b/adapters/33across/33acrosstest/exemplary/multi-format.json @@ -47,14 +47,13 @@ }, "ext": { "ttx": { - "prod": "inview" + "prod": "inview", + "zoneid": "fake-site-id" } } } ], - "site": { - "id": "fake-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/exemplary/optional-params.json b/adapters/33across/33acrosstest/exemplary/optional-params.json index e92958e73d7..3d5b30bbe9c 100644 --- a/adapters/33across/33acrosstest/exemplary/optional-params.json +++ b/adapters/33across/33acrosstest/exemplary/optional-params.json @@ -39,9 +39,7 @@ } } ], - "site": { - "id": "fake-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json b/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json index c0c31168684..b7b379cb941 100644 --- a/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json +++ b/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json @@ -41,14 +41,13 @@ }, "ext": { "ttx": { - "prod": "siab" + "prod": "siab", + "zoneid": "fake-site-id" } } } ], - "site": { - "id": "fake-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/exemplary/simple-banner.json b/adapters/33across/33acrosstest/exemplary/simple-banner.json index d8c215c06ae..4aaf72b9347 100644 --- a/adapters/33across/33acrosstest/exemplary/simple-banner.json +++ b/adapters/33across/33acrosstest/exemplary/simple-banner.json @@ -32,14 +32,13 @@ }, "ext": { "ttx": { - "prod": "inview" + "prod": "inview", + "zoneid": "fake-site-id" } } } ], - "site": { - "id": "fake-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/exemplary/simple-video.json b/adapters/33across/33acrosstest/exemplary/simple-video.json index 55337b92827..46b3bfbdaf5 100644 --- a/adapters/33across/33acrosstest/exemplary/simple-video.json +++ b/adapters/33across/33acrosstest/exemplary/simple-video.json @@ -44,14 +44,13 @@ }, "ext": { "ttx": { - "prod": "instream" + "prod": "instream", + "zoneid": "fake-site-id" } } } ], - "site": { - "id": "fake-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/supplemental/status-not-ok.json b/adapters/33across/33acrosstest/supplemental/status-not-ok.json index 98fe01c2e50..c64e7625b20 100644 --- a/adapters/33across/33acrosstest/supplemental/status-not-ok.json +++ b/adapters/33across/33acrosstest/supplemental/status-not-ok.json @@ -32,14 +32,13 @@ }, "ext": { "ttx": { - "prod": "inview" + "prod": "inview", + "zoneid": "fake-invalid-site-id" } } } ], - "site": { - "id": "fake-invalid-site-id" - } + "site": {} } }, "mockResponse": { diff --git a/adapters/33across/33acrosstest/supplemental/video-validation-fail.json b/adapters/33across/33acrosstest/supplemental/video-validation-fail.json index 97cb79bd26c..f29d728c9d7 100644 --- a/adapters/33across/33acrosstest/supplemental/video-validation-fail.json +++ b/adapters/33across/33acrosstest/supplemental/video-validation-fail.json @@ -23,10 +23,6 @@ { "value": "One or more invalid or missing video field(s) w, h, protocols, mimes, playbackmethod", "comparison": "literal" - }, - { - "value": "At least one of [banner, video] formats must be defined in Imp. None found", - "comparison": "literal" } ] } From 88dfe5ec27553f66d80db99397b3e403cdf537e1 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 2 Dec 2020 04:19:08 +0000 Subject: [PATCH 07/18] Added tests for multi-imp --- adapters/33across/33across.go | 4 +- .../exemplary/multi-imp-banner.json | 180 ++++++++++++++++++ 2 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 adapters/33across/33acrosstest/exemplary/multi-imp-banner.json diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 8fc56f93ce1..823286f35b6 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -38,7 +38,7 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters var adapterRequests []*adapters.RequestData // Break up multi-imp request into multiple external requests since we don't - // support SRA + // support SRA in our exchange server for i := 0; i < len(request.Imp); i++ { adapterReq, err := a.makeRequest(request, request.Imp[i]) if adapterReq != nil { @@ -57,7 +57,7 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) { var imps []openrtb.Imp - reqCopy := request + reqCopy := *request impCopy, err := makeImps(imp) if err != nil { diff --git a/adapters/33across/33acrosstest/exemplary/multi-imp-banner.json b/adapters/33across/33acrosstest/exemplary/multi-imp-banner.json new file mode 100644 index 00000000000..479ac1852dd --- /dev/null +++ b/adapters/33across/33acrosstest/exemplary/multi-imp-banner.json @@ -0,0 +1,180 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id1", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "inview" + } + } + }, + { + "id": "test-imp-id2", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "inview" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id1", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "ttx": { + "prod": "inview", + "zoneid": "fake-site-id" + } + } + } + ], + "site": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id1", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "ext": { + "ttx": { + "mediaType": "banner" + } + } + }] + } + ], + "cur": "USD" + } + } + }, + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id2", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "ttx": { + "prod": "inview", + "zoneid": "fake-site-id" + } + } + } + ], + "site": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id2", + "price": 0.600000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "ext": { + "ttx": { + "mediaType": "banner" + } + } + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id1", + "price": 0.5, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "ext": { + "ttx": { + "mediaType": "banner" + } + } + }, + "type": "banner" + } + ] + }, + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id2", + "price": 0.6, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "ext": { + "ttx": { + "mediaType": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} From a29a0f7084e7f0772d13d7e559d1443bc892b0c0 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 2 Dec 2020 12:48:24 -0500 Subject: [PATCH 08/18] Adding caller info --- adapters/33across/33across.go | 42 ++++++++++++++++++- .../exemplary/bidresponse-defaults.json | 10 +++++ .../exemplary/instream-video-defaults.json | 10 +++++ .../33acrosstest/exemplary/multi-format.json | 10 +++++ .../exemplary/multi-imp-banner.json | 20 +++++++++ .../exemplary/optional-params.json | 10 +++++ .../exemplary/outstream-video-defaults.json | 10 +++++ .../33acrosstest/exemplary/simple-banner.json | 10 +++++ .../33acrosstest/exemplary/simple-video.json | 10 +++++ .../supplemental/status-not-ok.json | 10 +++++ 10 files changed, 140 insertions(+), 2 deletions(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 823286f35b6..1e2f3cee03f 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -16,14 +16,27 @@ type TtxAdapter struct { } type Ext struct { - Ttx ext `json:"ttx"` + Ttx impTtxExt `json:"ttx"` } -type ext struct { +type impTtxExt struct { Prod string `json:"prod"` Zoneid string `json:"zoneid,omitempty"` } +type reqExt struct { + Ttx *reqTtxExt `json:"ttx,omitempty"` +} + +type reqTtxExt struct { + Caller []TtxCaller `json:"caller,omitempty"` +} + +type TtxCaller struct { + Name string `json:"name,omitempty"` + Version string `json:"version,omitempty"` +} + type bidExt struct { Ttx bidTtxExt `json:"ttx,omitempty"` } @@ -66,6 +79,31 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) ( reqCopy.Imp = append(imps, impCopy) + // Add info about caller + caller := TtxCaller{"Prebid-Server", "n/a"} + + var reqExt reqExt + if len(reqCopy.Ext) > 0 { + if err := json.Unmarshal(reqCopy.Ext, &reqExt); err != nil { + return nil, err + } + } + + if reqExt.Ttx == nil { + reqExt.Ttx = &reqTtxExt{} + } + + if reqExt.Ttx.Caller == nil { + reqExt.Ttx.Caller = make([]TtxCaller, 0) + } + + reqExt.Ttx.Caller = append(reqExt.Ttx.Caller, caller) + + reqCopy.Ext, err = json.Marshal(reqExt) + if err != nil { + return nil, err + } + // Last Step reqJSON, err := json.Marshal(reqCopy) if err != nil { diff --git a/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json b/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json index 0b35020ae57..50fba69bde1 100644 --- a/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json +++ b/adapters/33across/33acrosstest/exemplary/bidresponse-defaults.json @@ -29,6 +29,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json b/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json index 2759879d578..c99e535cdb7 100644 --- a/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json +++ b/adapters/33across/33acrosstest/exemplary/instream-video-defaults.json @@ -27,6 +27,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/exemplary/multi-format.json b/adapters/33across/33acrosstest/exemplary/multi-format.json index 17bdbcb58ce..3315ff72559 100644 --- a/adapters/33across/33acrosstest/exemplary/multi-format.json +++ b/adapters/33across/33acrosstest/exemplary/multi-format.json @@ -30,6 +30,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/exemplary/multi-imp-banner.json b/adapters/33across/33acrosstest/exemplary/multi-imp-banner.json index 479ac1852dd..b6d19f55683 100644 --- a/adapters/33across/33acrosstest/exemplary/multi-imp-banner.json +++ b/adapters/33across/33acrosstest/exemplary/multi-imp-banner.json @@ -35,6 +35,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { @@ -84,6 +94,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/exemplary/optional-params.json b/adapters/33across/33acrosstest/exemplary/optional-params.json index 3d5b30bbe9c..a6d9092a8d9 100644 --- a/adapters/33across/33acrosstest/exemplary/optional-params.json +++ b/adapters/33across/33acrosstest/exemplary/optional-params.json @@ -24,6 +24,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json b/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json index b7b379cb941..fdd422c7a63 100644 --- a/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json +++ b/adapters/33across/33acrosstest/exemplary/outstream-video-defaults.json @@ -27,6 +27,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/exemplary/simple-banner.json b/adapters/33across/33acrosstest/exemplary/simple-banner.json index 4aaf72b9347..552daf25224 100644 --- a/adapters/33across/33acrosstest/exemplary/simple-banner.json +++ b/adapters/33across/33acrosstest/exemplary/simple-banner.json @@ -23,6 +23,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/exemplary/simple-video.json b/adapters/33across/33acrosstest/exemplary/simple-video.json index 46b3bfbdaf5..3cf44775efb 100644 --- a/adapters/33across/33acrosstest/exemplary/simple-video.json +++ b/adapters/33across/33acrosstest/exemplary/simple-video.json @@ -29,6 +29,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { diff --git a/adapters/33across/33acrosstest/supplemental/status-not-ok.json b/adapters/33across/33acrosstest/supplemental/status-not-ok.json index c64e7625b20..2c7fcd013f3 100644 --- a/adapters/33across/33acrosstest/supplemental/status-not-ok.json +++ b/adapters/33across/33acrosstest/supplemental/status-not-ok.json @@ -23,6 +23,16 @@ "expectedRequest": { "uri": "http://ssc.33across.com", "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, "id": "test-request-id", "imp": [ { From 0b025769f1515f5e2754fb53b7838a87332a03af Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Thu, 3 Dec 2020 18:18:04 +0000 Subject: [PATCH 09/18] We do not support app --- static/bidder-info/33across.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/static/bidder-info/33across.yaml b/static/bidder-info/33across.yaml index 67e6996accf..e3eea765556 100644 --- a/static/bidder-info/33across.yaml +++ b/static/bidder-info/33across.yaml @@ -1,10 +1,6 @@ maintainer: email: "headerbidding@33across.com" capabilities: - app: - mediaTypes: - - banner - - video site: mediaTypes: - banner From 662c02d746bb0208537fbabea919f65f5a05536b Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Thu, 3 Dec 2020 19:13:03 +0000 Subject: [PATCH 10/18] fixed typo in debug messages --- adapters/33across/33across.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 1e2f3cee03f..33d17ece1fc 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -126,7 +126,7 @@ func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { if impCopy.Banner == nil && impCopy.Video == nil { return openrtb.Imp{}, &errortypes.BadInput{ - Message: fmt.Sprintf("Imp ID %s must have at one of [Banner, Video] defined", impCopy.ID), + Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", impCopy.ID), } } From 9a6a4e0496581dc45d8a54c6f102c49b3540f2e9 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Thu, 3 Dec 2020 19:14:05 +0000 Subject: [PATCH 11/18] removed confusing comment --- adapters/33across/33across.go | 1 - 1 file changed, 1 deletion(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 33d17ece1fc..e55940ffc89 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -147,7 +147,6 @@ func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { var impExt Ext impExt.Ttx.Prod = ttxExt.ProductId - // Add zoneid if it's defined impExt.Ttx.Zoneid = ttxExt.SiteId if len(ttxExt.ZoneId) > 0 { From a14bb1b78a5346ecc7aeaeb96c21e992573f791c Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Thu, 3 Dec 2020 19:20:50 +0000 Subject: [PATCH 12/18] removed outdated comments --- adapters/33across/33across.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index e55940ffc89..90f73dee668 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -65,8 +65,6 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters return adapterRequests, errs } -// Update the request object to include custom value -// site.id func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) { var imps []openrtb.Imp From 7ac08dd792b9236927a05e1d626319d2d3c70df8 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Tue, 8 Dec 2020 23:12:19 +0000 Subject: [PATCH 13/18] Code review feedback --- adapters/33across/33across.go | 35 +++-- .../multi-imp-mixed-validation.json | 121 ++++++++++++++++++ 2 files changed, 138 insertions(+), 18 deletions(-) create mode 100644 adapters/33across/33acrosstest/supplemental/multi-imp-mixed-validation.json diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 538b570fd09..17155f38e18 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -38,6 +38,10 @@ type TtxCaller struct { Version string `json:"version,omitempty"` } +// CALLER Info used to track Prebid Server +// as one of the hops in the request to exchange +var CALLER = TtxCaller{"Prebid-Server", "n/a"} + type bidExt struct { Ttx bidTtxExt `json:"ttx,omitempty"` } @@ -54,11 +58,10 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters // Break up multi-imp request into multiple external requests since we don't // support SRA in our exchange server for i := 0; i < len(request.Imp); i++ { - adapterReq, err := a.makeRequest(request, request.Imp[i]) - if adapterReq != nil { + // makeRequest will either return an adapterRequest or err + if adapterReq, err := a.makeRequest(request, request.Imp[i]); err == nil { adapterRequests = append(adapterRequests, adapterReq) - } - if err != nil { + } else { errs = append(errs, err) } } @@ -79,8 +82,6 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) ( reqCopy.Imp = append(imps, impCopy) // Add info about caller - caller := TtxCaller{"Prebid-Server", "n/a"} - var reqExt reqExt if len(reqCopy.Ext) > 0 { if err := json.Unmarshal(reqCopy.Ext, &reqExt); err != nil { @@ -96,7 +97,7 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) ( reqExt.Ttx.Caller = make([]TtxCaller, 0) } - reqExt.Ttx.Caller = append(reqExt.Ttx.Caller, caller) + reqExt.Ttx.Caller = append(reqExt.Ttx.Caller, CALLER) reqCopy.Ext, err = json.Marshal(reqExt) if err != nil { @@ -121,16 +122,14 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) ( } func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { - impCopy := imp - - if impCopy.Banner == nil && impCopy.Video == nil { + if imp.Banner == nil && imp.Video == nil { return openrtb.Imp{}, &errortypes.BadInput{ - Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", impCopy.ID), + Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", imp.ID), } } var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(impCopy.Ext, &bidderExt); err != nil { + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return openrtb.Imp{}, &errortypes.BadInput{ Message: err.Error(), } @@ -159,22 +158,22 @@ func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { } } - impCopy.Ext = impExtJSON + imp.Ext = impExtJSON // Validate Video if it exists - if impCopy.Video != nil { - videoCopy, err := validateVideoParams(impCopy.Video, impExt.Ttx.Prod) + if imp.Video != nil { + videoCopy, err := validateVideoParams(imp.Video, impExt.Ttx.Prod) - impCopy.Video = videoCopy + imp.Video = videoCopy if err != nil { - return impCopy, &errortypes.BadInput{ + return imp, &errortypes.BadInput{ Message: err.Error(), } } } - return impCopy, nil + return imp, nil } // MakeBids make the bids for the bid response. diff --git a/adapters/33across/33acrosstest/supplemental/multi-imp-mixed-validation.json b/adapters/33across/33acrosstest/supplemental/multi-imp-mixed-validation.json new file mode 100644 index 00000000000..a2bc7890e96 --- /dev/null +++ b/adapters/33across/33acrosstest/supplemental/multi-imp-mixed-validation.json @@ -0,0 +1,121 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id1", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "inview" + } + } + }, + { + "id": "test-imp-id2", + "ext": { + "bidder": { + "siteId": "fake-site-id", + "productId": "inview" + } + } + } + ], + "site": {} + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ssc.33across.com", + "body": { + "ext": { + "ttx": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, + "id": "test-request-id", + "imp": [ + { + "id":"test-imp-id1", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "ttx": { + "prod": "inview", + "zoneid": "fake-site-id" + } + } + } + ], + "site": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "ttx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id1", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "ext": { + "ttx": { + "mediaType": "banner" + } + } + }] + } + ], + "cur": "USD" + } + } + } + ], + "expectedMakeRequestsErrors": [ + { + "value": "Imp ID test-imp-id2 must have at least one of [Banner, Video] defined", + "comparison": "literal" + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id1", + "price": 0.5, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 728, + "h": 90, + "ext": { + "ttx": { + "mediaType": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} From 79bf68b1d9f91a884eb5ea95fa2e9c7075603076 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Mon, 14 Dec 2020 13:50:08 -0500 Subject: [PATCH 14/18] Refactored creating request ext --- adapters/33across/33across.go | 56 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 17155f38e18..0cd652b6f7d 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -55,11 +55,18 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters var errs []error var adapterRequests []*adapters.RequestData + // Construct request extension common to all imps + // NOTE: not blocking e + TTXRequestExt, err := makeReqExt(request) + if err != nil { + errs = append(errs, err) + } + // Break up multi-imp request into multiple external requests since we don't // support SRA in our exchange server for i := 0; i < len(request.Imp); i++ { // makeRequest will either return an adapterRequest or err - if adapterReq, err := a.makeRequest(request, request.Imp[i]); err == nil { + if adapterReq, err := a.makeRequest(request, request.Imp[i], TTXRequestExt); err == nil { adapterRequests = append(adapterRequests, adapterReq) } else { errs = append(errs, err) @@ -69,7 +76,7 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters return adapterRequests, errs } -func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) { +func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp, TTXRequestExt []byte) (*adapters.RequestData, error) { var imps []openrtb.Imp reqCopy := *request @@ -81,28 +88,7 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) ( reqCopy.Imp = append(imps, impCopy) - // Add info about caller - var reqExt reqExt - if len(reqCopy.Ext) > 0 { - if err := json.Unmarshal(reqCopy.Ext, &reqExt); err != nil { - return nil, err - } - } - - if reqExt.Ttx == nil { - reqExt.Ttx = &reqTtxExt{} - } - - if reqExt.Ttx.Caller == nil { - reqExt.Ttx.Caller = make([]TtxCaller, 0) - } - - reqExt.Ttx.Caller = append(reqExt.Ttx.Caller, CALLER) - - reqCopy.Ext, err = json.Marshal(reqExt) - if err != nil { - return nil, err - } + reqCopy.Ext = TTXRequestExt // Last Step reqJSON, err := json.Marshal(reqCopy) @@ -176,6 +162,28 @@ func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { return imp, nil } +func makeReqExt(request *openrtb.BidRequest) ([]byte, error) { + var reqExt reqExt + + if len(request.Ext) > 0 { + if err := json.Unmarshal(request.Ext, &reqExt); err != nil { + return nil, err + } + } + + if reqExt.Ttx == nil { + reqExt.Ttx = &reqTtxExt{} + } + + if reqExt.Ttx.Caller == nil { + reqExt.Ttx.Caller = make([]TtxCaller, 0) + } + + reqExt.Ttx.Caller = append(reqExt.Ttx.Caller, CALLER) + + return json.Marshal(reqExt) +} + // MakeBids make the bids for the bid response. func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { From 29f98fdef9507286114d4c7b777e72a234311027 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 16 Dec 2020 15:59:27 +0000 Subject: [PATCH 15/18] More optimizations based on code review --- adapters/33across/33across.go | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 0cd652b6f7d..e36b90be631 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -56,17 +56,17 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters var adapterRequests []*adapters.RequestData // Construct request extension common to all imps - // NOTE: not blocking e - TTXRequestExt, err := makeReqExt(request) + // NOTE: not blocking errors since request extension + // is optional. + reqExt, err := makeReqExt(request) if err != nil { errs = append(errs, err) } + request.Ext = reqExt - // Break up multi-imp request into multiple external requests since we don't - // support SRA in our exchange server for i := 0; i < len(request.Imp); i++ { // makeRequest will either return an adapterRequest or err - if adapterReq, err := a.makeRequest(request, request.Imp[i], TTXRequestExt); err == nil { + if adapterReq, err := a.makeRequest(*request, request.Imp[i]); err == nil { adapterRequests = append(adapterRequests, adapterReq) } else { errs = append(errs, err) @@ -76,22 +76,17 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters return adapterRequests, errs } -func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp, TTXRequestExt []byte) (*adapters.RequestData, error) { - var imps []openrtb.Imp - - reqCopy := *request +func (a *TtxAdapter) makeRequest(request openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) { impCopy, err := makeImps(imp) if err != nil { return nil, err } - reqCopy.Imp = append(imps, impCopy) - - reqCopy.Ext = TTXRequestExt + request.Imp = []openrtb.Imp{*impCopy} // Last Step - reqJSON, err := json.Marshal(reqCopy) + reqJSON, err := json.Marshal(request) if err != nil { return nil, err } @@ -107,23 +102,23 @@ func (a *TtxAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp, T }, nil } -func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { +func makeImps(imp openrtb.Imp) (*openrtb.Imp, error) { if imp.Banner == nil && imp.Video == nil { - return openrtb.Imp{}, &errortypes.BadInput{ + return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", imp.ID), } } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { - return openrtb.Imp{}, &errortypes.BadInput{ + return nil, &errortypes.BadInput{ Message: err.Error(), } } var ttxExt openrtb_ext.ExtImp33across if err := json.Unmarshal(bidderExt.Bidder, &ttxExt); err != nil { - return openrtb.Imp{}, &errortypes.BadInput{ + return nil, &errortypes.BadInput{ Message: err.Error(), } } @@ -139,7 +134,7 @@ func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { impExtJSON, err := json.Marshal(impExt) if err != nil { - return openrtb.Imp{}, &errortypes.BadInput{ + return nil, &errortypes.BadInput{ Message: err.Error(), } } @@ -153,13 +148,13 @@ func makeImps(imp openrtb.Imp) (openrtb.Imp, error) { imp.Video = videoCopy if err != nil { - return imp, &errortypes.BadInput{ + return nil, &errortypes.BadInput{ Message: err.Error(), } } } - return imp, nil + return &imp, nil } func makeReqExt(request *openrtb.BidRequest) ([]byte, error) { From 382731390916f1e91caa1a5ba8e18d27a8984c14 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 16 Dec 2020 16:01:50 +0000 Subject: [PATCH 16/18] Fixed comments --- adapters/33across/33across.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index e36b90be631..e72a69c4f6c 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -64,8 +64,9 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters } request.Ext = reqExt + // Break up multi-imp request into multiple external requests since we don't + // support SRA in our exchange server for i := 0; i < len(request.Imp); i++ { - // makeRequest will either return an adapterRequest or err if adapterReq, err := a.makeRequest(*request, request.Imp[i]); err == nil { adapterRequests = append(adapterRequests, adapterReq) } else { From 171a13d86e853a8b110e44a9d42102697bf08908 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Wed, 16 Dec 2020 16:18:24 +0000 Subject: [PATCH 17/18] made better comments --- adapters/33across/33across.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index e72a69c4f6c..b9655faab7f 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -56,8 +56,8 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters var adapterRequests []*adapters.RequestData // Construct request extension common to all imps - // NOTE: not blocking errors since request extension - // is optional. + // NOTE: not blocking adapter requests on errors + // since request extension is optional. reqExt, err := makeReqExt(request) if err != nil { errs = append(errs, err) From bc77e9a5b9a1972bfeeafa4f8bf3d0b9dd9a5c34 Mon Sep 17 00:00:00 2001 From: Aparna Rao Date: Thu, 4 Mar 2021 23:04:58 -0500 Subject: [PATCH 18/18] fixed endpoint to s2s --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 8c2bdfadb85..5559733c7c7 100755 --- a/config/config.go +++ b/config/config.go @@ -912,7 +912,7 @@ func SetupViper(v *viper.Viper, filename string) { // Disabling adapters by default that require some specific config params. // If you're using one of these, make sure you check out the documentation (https://github.com/prebid/prebid-server/tree/master/docs/bidders) // for them and specify all the parameters they need for them to work correctly. - v.SetDefault("adapters.33across.endpoint", "http://ssc.33across.com/api/v1/hb") + v.SetDefault("adapters.33across.endpoint", "https://ssc.33across.com/api/v1/s2s") v.SetDefault("adapters.33across.partner_id", "") v.SetDefault("adapters.acuityads.endpoint", "http://{{.Host}}.admanmedia.com/bid?token={{.AccountID}}") v.SetDefault("adapters.adform.endpoint", "http://adx.adform.net/adx")