From a5cc6156d34bb2668c5b975b9eca6798cd26b786 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Wed, 22 Jul 2020 13:03:14 +0300 Subject: [PATCH 01/23] initial --- adapters/adprime/adprime.go | 140 ++++++++++++++++++ adapters/adprime/adprime_test.go | 12 ++ .../adprimetest/exemplary/simple-banner.json | 134 +++++++++++++++++ .../adprimetest/exemplary/simple-video.json | 119 +++++++++++++++ .../exemplary/simple-web-banner.json | 133 +++++++++++++++++ .../adprime/adprimetest/params/banner.json | 3 + .../adprimetest/params/race/banner.json | 3 + .../adprimetest/params/race/video.json | 3 + .../adprime/adprimetest/params/video.json | 3 + .../adprimetest/supplemental/bad-imp-ext.json | 42 ++++++ .../supplemental/bad_response.json | 85 +++++++++++ .../supplemental/no-imp-ext-1.json | 39 +++++ .../supplemental/no-imp-ext-2.json | 39 +++++ .../adprimetest/supplemental/status-204.json | 79 ++++++++++ .../adprimetest/supplemental/status-404.json | 85 +++++++++++ adapters/adprime/params_test.go | 46 ++++++ config/config.go | 1 + exchange/adapter_map.go | 2 + openrtb_ext/bidders.go | 2 + openrtb_ext/imp_adprime.go | 6 + static/bidder-info/adprime.yaml | 11 ++ static/bidder-params/adprime.json | 14 ++ 22 files changed, 1001 insertions(+) create mode 100644 adapters/adprime/adprime.go create mode 100644 adapters/adprime/adprime_test.go create mode 100644 adapters/adprime/adprimetest/exemplary/simple-banner.json create mode 100644 adapters/adprime/adprimetest/exemplary/simple-video.json create mode 100644 adapters/adprime/adprimetest/exemplary/simple-web-banner.json create mode 100644 adapters/adprime/adprimetest/params/banner.json create mode 100644 adapters/adprime/adprimetest/params/race/banner.json create mode 100644 adapters/adprime/adprimetest/params/race/video.json create mode 100644 adapters/adprime/adprimetest/params/video.json create mode 100644 adapters/adprime/adprimetest/supplemental/bad-imp-ext.json create mode 100644 adapters/adprime/adprimetest/supplemental/bad_response.json create mode 100644 adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json create mode 100644 adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json create mode 100644 adapters/adprime/adprimetest/supplemental/status-204.json create mode 100644 adapters/adprime/adprimetest/supplemental/status-404.json create mode 100644 adapters/adprime/params_test.go create mode 100644 openrtb_ext/imp_adprime.go create mode 100644 static/bidder-info/adprime.yaml create mode 100644 static/bidder-params/adprime.json diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go new file mode 100644 index 00000000000..77ef984817e --- /dev/null +++ b/adapters/adprime/adprime.go @@ -0,0 +1,140 @@ +package adprime + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/mxmCherry/openrtb" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" +) + +// AdprimeAdapter struct +type AdprimeAdapter struct { + URI string +} + +// NewAdprimeBidder Initializes the Bidder +func NewAdprimeBidder(endpoint string) *AdprimeAdapter { + return &AdprimeAdapter{ + URI: endpoint, + } +} + +type adprimeParams struct { + TagID string `json:"TagID"` +} + +// MakeRequests create bid request for adprime demand +func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var errs []error + var adprimeExt openrtb_ext.ExtImpAdprime + var err error + + var adapterRequests []*adapters.RequestData + + reqCopy := *request + for _, imp := range request.Imp { + reqCopy.Imp = []openrtb.Imp{imp} + + var bidderExt adapters.ExtImpBidder + if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + errs = append(errs, err) + continue + } + + if err = json.Unmarshal(bidderExt.Bidder, &adprimeExt); err != nil { + errs = append(errs, err) + continue + } + + reqCopy.Imp[0].TagID = adprimeExt.TagID + + adapterReq, errors := a.makeRequest(&reqCopy) + if adapterReq != nil { + adapterRequests = append(adapterRequests, adapterReq) + } + errs = append(errs, errors...) + } + return adapterRequests, errs +} + +func (a *AdprimeAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { + + var errs []error + + reqJSON, err := json.Marshal(request) + + if err != nil { + errs = append(errs, err) + return nil, errs + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + return &adapters.RequestData{ + Method: "POST", + Uri: a.URI, + Body: reqJSON, + Headers: headers, + }, errs +} + +// MakeBids makes the bids +func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + var errs []error + + if response.StatusCode == http.StatusNoContent { + return nil, nil + } + + if response.StatusCode == http.StatusNotFound { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), + }} + } + + var bidResp openrtb.BidResponse + + if err := json.Unmarshal(response.Body, &bidResp); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) + + for _, sb := range bidResp.SeatBid { + for i := range sb.Bid { + bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp) + if err != nil { + errs = append(errs, err) + } else { + b := &adapters.TypedBid{ + Bid: &sb.Bid[i], + BidType: bidType, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + } + return bidResponse, errs +} + +func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { + mediaType := openrtb_ext.BidTypeBanner + for _, imp := range imps { + if imp.ID == impID { + if imp.Banner == nil && imp.Video != nil { + mediaType = openrtb_ext.BidTypeVideo + } + return mediaType, nil + } + } + + // This shouldnt happen. Lets handle it just incase by returning an error. + return "", &errortypes.BadInput{ + Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), + } +} diff --git a/adapters/adprime/adprime_test.go b/adapters/adprime/adprime_test.go new file mode 100644 index 00000000000..2d3ee9b2b3f --- /dev/null +++ b/adapters/adprime/adprime_test.go @@ -0,0 +1,12 @@ +package adprime + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" +) + +func TestJsonSamples(t *testing.T) { + adprimeAdapter := NewAdprimeBidder("http://delta.adprime.com/?c=o&m=ortb") + adapterstest.RunJSONBidderTest(t, "adprimetest", adprimeAdapter) +} diff --git a/adapters/adprime/adprimetest/exemplary/simple-banner.json b/adapters/adprime/adprimetest/exemplary/simple-banner.json new file mode 100644 index 00000000000..076175c6274 --- /dev/null +++ b/adapters/adprime/adprimetest/exemplary/simple-banner.json @@ -0,0 +1,134 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": { + "bidder": { + "TagID": "1" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } +}, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/?c=o&m=ortb", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": { + "bidder": { + "TagID": "1" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "bids":[ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/adprime/adprimetest/exemplary/simple-video.json b/adapters/adprime/adprimetest/exemplary/simple-video.json new file mode 100644 index 00000000000..3e61c4dddd1 --- /dev/null +++ b/adapters/adprime/adprimetest/exemplary/simple-video.json @@ -0,0 +1,119 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": ["video/mp4"], + "protocols": [2, 5], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "TagID": "288" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/?c=o&m=ortb", + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": ["video/mp4"], + "protocols": [2, 5], + "w": 1024, + "h": 576 + }, + "tagid": "288", + "ext": { + "bidder": { + "TagID": "288" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } + } + ], + + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/adprime/adprimetest/exemplary/simple-web-banner.json b/adapters/adprime/adprimetest/exemplary/simple-web-banner.json new file mode 100644 index 00000000000..a955854fb31 --- /dev/null +++ b/adapters/adprime/adprimetest/exemplary/simple-web-banner.json @@ -0,0 +1,133 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": { + "bidder": { + "TagID": "1" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/?c=o&m=ortb", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": { + "bidder": { + "TagID": "1" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "bids":[ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] + } + \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/banner.json b/adapters/adprime/adprimetest/params/banner.json new file mode 100644 index 00000000000..e3f4cb7605a --- /dev/null +++ b/adapters/adprime/adprimetest/params/banner.json @@ -0,0 +1,3 @@ +{ + "TagID": "1" +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/race/banner.json b/adapters/adprime/adprimetest/params/race/banner.json new file mode 100644 index 00000000000..e3f4cb7605a --- /dev/null +++ b/adapters/adprime/adprimetest/params/race/banner.json @@ -0,0 +1,3 @@ +{ + "TagID": "1" +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/race/video.json b/adapters/adprime/adprimetest/params/race/video.json new file mode 100644 index 00000000000..c8d14757903 --- /dev/null +++ b/adapters/adprime/adprimetest/params/race/video.json @@ -0,0 +1,3 @@ +{ + "TagID": "288" +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/video.json b/adapters/adprime/adprimetest/params/video.json new file mode 100644 index 00000000000..c8d14757903 --- /dev/null +++ b/adapters/adprime/adprimetest/params/video.json @@ -0,0 +1,3 @@ +{ + "TagID": "288" +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json new file mode 100644 index 00000000000..9e8671264fd --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json @@ -0,0 +1,42 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": { + "adprime": { + "TagID": "1" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } +}, +"expectedMakeRequestsErrors": [ + { + "value": "unexpected end of JSON input", + "comparison": "literal" + } +] +} diff --git a/adapters/adprime/adprimetest/supplemental/bad_response.json b/adapters/adprime/adprimetest/supplemental/bad_response.json new file mode 100644 index 00000000000..329e9c7269f --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/bad_response.json @@ -0,0 +1,85 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "17", + "ext": { + "bidder": { + "TagID": "17" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://delta.adprime.com/?c=o&m=ortb", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "17", + "ext": { + "bidder": { + "TagID": "17" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 200, + "body": "" + } + }], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "comparison": "literal" + } + ] +} diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json new file mode 100644 index 00000000000..e3570246fab --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json @@ -0,0 +1,39 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": "" + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json new file mode 100644 index 00000000000..b87bd6107ac --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json @@ -0,0 +1,39 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": {} + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "unexpected end of JSON input", + "comparison": "literal" + } + ] + } + \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/status-204.json b/adapters/adprime/adprimetest/supplemental/status-204.json new file mode 100644 index 00000000000..44ee59d4d28 --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/status-204.json @@ -0,0 +1,79 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "17", + "ext": { + "bidder": { + "TagID": "17" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://delta.adprime.com/?c=o&m=ortb", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "17", + "ext": { + "bidder": { + "TagID": "17" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + }] +} diff --git a/adapters/adprime/adprimetest/supplemental/status-404.json b/adapters/adprime/adprimetest/supplemental/status-404.json new file mode 100644 index 00000000000..b27bb2a8df6 --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/status-404.json @@ -0,0 +1,85 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "100000000", + "ext": { + "bidder": { + "TagID": "100000000" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://delta.adprime.com/?c=o&m=ortb", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "100000000", + "ext": { + "bidder": { + "TagID": "100000000" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 404, + "body": {} + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 404. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/adprime/params_test.go b/adapters/adprime/params_test.go new file mode 100644 index 00000000000..05adad5c4ff --- /dev/null +++ b/adapters/adprime/params_test.go @@ -0,0 +1,46 @@ +package adprime + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +// TestValidParams makes sure that the adprime schema accepts all imp.ext fields which we intend to support. +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, validParam := range validParams { + if err := validator.Validate(openrtb_ext.BidderAdprime, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected adprime params: %s", validParam) + } + } +} + +// TestInvalidParams makes sure that the adprime schema rejects all the imp.ext fields we don't support. +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, invalidParam := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderAdprime, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"TagID": "1"}`, +} + +var invalidParams = []string{ + `{"id": "123"}`, + `{"tagid": "123"}`, + `{"TagID": 16}`, +} diff --git a/config/config.go b/config/config.go index 2e7f875b023..6831b986289 100755 --- a/config/config.go +++ b/config/config.go @@ -776,6 +776,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") v.SetDefault("adapters.adoppler.endpoint", "http://app.trustedmarketplace.io/ads") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") + v.SetDefault("adapters.adprime.endpoint", "http://delta.adprime.com/?c=o&m=ortb") v.SetDefault("adapters.adtarget.endpoint", "http://ghb.console.adtarget.com.tr/pbs/ortb") v.SetDefault("adapters.adtelligent.endpoint", "http://ghb.adtelligent.com/pbs/ortb") v.SetDefault("adapters.advangelists.endpoint", "http://nep.advangelists.com/xp/get?pubid={{.PublisherID}}") diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index 53607ac57d8..136b36e4879 100755 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -19,6 +19,7 @@ import ( "github.com/prebid/prebid-server/adapters/adocean" "github.com/prebid/prebid-server/adapters/adoppler" "github.com/prebid/prebid-server/adapters/adpone" + "github.com/prebid/prebid-server/adapters/adprime" "github.com/prebid/prebid-server/adapters/adtarget" "github.com/prebid/prebid-server/adapters/adtelligent" "github.com/prebid/prebid-server/adapters/advangelists" @@ -105,6 +106,7 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter openrtb_ext.BidderAdOcean: adocean.NewAdOceanBidder(client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderAdOcean))].Endpoint), openrtb_ext.BidderAdoppler: adoppler.NewAdopplerBidder(cfg.Adapters[string(openrtb_ext.BidderAdoppler)].Endpoint), openrtb_ext.BidderAdpone: adpone.NewAdponeBidder(cfg.Adapters[string(openrtb_ext.BidderAdpone)].Endpoint), + openrtb_ext.BidderAdprime: adprime.NewAdprimeBidder(cfg.Adapters[string(openrtb_ext.BidderAdprime)].Endpoint), openrtb_ext.BidderAdtarget: adtarget.NewAdtargetBidder(cfg.Adapters[string(openrtb_ext.BidderAdtarget)].Endpoint), openrtb_ext.BidderAdtelligent: adtelligent.NewAdtelligentBidder(cfg.Adapters[string(openrtb_ext.BidderAdtelligent)].Endpoint), openrtb_ext.BidderAdvangelists: advangelists.NewAdvangelistsBidder(cfg.Adapters[string(openrtb_ext.BidderAdvangelists)].Endpoint), diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 62fb9750616..cdb3689ec82 100755 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -34,6 +34,7 @@ const ( BidderAdman BidderName = "adman" BidderAdmixer BidderName = "admixer" BidderAdOcean BidderName = "adocean" + BidderAdprime BidderName = "adprime" BidderAdtarget BidderName = "adtarget" BidderAdtelligent BidderName = "adtelligent" BidderAdvangelists BidderName = "advangelists" @@ -115,6 +116,7 @@ var BidderMap = map[string]BidderName{ "adman": BidderAdman, "admixer": BidderAdmixer, "adocean": BidderAdOcean, + "adprime": BidderAdprime, "adpone": BidderAdpone, "adtarget": BidderAdtarget, "adtelligent": BidderAdtelligent, diff --git a/openrtb_ext/imp_adprime.go b/openrtb_ext/imp_adprime.go new file mode 100644 index 00000000000..a6bf7d76efc --- /dev/null +++ b/openrtb_ext/imp_adprime.go @@ -0,0 +1,6 @@ +package openrtb_ext + +// ExtImpAdprime defines adprime specifiec param +type ExtImpAdprime struct { + TagID string `json:"TagID"` +} \ No newline at end of file diff --git a/static/bidder-info/adprime.yaml b/static/bidder-info/adprime.yaml new file mode 100644 index 00000000000..9759ed63be7 --- /dev/null +++ b/static/bidder-info/adprime.yaml @@ -0,0 +1,11 @@ +maintainer: + email: "rafal@adprime.com" +capabilities: + app: + mediaTypes: + - banner + - video + site: + mediaTypes: + - banner + - video \ No newline at end of file diff --git a/static/bidder-params/adprime.json b/static/bidder-params/adprime.json new file mode 100644 index 00000000000..d527056597d --- /dev/null +++ b/static/bidder-params/adprime.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Adprime Adapter Params", + "description": "A schema which validates params accepted by the Adprime adapter", + + "type": "object", + "properties": { + "TagID": { + "type": "string", + "description": "An ID which identifies the adprime ad tag" + } + }, + "required" : [ "TagID" ] + } \ No newline at end of file From 003e302399634cdc4031e7663c7b49e73286d0b4 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Wed, 22 Jul 2020 15:10:22 +0300 Subject: [PATCH 02/23] initial --- usersync/usersyncers/syncer_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index 32ab2e730eb..4857d9c8c91 100755 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -95,6 +95,7 @@ func TestNewSyncerMap(t *testing.T) { openrtb_ext.BidderPubnative: true, openrtb_ext.BidderTappx: true, openrtb_ext.BidderYeahmobi: true, + openrtb_ext.BidderAdprime: true, } for bidder, config := range cfg.Adapters { From f2d3e1093c614f2b6025c311461e4f048411c538 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Wed, 22 Jul 2020 15:15:24 +0300 Subject: [PATCH 03/23] initial --- exchange/adapter_map.go | 2 +- openrtb_ext/bidders.go | 4 ++-- openrtb_ext/imp_adprime.go | 2 +- usersync/usersyncers/syncer_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index 136b36e4879..172a07318a8 100755 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -106,7 +106,7 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter openrtb_ext.BidderAdOcean: adocean.NewAdOceanBidder(client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderAdOcean))].Endpoint), openrtb_ext.BidderAdoppler: adoppler.NewAdopplerBidder(cfg.Adapters[string(openrtb_ext.BidderAdoppler)].Endpoint), openrtb_ext.BidderAdpone: adpone.NewAdponeBidder(cfg.Adapters[string(openrtb_ext.BidderAdpone)].Endpoint), - openrtb_ext.BidderAdprime: adprime.NewAdprimeBidder(cfg.Adapters[string(openrtb_ext.BidderAdprime)].Endpoint), + openrtb_ext.BidderAdprime: adprime.NewAdprimeBidder(cfg.Adapters[string(openrtb_ext.BidderAdprime)].Endpoint), openrtb_ext.BidderAdtarget: adtarget.NewAdtargetBidder(cfg.Adapters[string(openrtb_ext.BidderAdtarget)].Endpoint), openrtb_ext.BidderAdtelligent: adtelligent.NewAdtelligentBidder(cfg.Adapters[string(openrtb_ext.BidderAdtelligent)].Endpoint), openrtb_ext.BidderAdvangelists: advangelists.NewAdvangelistsBidder(cfg.Adapters[string(openrtb_ext.BidderAdvangelists)].Endpoint), diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index cdb3689ec82..73169b776ca 100755 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -34,7 +34,7 @@ const ( BidderAdman BidderName = "adman" BidderAdmixer BidderName = "admixer" BidderAdOcean BidderName = "adocean" - BidderAdprime BidderName = "adprime" + BidderAdprime BidderName = "adprime" BidderAdtarget BidderName = "adtarget" BidderAdtelligent BidderName = "adtelligent" BidderAdvangelists BidderName = "advangelists" @@ -116,7 +116,7 @@ var BidderMap = map[string]BidderName{ "adman": BidderAdman, "admixer": BidderAdmixer, "adocean": BidderAdOcean, - "adprime": BidderAdprime, + "adprime": BidderAdprime, "adpone": BidderAdpone, "adtarget": BidderAdtarget, "adtelligent": BidderAdtelligent, diff --git a/openrtb_ext/imp_adprime.go b/openrtb_ext/imp_adprime.go index a6bf7d76efc..a089b818b56 100644 --- a/openrtb_ext/imp_adprime.go +++ b/openrtb_ext/imp_adprime.go @@ -3,4 +3,4 @@ package openrtb_ext // ExtImpAdprime defines adprime specifiec param type ExtImpAdprime struct { TagID string `json:"TagID"` -} \ No newline at end of file +} diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index 4857d9c8c91..df5a34f9d5e 100755 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -95,7 +95,7 @@ func TestNewSyncerMap(t *testing.T) { openrtb_ext.BidderPubnative: true, openrtb_ext.BidderTappx: true, openrtb_ext.BidderYeahmobi: true, - openrtb_ext.BidderAdprime: true, + openrtb_ext.BidderAdprime: true, } for bidder, config := range cfg.Adapters { From fb078180c5b51339691f7a5c334c907083b54bd2 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 11:29:24 +0300 Subject: [PATCH 04/23] use jsonparser --- adapters/adprime/adprime.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 77ef984817e..3cf9e15b663 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" + "github.com/buger/jsonparser" "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" @@ -45,12 +46,13 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap continue } + tagID, err := jsonparser.GetString(reqCopy.Imp[0].Ext, "TagID") if err = json.Unmarshal(bidderExt.Bidder, &adprimeExt); err != nil { errs = append(errs, err) continue } - reqCopy.Imp[0].TagID = adprimeExt.TagID + reqCopy.Imp[0].TagID = tagID adapterReq, errors := a.makeRequest(&reqCopy) if adapterReq != nil { From db5500471371a31e5cd390895e593bd398fd2ba4 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 12:11:55 +0300 Subject: [PATCH 05/23] use jsonparser --- adapters/adprime/adprime.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 3cf9e15b663..b31dfbe9662 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -31,8 +31,8 @@ type adprimeParams struct { // MakeRequests create bid request for adprime demand func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error - var adprimeExt openrtb_ext.ExtImpAdprime var err error + var tagID string var adapterRequests []*adapters.RequestData @@ -40,14 +40,8 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap for _, imp := range request.Imp { reqCopy.Imp = []openrtb.Imp{imp} - var bidderExt adapters.ExtImpBidder - if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { - errs = append(errs, err) - continue - } - - tagID, err := jsonparser.GetString(reqCopy.Imp[0].Ext, "TagID") - if err = json.Unmarshal(bidderExt.Bidder, &adprimeExt); err != nil { + tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "TagID") + if err != nil { errs = append(errs, err) continue } From 7e454859ad76bd545b2f1feb80c41579c27e22c1 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 12:24:01 +0300 Subject: [PATCH 06/23] log --- adapters/adprime/adprime.go | 1 + 1 file changed, 1 insertion(+) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index b31dfbe9662..0cea181ac9a 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -42,6 +42,7 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "TagID") if err != nil { + fmt.Println(err, tagID) errs = append(errs, err) continue } From e0c8993a145bd79535eb971bfcc5eddde88128af Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 12:25:37 +0300 Subject: [PATCH 07/23] log --- adapters/adprime/adprime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 0cea181ac9a..2e8a0970fea 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -42,7 +42,7 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "TagID") if err != nil { - fmt.Println(err, tagID) + fmt.Println(err, tagID, reqCopy.Imp[0].Ext) errs = append(errs, err) continue } From 502e5eadff812dd8b24b45f64c926875b98910cb Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 12:43:04 +0300 Subject: [PATCH 08/23] log --- adapters/adprime/adprime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 2e8a0970fea..6bee8b6bdd0 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -42,7 +42,7 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "TagID") if err != nil { - fmt.Println(err, tagID, reqCopy.Imp[0].Ext) + fmt.Println(err, tagID, string(reqCopy.Imp[0].Ext)) errs = append(errs, err) continue } From c11d22453d33fbea91b7a15fbc4a5ceca5292122 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 12:43:58 +0300 Subject: [PATCH 09/23] log --- adapters/adprime/adprime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 6bee8b6bdd0..200e865b9b2 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -40,7 +40,7 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap for _, imp := range request.Imp { reqCopy.Imp = []openrtb.Imp{imp} - tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "TagID") + tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID") if err != nil { fmt.Println(err, tagID, string(reqCopy.Imp[0].Ext)) errs = append(errs, err) From 005bfe6981285afa3dae567c24fdb4399e63a98d Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 12:45:56 +0300 Subject: [PATCH 10/23] log --- adapters/adprime/adprime.go | 1 - 1 file changed, 1 deletion(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 200e865b9b2..4faaa2a8bf8 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -42,7 +42,6 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID") if err != nil { - fmt.Println(err, tagID, string(reqCopy.Imp[0].Ext)) errs = append(errs, err) continue } From f81b3fabde8dad8c1d1bbc060b015e11df6ede47 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Tue, 4 Aug 2020 12:51:32 +0300 Subject: [PATCH 11/23] log --- adapters/adprime/adprimetest/supplemental/bad-imp-ext.json | 2 +- adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json | 2 +- adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json index 9e8671264fd..a95c56e8426 100644 --- a/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json +++ b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json @@ -35,7 +35,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", + "value": "Key path not found", "comparison": "literal" } ] diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json index e3570246fab..1e38dbe4541 100644 --- a/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json @@ -31,7 +31,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "value": "Key path not found", "comparison": "literal" } ] diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json index b87bd6107ac..f9759fae8ff 100644 --- a/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json @@ -31,7 +31,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "unexpected end of JSON input", + "value": "Key path not found", "comparison": "literal" } ] From fdc4d4c57879ad31ab29eb8351daf28cc099ba04 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Wed, 5 Aug 2020 17:30:40 +0300 Subject: [PATCH 12/23] add not ok status check --- adapters/adprime/adprime.go | 6 ++++++ adapters/adprime/adprimetest/supplemental/status-404.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 4faaa2a8bf8..007d3c86570 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -88,6 +88,12 @@ func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR } if response.StatusCode == http.StatusNotFound { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Page not found: %d. Run with request.debug = 1 for more info", response.StatusCode), + }} + } + + if response.StatusCode != http.StatusOK { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), }} diff --git a/adapters/adprime/adprimetest/supplemental/status-404.json b/adapters/adprime/adprimetest/supplemental/status-404.json index b27bb2a8df6..c2b303f0cb4 100644 --- a/adapters/adprime/adprimetest/supplemental/status-404.json +++ b/adapters/adprime/adprimetest/supplemental/status-404.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "Unexpected status code: 404. Run with request.debug = 1 for more info", + "value": "Page not found: 404. Run with request.debug = 1 for more info", "comparison": "literal" } ] From 19aedcac1708f365c26b6daa251384c708f49b19 Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Fri, 7 Aug 2020 10:29:55 +0300 Subject: [PATCH 13/23] remove redundad struct --- adapters/adprime/adprime.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 007d3c86570..8594cb5d2e4 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -24,10 +24,6 @@ func NewAdprimeBidder(endpoint string) *AdprimeAdapter { } } -type adprimeParams struct { - TagID string `json:"TagID"` -} - // MakeRequests create bid request for adprime demand func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error From c29889639cbf89630f5935d3f885ab392f595922 Mon Sep 17 00:00:00 2001 From: Adprime Date: Sun, 15 Aug 2021 21:32:33 +0300 Subject: [PATCH 14/23] more fixes --- adapters/adprime/adprime.go | 14 + adapters/adprime/adprime_test.go | 2 +- .../adprimetest/exemplary/simple-banner.json | 246 +++++++++--------- .../adprimetest/exemplary/simple-video.json | 228 ++++++++-------- .../exemplary/simple-web-banner.json | 229 ++++++++-------- .../adprime/adprimetest/params/banner.json | 2 +- .../adprimetest/params/race/banner.json | 2 +- .../adprimetest/params/race/video.json | 2 +- .../adprime/adprimetest/params/video.json | 2 +- .../supplemental/bad_response.json | 8 +- .../adprimetest/supplemental/status-204.json | 8 +- .../adprimetest/supplemental/status-404.json | 8 +- adapters/adprime/params_test.go | 2 +- config/config.go | 2 +- static/bidder-info/adprime.yaml | 2 + 15 files changed, 395 insertions(+), 362 deletions(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 70fbd6b399b..030de24115e 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -46,6 +46,20 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada reqCopy.Imp[0].TagID = tagID + ext := map[string]interface{}{ + "bidder": map[string]interface{}{ + "TagID": tagID, + "placementId": tagID, + }, + } + + newExt, err := json.Marshal(ext) + if err != nil { + errs = append(errs, err) + return nil, errs + } + reqCopy.Imp[0].Ext = newExt + adapterReq, errors := a.makeRequest(&reqCopy) if adapterReq != nil { adapterRequests = append(adapterRequests, adapterReq) diff --git a/adapters/adprime/adprime_test.go b/adapters/adprime/adprime_test.go index ff12381d053..113233ee507 100644 --- a/adapters/adprime/adprime_test.go +++ b/adapters/adprime/adprime_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderAdprime, config.Adapter{ - Endpoint: "http://delta.adprime.com/?c=o&m=ortb"}) + Endpoint: "http://delta.adprime.com/pserver"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) diff --git a/adapters/adprime/adprimetest/exemplary/simple-banner.json b/adapters/adprime/adprimetest/exemplary/simple-banner.json index 076175c6274..e96abe5cff1 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-banner.json +++ b/adapters/adprime/adprimetest/exemplary/simple-banner.json @@ -1,134 +1,134 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ] + }, + "httpCalls": [ { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" }, - { - "w": 300, - "h": 600 + "device": { + "ip": "123.123.123.123", + "ua": "iPad" } - ] + } }, - "tagid": "1", - "ext": { - "bidder": { - "TagID": "1" + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" } } } ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } -}, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://delta.adprime.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "1", - "ext": { - "bidder": { - "TagID": "1" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } - } - ], - "seat": "adprime" - } - ], - "cur": "USD" - } - } - } - ], - - "expectedBidResponses": [ - { - "bids":[ + "expectedBidResponses": [ { - "bid": { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } - }, - "type": "banner" + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] } - ] - } - ] -} + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/exemplary/simple-video.json b/adapters/adprime/adprimetest/exemplary/simple-video.json index 3e61c4dddd1..164e3040b1d 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-video.json +++ b/adapters/adprime/adprimetest/exemplary/simple-video.json @@ -1,119 +1,129 @@ { - "mockBidRequest": { - "id": "test-request-id", - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - }, - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "imp": [ - { - "id": "test-imp-id", - "video": { - "mimes": ["video/mp4"], - "protocols": [2, 5], - "w": 1024, - "h": 576 - }, - "ext": { - "bidder": { - "TagID": "288" - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://delta.adprime.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "device": { + "mockBidRequest": { + "id": "test-request-id", + "device": { "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - }, - "app": { + "ua": "iPad" + }, + "app": { "id": "1", "bundle": "com.wls.testwlsapplication" - }, - "imp": [ + }, + "imp": [ { - "id": "test-imp-id", - "video": { - "mimes": ["video/mp4"], - "protocols": [2, 5], - "w": 1024, - "h": 576 - }, - "tagid": "288", - "ext": { - "bidder": { - "TagID": "288" + "id": "test-imp-id", + "tagid": "test", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" } - } } - ] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "00:01:00", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } - } - ], - "seat": "adprime" - } - ], - "cur": "USD" } - } - } - ], - - - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ + ], + "expectedBidResponses": [ { - "bid": { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "00:01:00", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } - }, - "type": "video" + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + }, + "type": "video" + } + ] } - ] - } - ] -} + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/exemplary/simple-web-banner.json b/adapters/adprime/adprimetest/exemplary/simple-web-banner.json index a955854fb31..74797b199b6 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-web-banner.json +++ b/adapters/adprime/adprimetest/exemplary/simple-web-banner.json @@ -1,133 +1,134 @@ { "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "1", - "ext": { - "bidder": { - "TagID": "1" - } - } - } - ], - "site": { - "id": "1", - "domain": "test.com" - }, - "device": { - "ip": "123.123.123.123" - } - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://delta.adprime.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "1", - "ext": { - "bidder": { - "TagID": "1" + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 } + ] + }, + "ext": { + "bidder": { + "TagID": "test", + "placementId": "test" } } - ], - "site": { - "id": "1", - "domain": "test.com" - }, - "device": { - "ip": "123.123.123.123" } - } + ], + "site": { + "id": "1", + "domain": "test.com" }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ + "device": { + "ip": "123.123.123.123", + "ua": "Ubuntu" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 468, - "h": 60, + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, "ext": { - "prebid": { - "type": "banner" + "bidder": { + "placementId": "test", + "TagID": "test" } } } ], - "seat": "adprime" + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123", + "ua": "Ubuntu" + } } - ], - "cur": "USD" - } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } } - } ], - "expectedBidResponses": [ - { - "bids":[ - { - "bid": { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 468, - "h": 60, - "ext": { - "prebid": { - "type": "banner" - } + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" } - }, - "type": "banner" - } - ] - } + ] + } ] - } - \ No newline at end of file +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/banner.json b/adapters/adprime/adprimetest/params/banner.json index e3f4cb7605a..22651f516d6 100644 --- a/adapters/adprime/adprimetest/params/banner.json +++ b/adapters/adprime/adprimetest/params/banner.json @@ -1,3 +1,3 @@ { - "TagID": "1" + "TagID": "test" } \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/race/banner.json b/adapters/adprime/adprimetest/params/race/banner.json index e3f4cb7605a..22651f516d6 100644 --- a/adapters/adprime/adprimetest/params/race/banner.json +++ b/adapters/adprime/adprimetest/params/race/banner.json @@ -1,3 +1,3 @@ { - "TagID": "1" + "TagID": "test" } \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/race/video.json b/adapters/adprime/adprimetest/params/race/video.json index c8d14757903..22651f516d6 100644 --- a/adapters/adprime/adprimetest/params/race/video.json +++ b/adapters/adprime/adprimetest/params/race/video.json @@ -1,3 +1,3 @@ { - "TagID": "288" + "TagID": "test" } \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/video.json b/adapters/adprime/adprimetest/params/video.json index c8d14757903..22651f516d6 100644 --- a/adapters/adprime/adprimetest/params/video.json +++ b/adapters/adprime/adprimetest/params/video.json @@ -1,3 +1,3 @@ { - "TagID": "288" + "TagID": "test" } \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/bad_response.json b/adapters/adprime/adprimetest/supplemental/bad_response.json index 435529a485c..acec885f98a 100644 --- a/adapters/adprime/adprimetest/supplemental/bad_response.json +++ b/adapters/adprime/adprimetest/supplemental/bad_response.json @@ -19,7 +19,8 @@ "tagid": "17", "ext": { "bidder": { - "TagID": "17" + "TagID": "17", + "placementId": "17" } } } @@ -35,7 +36,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://delta.adprime.com/?c=o&m=ortb", + "uri": "http://delta.adprime.com/pserver", "body": { "id": "test-request-id", "imp": [ @@ -56,7 +57,8 @@ "tagid": "17", "ext": { "bidder": { - "TagID": "17" + "TagID": "17", + "placementId": "17" } } } diff --git a/adapters/adprime/adprimetest/supplemental/status-204.json b/adapters/adprime/adprimetest/supplemental/status-204.json index 4fa57dcee86..c0c2f346fb7 100644 --- a/adapters/adprime/adprimetest/supplemental/status-204.json +++ b/adapters/adprime/adprimetest/supplemental/status-204.json @@ -19,7 +19,8 @@ "tagid": "17", "ext": { "bidder": { - "TagID": "17" + "TagID": "17", + "placementId": "17" } } } @@ -35,7 +36,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://delta.adprime.com/?c=o&m=ortb", + "uri": "http://delta.adprime.com/pserver", "body": { "id": "test-request-id", "imp": [ @@ -56,7 +57,8 @@ "tagid": "17", "ext": { "bidder": { - "TagID": "17" + "TagID": "17", + "placementId": "17" } } } diff --git a/adapters/adprime/adprimetest/supplemental/status-404.json b/adapters/adprime/adprimetest/supplemental/status-404.json index c2b303f0cb4..6cd718548d3 100644 --- a/adapters/adprime/adprimetest/supplemental/status-404.json +++ b/adapters/adprime/adprimetest/supplemental/status-404.json @@ -19,7 +19,8 @@ "tagid": "100000000", "ext": { "bidder": { - "TagID": "100000000" + "TagID": "100000000", + "placementId": "100000000" } } } @@ -35,7 +36,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://delta.adprime.com/?c=o&m=ortb", + "uri": "http://delta.adprime.com/pserver", "body": { "id": "test-request-id", "imp": [ @@ -56,7 +57,8 @@ "tagid": "100000000", "ext": { "bidder": { - "TagID": "100000000" + "TagID": "100000000", + "placementId": "100000000" } } } diff --git a/adapters/adprime/params_test.go b/adapters/adprime/params_test.go index 05adad5c4ff..b466c658ede 100644 --- a/adapters/adprime/params_test.go +++ b/adapters/adprime/params_test.go @@ -36,7 +36,7 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"TagID": "1"}`, + `{"TagID": "test"}`, } var invalidParams = []string{ diff --git a/config/config.go b/config/config.go index 865c422ffb8..f09b2e9fcf9 100644 --- a/config/config.go +++ b/config/config.go @@ -864,7 +864,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") - v.SetDefault("adapters.adprime.endpoint", "http://delta.adprime.com/?c=o&m=ortb") + v.SetDefault("adapters.adprime.endpoint", "http://delta.adprime.com/pserver") v.SetDefault("adapters.adtarget.endpoint", "http://ghb.console.adtarget.com.tr/pbs/ortb") v.SetDefault("adapters.adtelligent.endpoint", "http://ghb.adtelligent.com/pbs/ortb") v.SetDefault("adapters.advangelists.endpoint", "http://nep.advangelists.com/xp/get?pubid={{.PublisherID}}") diff --git a/static/bidder-info/adprime.yaml b/static/bidder-info/adprime.yaml index d702521ec75..4e5ff75fb71 100644 --- a/static/bidder-info/adprime.yaml +++ b/static/bidder-info/adprime.yaml @@ -5,7 +5,9 @@ capabilities: mediaTypes: - banner - video + - native site: mediaTypes: - banner - video + - native From f7a26325ee76321da7149464cb0fbfc8434d934b Mon Sep 17 00:00:00 2001 From: Adprime Date: Sun, 15 Aug 2021 22:02:34 +0300 Subject: [PATCH 15/23] add native --- .../adprimetest/exemplary/simple-native.json | 118 ++++++++++++++++++ .../adprime/adprimetest/params/native.json | 3 + .../adprimetest/params/race/native.json | 3 + 3 files changed, 124 insertions(+) create mode 100644 adapters/adprime/adprimetest/exemplary/simple-native.json create mode 100644 adapters/adprime/adprimetest/params/native.json create mode 100644 adapters/adprime/adprimetest/params/race/native.json diff --git a/adapters/adprime/adprimetest/exemplary/simple-native.json b/adapters/adprime/adprimetest/exemplary/simple-native.json new file mode 100644 index 00000000000..c94922d7d3c --- /dev/null +++ b/adapters/adprime/adprimetest/exemplary/simple-native.json @@ -0,0 +1,118 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "native": { + "request": "{\"ver\":\"1.1\",\"layout\":1,\"adunit\":2,\"plcmtcnt\":6,\"plcmttype\":4,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"wmin\":492,\"hmin\":328,\"type\":3,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":4,\"required\":0,\"data\":{\"type\":6}},{\"id\":5,\"required\":0,\"data\":{\"type\":7}},{\"id\":6,\"required\":0,\"data\":{\"type\":1,\"len\":20}}]}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "native": { + "request": "{\"ver\":\"1.1\",\"layout\":1,\"adunit\":2,\"plcmtcnt\":6,\"plcmttype\":4,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"wmin\":492,\"hmin\":328,\"type\":3,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":4,\"required\":0,\"data\":{\"type\":6}},{\"id\":5,\"required\":0,\"data\":{\"type\":7}},{\"id\":6,\"required\":0,\"data\":{\"type\":1,\"len\":20}}]}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/native.json b/adapters/adprime/adprimetest/params/native.json new file mode 100644 index 00000000000..22651f516d6 --- /dev/null +++ b/adapters/adprime/adprimetest/params/native.json @@ -0,0 +1,3 @@ +{ + "TagID": "test" +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/race/native.json b/adapters/adprime/adprimetest/params/race/native.json new file mode 100644 index 00000000000..22651f516d6 --- /dev/null +++ b/adapters/adprime/adprimetest/params/race/native.json @@ -0,0 +1,3 @@ +{ + "TagID": "test" +} \ No newline at end of file From e0747e1c07ce2e5aa3b5c718d46fced0c73085ae Mon Sep 17 00:00:00 2001 From: Adprime Date: Mon, 16 Aug 2021 03:57:16 +0300 Subject: [PATCH 16/23] add keywords and odiences --- adapters/adprime/adprime.go | 50 ++++++++++--- .../adprime/adprimetest/params/banner.json | 3 - .../adprime/adprimetest/params/native.json | 3 - .../adprime/adprimetest/params/video.json | 3 - .../adprimetest/supplemental/bad-imp-ext.json | 72 +++++++++--------- .../supplemental/no-imp-ext-1.json | 73 +++++++++---------- .../supplemental/no-imp-ext-2.json | 73 +++++++++---------- openrtb_ext/imp_adprime.go | 4 +- static/bidder-params/adprime.json | 29 ++++++-- 9 files changed, 171 insertions(+), 139 deletions(-) delete mode 100644 adapters/adprime/adprimetest/params/banner.json delete mode 100644 adapters/adprime/adprimetest/params/native.json delete mode 100644 adapters/adprime/adprimetest/params/video.json diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 030de24115e..d6aa5fcff95 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" "net/http" + "strings" - "github.com/buger/jsonparser" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" @@ -30,36 +30,62 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters func (a *AdprimeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var err error - var tagID string var adapterRequests []*adapters.RequestData + var bidderExt adapters.ExtImpBidder + var adprimeExt openrtb_ext.ExtImpAdprime + reqCopy := *request for _, imp := range request.Imp { reqCopy.Imp = []openrtb2.Imp{imp} - tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID") + err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt) if err != nil { errs = append(errs, err) - continue + return nil, errs } - reqCopy.Imp[0].TagID = tagID - - ext := map[string]interface{}{ - "bidder": map[string]interface{}{ - "TagID": tagID, - "placementId": tagID, - }, + err = json.Unmarshal(bidderExt.Bidder, &adprimeExt) + if err != nil { + errs = append(errs, err) + return nil, errs } - newExt, err := json.Marshal(ext) + // tagId + tagID := adprimeExt.TagID + reqCopy.Imp[0].TagID = tagID + + // placementId + newExt, err := json.Marshal( + map[string]interface{}{ + "bidder": map[string]interface{}{ + "TagID": tagID, + "placementId": tagID, + }, + }) if err != nil { errs = append(errs, err) return nil, errs } reqCopy.Imp[0].Ext = newExt + // keywords + if len(adprimeExt.Keywords) > 0 { + if reqCopy.Site == nil { + reqCopy.Site = &openrtb2.Site{} + } + reqCopy.Site.Keywords = strings.Join(adprimeExt.Keywords, ",") + } + + // audiences + if len(adprimeExt.Audiences) > 0 { + if reqCopy.User == nil { + reqCopy.User = &openrtb2.User{} + } + reqCopy.User.CustomData = strings.Join(adprimeExt.Audiences, ",") + } + adapterReq, errors := a.makeRequest(&reqCopy) if adapterReq != nil { adapterRequests = append(adapterRequests, adapterReq) diff --git a/adapters/adprime/adprimetest/params/banner.json b/adapters/adprime/adprimetest/params/banner.json deleted file mode 100644 index 22651f516d6..00000000000 --- a/adapters/adprime/adprimetest/params/banner.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "TagID": "test" -} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/native.json b/adapters/adprime/adprimetest/params/native.json deleted file mode 100644 index 22651f516d6..00000000000 --- a/adapters/adprime/adprimetest/params/native.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "TagID": "test" -} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/params/video.json b/adapters/adprime/adprimetest/params/video.json deleted file mode 100644 index 22651f516d6..00000000000 --- a/adapters/adprime/adprimetest/params/video.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "TagID": "test" -} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json index a95c56e8426..39cd3cd02ce 100644 --- a/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json +++ b/adapters/adprime/adprimetest/supplemental/bad-imp-ext.json @@ -1,42 +1,42 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": { + "adprime": { + "TagID": "1" } - ] - }, - "tagid": "1", - "ext": { - "adprime": { - "TagID": "1" } } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } -}, -"expectedMakeRequestsErrors": [ - { - "value": "Key path not found", - "comparison": "literal" - } -] -} + "expectedMakeRequestsErrors": [ + { + "value": "unexpected end of JSON input", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json index 1e38dbe4541..5ba65925a70 100644 --- a/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-1.json @@ -1,39 +1,38 @@ { "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "1", - "ext": "" - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } - }, - "expectedMakeRequestsErrors": [ - { - "value": "Key path not found", - "comparison": "literal" - } - ] - } - \ No newline at end of file + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": "" + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json index f9759fae8ff..e08f5385b88 100644 --- a/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json +++ b/adapters/adprime/adprimetest/supplemental/no-imp-ext-2.json @@ -1,39 +1,38 @@ { "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "1", - "ext": {} - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } - }, - "expectedMakeRequestsErrors": [ - { - "value": "Key path not found", - "comparison": "literal" - } - ] - } - \ No newline at end of file + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "1", + "ext": {} + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "unexpected end of JSON input", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/openrtb_ext/imp_adprime.go b/openrtb_ext/imp_adprime.go index a089b818b56..608f5670056 100644 --- a/openrtb_ext/imp_adprime.go +++ b/openrtb_ext/imp_adprime.go @@ -2,5 +2,7 @@ package openrtb_ext // ExtImpAdprime defines adprime specifiec param type ExtImpAdprime struct { - TagID string `json:"TagID"` + TagID string `json:"TagID"` + Keywords []string `json:"keywords"` + Audiences []string `json:"audiences"` } diff --git a/static/bidder-params/adprime.json b/static/bidder-params/adprime.json index d527056597d..23f7cb947ac 100644 --- a/static/bidder-params/adprime.json +++ b/static/bidder-params/adprime.json @@ -2,13 +2,28 @@ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Adprime Adapter Params", "description": "A schema which validates params accepted by the Adprime adapter", - "type": "object", "properties": { - "TagID": { - "type": "string", - "description": "An ID which identifies the adprime ad tag" - } + "TagID": { + "type": "string", + "description": "An ID which identifies the adprime ad tag" + }, + "keywords": { + "type": "array", + "description": "page context keywords", + "items": { + "type": "string" + } + }, + "audiences": { + "type": "array", + "description": "publisher audiences", + "items": { + "type": "string" + } + } }, - "required" : [ "TagID" ] - } \ No newline at end of file + "required": [ + "TagID" + ] +} \ No newline at end of file From d1b15218f1135e7fbeac36359de9c77eef7a5b34 Mon Sep 17 00:00:00 2001 From: Adprime Date: Tue, 17 Aug 2021 10:45:04 +0300 Subject: [PATCH 17/23] fix --- adapters/adprime/adprime.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index d6aa5fcff95..ebdddce1d64 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -169,6 +169,9 @@ func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, if imp.Banner == nil && imp.Video != nil { mediaType = openrtb_ext.BidTypeVideo } + if imp.Banner == nil && imp.Video == nil && imp.Native != nil { + mediaType = openrtb_ext.BidTypeNative + } return mediaType, nil } } From 3974a1895727f7d6e15025fbacaf6a1337bd6c73 Mon Sep 17 00:00:00 2001 From: Adprime Date: Tue, 17 Aug 2021 11:09:08 +0300 Subject: [PATCH 18/23] fix test --- adapters/adprime/adprimetest/exemplary/simple-native.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adapters/adprime/adprimetest/exemplary/simple-native.json b/adapters/adprime/adprimetest/exemplary/simple-native.json index c94922d7d3c..0ea8a0a1e3f 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-native.json +++ b/adapters/adprime/adprimetest/exemplary/simple-native.json @@ -77,7 +77,7 @@ "h": 250, "ext": { "prebid": { - "type": "banner" + "type": "native" } } } @@ -106,11 +106,11 @@ "h": 250, "ext": { "prebid": { - "type": "banner" + "type": "native" } } }, - "type": "banner" + "type": "native" } ] } From 80371b647d3a19757954409fdc1f9210e0dc90a3 Mon Sep 17 00:00:00 2001 From: Adprime Date: Mon, 30 Aug 2021 17:50:18 +0300 Subject: [PATCH 19/23] fix --- adapters/adprime/adprime.go | 29 ++-- .../adprimetest/exemplary/withAudiences.json | 138 ++++++++++++++++++ .../adprimetest/exemplary/withKeywords.json | 136 +++++++++++++++++ .../supplemental/bad_media_type.json | 91 ++++++++++++ .../adprimetest/supplemental/status-400.json | 87 +++++++++++ 5 files changed, 467 insertions(+), 14 deletions(-) create mode 100644 adapters/adprime/adprimetest/exemplary/withAudiences.json create mode 100644 adapters/adprime/adprimetest/exemplary/withKeywords.json create mode 100644 adapters/adprime/adprimetest/supplemental/bad_media_type.json create mode 100644 adapters/adprime/adprimetest/supplemental/status-400.json diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index ebdddce1d64..afdb7504623 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -71,11 +71,10 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada reqCopy.Imp[0].Ext = newExt // keywords - if len(adprimeExt.Keywords) > 0 { - if reqCopy.Site == nil { - reqCopy.Site = &openrtb2.Site{} - } - reqCopy.Site.Keywords = strings.Join(adprimeExt.Keywords, ",") + if reqCopy.Site != nil && len(adprimeExt.Keywords) > 0 { + siteCopy := *reqCopy.Site + siteCopy.Keywords = strings.Join(adprimeExt.Keywords, ",") + reqCopy.Site = &siteCopy } // audiences @@ -83,7 +82,9 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada if reqCopy.User == nil { reqCopy.User = &openrtb2.User{} } - reqCopy.User.CustomData = strings.Join(adprimeExt.Audiences, ",") + userCopy := *reqCopy.User + userCopy.CustomData = strings.Join(adprimeExt.Audiences, ",") + reqCopy.User = &userCopy } adapterReq, errors := a.makeRequest(&reqCopy) @@ -163,21 +164,21 @@ func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external } func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { - mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { - if imp.Banner == nil && imp.Video != nil { - mediaType = openrtb_ext.BidTypeVideo + if imp.Banner != nil { + return openrtb_ext.BidTypeBanner, nil + } + if imp.Video != nil { + return openrtb_ext.BidTypeVideo, nil } - if imp.Banner == nil && imp.Video == nil && imp.Native != nil { - mediaType = openrtb_ext.BidTypeNative + if imp.Native != nil { + return openrtb_ext.BidTypeNative, nil } - return mediaType, nil } } - // This shouldnt happen. Lets handle it just incase by returning an error. return "", &errortypes.BadInput{ - Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), + Message: fmt.Sprintf("Failed to find impression \"%s\"", impID), } } diff --git a/adapters/adprime/adprimetest/exemplary/withAudiences.json b/adapters/adprime/adprimetest/exemplary/withAudiences.json new file mode 100644 index 00000000000..ed8e1c003b3 --- /dev/null +++ b/adapters/adprime/adprimetest/exemplary/withAudiences.json @@ -0,0 +1,138 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "site": { + "id": "1", + "domain": "test.com" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test", + "audiences": ["aud1", "aud2"] + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "user": { + "customdata": "aud1,aud2" + }, + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/exemplary/withKeywords.json b/adapters/adprime/adprimetest/exemplary/withKeywords.json new file mode 100644 index 00000000000..3e1528fe78e --- /dev/null +++ b/adapters/adprime/adprimetest/exemplary/withKeywords.json @@ -0,0 +1,136 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "site": { + "id": "1", + "domain": "test.com" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test", + "keywords": ["keyw1", "keyw2"] + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com", + "keywords": "keyw1,keyw2" + }, + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/bad_media_type.json b/adapters/adprime/adprimetest/supplemental/bad_media_type.json new file mode 100644 index 00000000000..e91a0138449 --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/bad_media_type.json @@ -0,0 +1,91 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "ext": { + "bidder": { + "TagID": "test", + "placementId": "test" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123", + "ua": "Ubuntu" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "ext": { + "bidder": { + "placementId": "test", + "TagID": "test" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123", + "ua": "Ubuntu" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "adprime" + } + ], + "cur": "USD" + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Failed to find impression \"test-imp-id\"", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adprime/adprimetest/supplemental/status-400.json b/adapters/adprime/adprimetest/supplemental/status-400.json new file mode 100644 index 00000000000..ab1c38a0346 --- /dev/null +++ b/adapters/adprime/adprimetest/supplemental/status-400.json @@ -0,0 +1,87 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "100000000", + "ext": { + "bidder": { + "TagID": "100000000", + "placementId": "100000000" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://delta.adprime.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "tagid": "100000000", + "ext": { + "bidder": { + "TagID": "100000000", + "placementId": "100000000" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} From 63f14618c246bacb62a60d3c0c9c84400233cf6f Mon Sep 17 00:00:00 2001 From: Adprime Date: Wed, 1 Sep 2021 11:29:22 +0300 Subject: [PATCH 20/23] fix --- adapters/adprime/adprime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index afdb7504623..c907380db8d 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -78,7 +78,7 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada } // audiences - if len(adprimeExt.Audiences) > 0 { + if reqCopy.Site != nil && len(adprimeExt.Audiences) > 0 { if reqCopy.User == nil { reqCopy.User = &openrtb2.User{} } From 2d7e0dab879c89425e89014b1fd2235c2a2753a8 Mon Sep 17 00:00:00 2001 From: Adprime Date: Thu, 1 Feb 2024 16:20:04 +0200 Subject: [PATCH 21/23] add mtype --- adapters/adprime/adprime.go | 30 ++++++++----------- .../adprimetest/exemplary/simple-banner.json | 2 ++ .../adprimetest/exemplary/simple-native.json | 2 ++ .../adprimetest/exemplary/simple-video.json | 2 ++ .../exemplary/simple-web-banner.json | 2 ++ .../supplemental/bad_media_type.json | 2 +- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index fe5f640ed6c..b53ab4aa7dc 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -148,7 +148,8 @@ func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external for _, sb := range bidResp.SeatBid { for i := range sb.Bid { - bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp) + bidType, err := getBidMediaType(&sb.Bid[i]) + if err != nil { errs = append(errs, err) } else { @@ -163,22 +164,15 @@ func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, external return bidResponse, errs } -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.Video != nil { - return openrtb_ext.BidTypeVideo, nil - } - if 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) } } diff --git a/adapters/adprime/adprimetest/exemplary/simple-banner.json b/adapters/adprime/adprimetest/exemplary/simple-banner.json index e96abe5cff1..88ed1770d14 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-banner.json +++ b/adapters/adprime/adprimetest/exemplary/simple-banner.json @@ -91,6 +91,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 1, "ext": { "prebid": { "type": "banner" @@ -120,6 +121,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 1, "ext": { "prebid": { "type": "banner" diff --git a/adapters/adprime/adprimetest/exemplary/simple-native.json b/adapters/adprime/adprimetest/exemplary/simple-native.json index 0ea8a0a1e3f..4ec94edeb50 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-native.json +++ b/adapters/adprime/adprimetest/exemplary/simple-native.json @@ -75,6 +75,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 4, "ext": { "prebid": { "type": "native" @@ -104,6 +105,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 4, "ext": { "prebid": { "type": "native" diff --git a/adapters/adprime/adprimetest/exemplary/simple-video.json b/adapters/adprime/adprimetest/exemplary/simple-video.json index 164e3040b1d..722cfd29612 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-video.json +++ b/adapters/adprime/adprimetest/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/adprime/adprimetest/exemplary/simple-web-banner.json b/adapters/adprime/adprimetest/exemplary/simple-web-banner.json index 74797b199b6..db518934055 100644 --- a/adapters/adprime/adprimetest/exemplary/simple-web-banner.json +++ b/adapters/adprime/adprimetest/exemplary/simple-web-banner.json @@ -91,6 +91,7 @@ "dealid": "test_dealid", "w": 468, "h": 60, + "mtype": 1, "ext": { "prebid": { "type": "banner" @@ -120,6 +121,7 @@ "dealid": "test_dealid", "w": 468, "h": 60, + "mtype": 1, "ext": { "prebid": { "type": "banner" diff --git a/adapters/adprime/adprimetest/supplemental/bad_media_type.json b/adapters/adprime/adprimetest/supplemental/bad_media_type.json index d58833702f5..3dce9019174 100644 --- a/adapters/adprime/adprimetest/supplemental/bad_media_type.json +++ b/adapters/adprime/adprimetest/supplemental/bad_media_type.json @@ -85,7 +85,7 @@ "expectedBidResponses": [{"currency":"USD","bids":[]}], "expectedMakeBidsErrors": [ { - "value": "Failed to find impression \"test-imp-id\"", + "value": "Unable to fetch mediaType in multi-format: test-imp-id", "comparison": "literal" } ] From 8ac24f22adc41c784b1face4742e73041cbd341f Mon Sep 17 00:00:00 2001 From: Adprime Date: Tue, 6 Feb 2024 12:09:23 +0200 Subject: [PATCH 22/23] fix test --- adapters/adprime/adprimetest/exemplary/withAudiences.json | 2 ++ adapters/adprime/adprimetest/exemplary/withKeywords.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/adapters/adprime/adprimetest/exemplary/withAudiences.json b/adapters/adprime/adprimetest/exemplary/withAudiences.json index ed8e1c003b3..40a0304656b 100644 --- a/adapters/adprime/adprimetest/exemplary/withAudiences.json +++ b/adapters/adprime/adprimetest/exemplary/withAudiences.json @@ -95,6 +95,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 1, "ext": { "prebid": { "type": "banner" @@ -124,6 +125,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 1, "ext": { "prebid": { "type": "banner" diff --git a/adapters/adprime/adprimetest/exemplary/withKeywords.json b/adapters/adprime/adprimetest/exemplary/withKeywords.json index 3e1528fe78e..b7018097902 100644 --- a/adapters/adprime/adprimetest/exemplary/withKeywords.json +++ b/adapters/adprime/adprimetest/exemplary/withKeywords.json @@ -93,6 +93,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 1, "ext": { "prebid": { "type": "banner" @@ -122,6 +123,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, + "mtype": 1, "ext": { "prebid": { "type": "banner" From 5536e9c909711b66cd2c7064b5ee858d660222b0 Mon Sep 17 00:00:00 2001 From: Adprime Date: Sun, 23 Jun 2024 12:41:23 +0300 Subject: [PATCH 23/23] add userSync --- static/bidder-info/adprime.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/static/bidder-info/adprime.yaml b/static/bidder-info/adprime.yaml index 2aab94c6b9d..79d938ad264 100644 --- a/static/bidder-info/adprime.yaml +++ b/static/bidder-info/adprime.yaml @@ -12,3 +12,10 @@ capabilities: - banner - video - native +userSync: + redirect: + url: "https://sync.adprime.com/pbserver?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&ccpa={{.USPrivacy}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}}&redir={{.RedirectURL}}" + userMacro: "[UID]" + iframe: + url: "https://sync.adprime.com/pbserverIframe?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&ccpa={{.USPrivacy}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}}&pbserverUrl={{.RedirectURL}}" + userMacro: "[UID]"