From f91e3057a4e71026e549de0bb46294a51840a094 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Wed, 10 Apr 2024 14:01:00 -0600 Subject: [PATCH 01/48] adds empty files for concert adapter --- adapters/concert/concert.go | 0 adapters/concert/concert_test.go | 0 static/bidder-info/concert.yaml | 0 static/bidder-params/concert.json | 7 +++++++ 4 files changed, 7 insertions(+) create mode 100644 adapters/concert/concert.go create mode 100644 adapters/concert/concert_test.go create mode 100644 static/bidder-info/concert.yaml create mode 100644 static/bidder-params/concert.json diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go new file mode 100644 index 00000000000..e69de29bb2d diff --git a/adapters/concert/concert_test.go b/adapters/concert/concert_test.go new file mode 100644 index 00000000000..e69de29bb2d diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/static/bidder-params/concert.json b/static/bidder-params/concert.json new file mode 100644 index 00000000000..a10b3dfbb03 --- /dev/null +++ b/static/bidder-params/concert.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Concert Adapter Params", + "description": "A schema which validates params accepted by the Concert adapter", + "type": "object", + "properties": {} + } \ No newline at end of file From d34e43224f4303507a70bdd6935cb0a027463013 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 11 Apr 2024 11:16:27 -0600 Subject: [PATCH 02/48] adds placeholder config options --- static/bidder-info/concert.yaml | 32 +++++++++++++++++++++++++++++++ static/bidder-params/concert.json | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index e69de29bb2d..02c2d918816 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -0,0 +1,32 @@ +endpoint: "https://bids.concert.io/bids/openrtb" +endpointCompression: gzip +geoscope: + - USA + - CAN +maintainer: + email: prebid-maintainer@example.com +gvlVendorID: 42 +modifyingVastXmlAllowed: true +capabilities: + app: + mediaTypes: + - banner + - video + - audio + - native + site: + mediaTypes: + - banner + - video + - audio + - native + dooh: + mediaTypes: + - banner + - video + - audio + - native +userSync: + redirect: + url: https://bids.concert.io/sync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect={{.RedirectURL}} + userMacro: $UID \ No newline at end of file diff --git a/static/bidder-params/concert.json b/static/bidder-params/concert.json index a10b3dfbb03..b983ec4c131 100644 --- a/static/bidder-params/concert.json +++ b/static/bidder-params/concert.json @@ -4,4 +4,4 @@ "description": "A schema which validates params accepted by the Concert adapter", "type": "object", "properties": {} - } \ No newline at end of file + } \ No newline at end of file From 5aeb95f5f7c800e2e27b486fa3952015f66da0f3 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 11 Apr 2024 11:27:22 -0600 Subject: [PATCH 03/48] omits gvlVendorId from config --- static/bidder-info/concert.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index 02c2d918816..ab6b88f43ce 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -2,10 +2,8 @@ endpoint: "https://bids.concert.io/bids/openrtb" endpointCompression: gzip geoscope: - USA - - CAN maintainer: email: prebid-maintainer@example.com -gvlVendorID: 42 modifyingVastXmlAllowed: true capabilities: app: From b7a6fe3473a10ad91ce1c5694241f8e59dac0cd9 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 11 Apr 2024 11:31:21 -0600 Subject: [PATCH 04/48] removes dooh capability --- static/bidder-info/concert.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index ab6b88f43ce..82fe020c113 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -1,7 +1,7 @@ endpoint: "https://bids.concert.io/bids/openrtb" endpointCompression: gzip geoscope: - - USA + - global maintainer: email: prebid-maintainer@example.com modifyingVastXmlAllowed: true @@ -18,12 +18,6 @@ capabilities: - video - audio - native - dooh: - mediaTypes: - - banner - - video - - audio - - native userSync: redirect: url: https://bids.concert.io/sync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect={{.RedirectURL}} From 7b5df752e94529ad16926f5642cea1b39ec7f813 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 11 Apr 2024 11:32:23 -0600 Subject: [PATCH 05/48] removes native media types --- static/bidder-info/concert.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index 82fe020c113..6fa6b97b4ef 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -11,13 +11,11 @@ capabilities: - banner - video - audio - - native site: mediaTypes: - banner - video - audio - - native userSync: redirect: url: https://bids.concert.io/sync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect={{.RedirectURL}} From 33b8a4d99a893c7c307b34e4e018aec56bb46e9c Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 11 Apr 2024 17:13:54 -0600 Subject: [PATCH 06/48] adds placeholder concert support email - to be confirmed --- static/bidder-info/concert.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index 6fa6b97b4ef..2e6c555f951 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -3,7 +3,7 @@ endpointCompression: gzip geoscope: - global maintainer: - email: prebid-maintainer@example.com + email: support@concert.io modifyingVastXmlAllowed: true capabilities: app: From 217570fd07513dc7e9e9cc138e2a595716f8ae73 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Fri, 12 Apr 2024 11:26:56 -0600 Subject: [PATCH 07/48] scaffolds out basic go adapter for concert --- adapters/concert/concert.go | 100 ++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index e69de29bb2d..d3bf4d4e643 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -0,0 +1,100 @@ +package concert + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v2/config" + "github.com/prebid/prebid-server/v2/errortypes" + "github.com/prebid/prebid-server/v2/openrtb_ext" + + "github.com/prebid/prebid-server/v2/adapters" +) + +type adapter struct { + endpoint string +} + +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +func (adapter *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) { + jsonBody, err := json.Marshal(openRTBRequest) + if err != nil { + errs = append(errs, err) + return nil, errs + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + + request := &adapters.RequestData{ + Method: "POST", + Uri: adapter.endpoint, + Body: jsonBody, + Headers: headers, + } + + requestsToBidder = append(requestsToBidder, request) + + return requestsToBidder, errs +} + +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if response.StatusCode == http.StatusNoContent { + return nil, nil + } + + if response.StatusCode == http.StatusBadRequest { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), + }} + } + + bidResponse := new(openrtb2.BidResponse) + if err := json.Unmarshal(response.Body, bidResponse); err != nil { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Bad server response: %s", err), + }} + } + + bidderResponse := adapters.NewBidderResponseWithBidsCapacity(5) + + for _, sb := range bidResponse.SeatBid { + for i := range sb.Bid { + bidType, err := getBidType(sb.Bid[i].ImpID, internalRequest.Imp) + if err != nil { + return nil, []error{err} + } + bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ + Bid: &sb.Bid[i], + BidType: bidType, + }) + } + } + + return bidderResponse, nil +} + +func getBidType(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.Audio != nil { + return openrtb_ext.BidTypeAudio, nil + } + } + } + return "", fmt.Errorf("Unknown impression type for ID %s", impID) +} \ No newline at end of file From ad315c1f8401e5aa1319feaeb631b2eb3f8b8606 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 15 Apr 2024 11:04:48 -0600 Subject: [PATCH 08/48] adds concert to adapter_builders and bidders lists --- adapters/concert/concert.go | 126 +++++++++++++++---------------- adapters/concert/concert_test.go | 23 ++++++ exchange/adapter_builders.go | 2 + openrtb_ext/bidders.go | 2 + 4 files changed, 90 insertions(+), 63 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index d3bf4d4e643..6c2f169bde8 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -25,76 +25,76 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co } func (adapter *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) { - jsonBody, err := json.Marshal(openRTBRequest) - if err != nil { - errs = append(errs, err) - return nil, errs - } + jsonBody, err := json.Marshal(openRTBRequest) + if err != nil { + errs = append(errs, err) + return nil, errs + } - headers := http.Header{} - headers.Add("Content-Type", "application/json;charset=utf-8") + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") - request := &adapters.RequestData{ - Method: "POST", - Uri: adapter.endpoint, - Body: jsonBody, - Headers: headers, - } + request := &adapters.RequestData{ + Method: "POST", + Uri: adapter.endpoint, + Body: jsonBody, + Headers: headers, + } - requestsToBidder = append(requestsToBidder, request) + requestsToBidder = append(requestsToBidder, request) - return requestsToBidder, errs + return requestsToBidder, errs } func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if response.StatusCode == http.StatusNoContent { - return nil, nil - } - - if response.StatusCode == http.StatusBadRequest { - return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), - }} - } - - bidResponse := new(openrtb2.BidResponse) - if err := json.Unmarshal(response.Body, bidResponse); err != nil { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Bad server response: %s", err), - }} - } - - bidderResponse := adapters.NewBidderResponseWithBidsCapacity(5) - - for _, sb := range bidResponse.SeatBid { - for i := range sb.Bid { - bidType, err := getBidType(sb.Bid[i].ImpID, internalRequest.Imp) - if err != nil { - return nil, []error{err} - } - bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ - Bid: &sb.Bid[i], - BidType: bidType, - }) - } - } - - return bidderResponse, nil + if response.StatusCode == http.StatusNoContent { + return nil, nil + } + + if response.StatusCode == http.StatusBadRequest { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), + }} + } + + bidResponse := new(openrtb2.BidResponse) + if err := json.Unmarshal(response.Body, bidResponse); err != nil { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Bad server response: %s", err), + }} + } + + bidderResponse := adapters.NewBidderResponseWithBidsCapacity(5) + + for _, sb := range bidResponse.SeatBid { + for i := range sb.Bid { + bidType, err := getBidType(sb.Bid[i].ImpID, internalRequest.Imp) + if err != nil { + return nil, []error{err} + } + bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ + Bid: &sb.Bid[i], + BidType: bidType, + }) + } + } + + return bidderResponse, nil } func getBidType(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.Audio != nil { - return openrtb_ext.BidTypeAudio, nil - } - } - } - return "", fmt.Errorf("Unknown impression type for ID %s", impID) -} \ No newline at end of file + 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.Audio != nil { + return openrtb_ext.BidTypeAudio, nil + } + } + } + return "", fmt.Errorf("Unknown impression type for ID %s", impID) +} diff --git a/adapters/concert/concert_test.go b/adapters/concert/concert_test.go index e69de29bb2d..74f7d8df949 100644 --- a/adapters/concert/concert_test.go +++ b/adapters/concert/concert_test.go @@ -0,0 +1,23 @@ +package concert + +import ( + "testing" + + "github.com/prebid/prebid-server/v2/adapters/adapterstest" + "github.com/prebid/prebid-server/v2/config" + "github.com/prebid/prebid-server/v2/openrtb_ext" +) + +const testsDir = "concerttest" +const testsBidderEndpoint = "http://test-request.com/prebid" + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderConcert, config.Adapter{ + Endpoint: testsBidderEndpoint}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, testsDir, bidder) +} diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index 9f96cdbf171..922fecfa7ef 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -66,6 +66,7 @@ import ( "github.com/prebid/prebid-server/v2/adapters/coinzilla" "github.com/prebid/prebid-server/v2/adapters/colossus" "github.com/prebid/prebid-server/v2/adapters/compass" + "github.com/prebid/prebid-server/v2/adapters/concert" "github.com/prebid/prebid-server/v2/adapters/connectad" "github.com/prebid/prebid-server/v2/adapters/consumable" "github.com/prebid/prebid-server/v2/adapters/conversant" @@ -274,6 +275,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderCoinzilla: coinzilla.Builder, openrtb_ext.BidderColossus: colossus.Builder, openrtb_ext.BidderCompass: compass.Builder, + openrtb_ext.BidderConcert: concert.Builder, openrtb_ext.BidderConnectAd: connectad.Builder, openrtb_ext.BidderConsumable: consumable.Builder, openrtb_ext.BidderConversant: conversant.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 93c6a49e8e4..3b3bcb64201 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -82,6 +82,7 @@ var coreBidderNames []BidderName = []BidderName{ BidderCoinzilla, BidderColossus, BidderCompass, + BidderConcert, BidderConnectAd, BidderConsumable, BidderConversant, @@ -368,6 +369,7 @@ const ( BidderCoinzilla BidderName = "coinzilla" BidderColossus BidderName = "colossus" BidderCompass BidderName = "compass" + BidderConcert BidderName = "concert" BidderConnectAd BidderName = "connectad" BidderConsumable BidderName = "consumable" BidderConversant BidderName = "conversant" From 6be2f7de19432ebf53645fb861d3a4e757734051 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 09:57:16 -0600 Subject: [PATCH 09/48] translates prebidjs bidder params to prebid server schema for concert adapter --- static/bidder-params/concert.json | 42 ++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/static/bidder-params/concert.json b/static/bidder-params/concert.json index b983ec4c131..6740079a236 100644 --- a/static/bidder-params/concert.json +++ b/static/bidder-params/concert.json @@ -1,7 +1,37 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Concert Adapter Params", - "description": "A schema which validates params accepted by the Concert adapter", - "type": "object", - "properties": {} - } \ No newline at end of file + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Concert Adapter Params", + "description": "A schema which validates params accepted by the Concert adapter", + "type": "object", + "properties": { + "partnerId": { + "type": "string", + "description": "The partner id assigned by concert." + }, + "placementId": { + "type": "integer", + "description": "The placement id." + }, + "site": { + "type": "string", + "description": "The site name." + }, + "slot": { + "type": "string", + "description": "The slot name." + }, + "sizes": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "integer" + }, + "minItems": 2, + "maxItems": 2 + }, + "description": "All sizes this ad unit accepts." + } + }, + "required": ["partnerId"] +} \ No newline at end of file From 116154064676048c8340049ecfa6615ad5004629 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 10:44:01 -0600 Subject: [PATCH 10/48] adds params struct file and updates adapter --- adapters/concert/concert.go | 106 +++++++++++++++--------------- openrtb_ext/imp_concert.go | 5 ++ static/bidder-params/concert.json | 24 ------- 3 files changed, 57 insertions(+), 78 deletions(-) create mode 100644 openrtb_ext/imp_concert.go diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 6c2f169bde8..f1df55efd47 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -17,84 +17,82 @@ type adapter struct { endpoint string } +// Builder builds a new instance of the Concert adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { bidder := &adapter{ - endpoint: config.Endpoint, + endpoint: config.Endpoint, } return bidder, nil } -func (adapter *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) { - jsonBody, err := json.Marshal(openRTBRequest) +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + requestJSON, err := json.Marshal(request) if err != nil { - errs = append(errs, err) - return nil, errs + return nil, []error{err} } - headers := http.Header{} - headers.Add("Content-Type", "application/json;charset=utf-8") - - request := &adapters.RequestData{ + requestData := &adapters.RequestData{ Method: "POST", - Uri: adapter.endpoint, - Body: jsonBody, - Headers: headers, + Uri: a.endpoint, + Body: requestJSON, } - requestsToBidder = append(requestsToBidder, request) - - return requestsToBidder, errs + return []*adapters.RequestData{requestData}, nil } - -func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if response.StatusCode == http.StatusNoContent { - return nil, nil + +func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { + if bid.Ext != nil { + var bidExt openrtb_ext.ExtBid + err := json.Unmarshal(bid.Ext, &bidExt) + if err == nil && bidExt.Prebid != nil { + return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) + } } - if response.StatusCode == http.StatusBadRequest { - return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), - }} + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID), } +} - bidResponse := new(openrtb2.BidResponse) - if err := json.Unmarshal(response.Body, bidResponse); err != nil { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Bad server response: %s", err), - }} +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if responseData.StatusCode == http.StatusNoContent { + return nil, nil } - bidderResponse := adapters.NewBidderResponseWithBidsCapacity(5) + if responseData.StatusCode == http.StatusBadRequest { + err := &errortypes.BadInput{ + Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", + } + return nil, []error{err} + } - for _, sb := range bidResponse.SeatBid { - for i := range sb.Bid { - bidType, err := getBidType(sb.Bid[i].ImpID, internalRequest.Imp) - if err != nil { - return nil, []error{err} - } - bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ - Bid: &sb.Bid[i], - BidType: bidType, - }) + if responseData.StatusCode != http.StatusOK { + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), } + return nil, []error{err} } - return bidderResponse, nil -} + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } -func getBidType(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.Audio != nil { - return openrtb_ext.BidTypeAudio, nil - } + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur + var errors []error + for _, seatBid := range response.SeatBid { + for i, bid := range seatBid.Bid { + bidType, err := getMediaTypeForBid(bid) + if err != nil { + errors = append(errors, err) + continue + } + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &seatBid.Bid[i], + BidType: bidType, + }) } } - return "", fmt.Errorf("Unknown impression type for ID %s", impID) + return bidResponse, nil } diff --git a/openrtb_ext/imp_concert.go b/openrtb_ext/imp_concert.go new file mode 100644 index 00000000000..398710df3b3 --- /dev/null +++ b/openrtb_ext/imp_concert.go @@ -0,0 +1,5 @@ +package openrtb_ext + +type ImpExtConcert struct { + PartnerID string `json:"partnerId"` +} \ No newline at end of file diff --git a/static/bidder-params/concert.json b/static/bidder-params/concert.json index 6740079a236..ebfdab5e0e0 100644 --- a/static/bidder-params/concert.json +++ b/static/bidder-params/concert.json @@ -7,30 +7,6 @@ "partnerId": { "type": "string", "description": "The partner id assigned by concert." - }, - "placementId": { - "type": "integer", - "description": "The placement id." - }, - "site": { - "type": "string", - "description": "The site name." - }, - "slot": { - "type": "string", - "description": "The slot name." - }, - "sizes": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "integer" - }, - "minItems": 2, - "maxItems": 2 - }, - "description": "All sizes this ad unit accepts." } }, "required": ["partnerId"] From b0878289b79929c04a186176ffd8d4f0c22bbbc2 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 11:44:00 -0600 Subject: [PATCH 11/48] extracts publisher id and forwards it in site object --- adapters/concert/concert.go | 65 +++++++++++++++++++++++++------------ openrtb_ext/imp_concert.go | 4 +-- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index f1df55efd47..aae560aefda 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -6,11 +6,10 @@ import ( "net/http" "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" - - "github.com/prebid/prebid-server/v2/adapters" ) type adapter struct { @@ -20,32 +19,44 @@ type adapter struct { // Builder builds a new instance of the Concert adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { bidder := &adapter{ - endpoint: config.Endpoint, + endpoint: config.Endpoint, } return bidder, nil } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - requestJSON, err := json.Marshal(request) + partnerId, err := extractPartnerId(request) if err != nil { return nil, []error{err} } + if request.Site != nil { + if request.Site.Publisher == nil { + request.Site.Publisher = &openrtb2.Publisher{} + } + request.Site.Publisher.ID = partnerId + } + + requestJSON, err := json.Marshal(request) + if err != nil { + return nil, []error{err} + } + requestData := &adapters.RequestData{ - Method: "POST", - Uri: a.endpoint, - Body: requestJSON, + Method: "POST", + Uri: a.endpoint, + Body: requestJSON, } return []*adapters.RequestData{requestData}, nil } - + func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid err := json.Unmarshal(bid.Ext, &bidExt) if err == nil && bidExt.Prebid != nil { - return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) + return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } } @@ -61,14 +72,14 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R if responseData.StatusCode == http.StatusBadRequest { err := &errortypes.BadInput{ - Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", + Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", } return nil, []error{err} } if responseData.StatusCode != http.StatusOK { err := &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), } return nil, []error{err} } @@ -83,16 +94,30 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R var errors []error for _, seatBid := range response.SeatBid { for i, bid := range seatBid.Bid { - bidType, err := getMediaTypeForBid(bid) - if err != nil { - errors = append(errors, err) - continue - } - bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &seatBid.Bid[i], - BidType: bidType, - }) + bidType, err := getMediaTypeForBid(bid) + if err != nil { + errors = append(errors, err) + continue + } + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &seatBid.Bid[i], + BidType: bidType, + }) } } return bidResponse, nil } + +func extractPartnerId(request *openrtb2.BidRequest) (string, error) { + if len(request.Imp) > 0 { + var extBidders openrtb_ext.ImpExtConcert + err := json.Unmarshal(request.Imp[0].Ext, &extBidders) + if err != nil { + return "", err + } + + return extBidders.PartnerId, nil + } + + return "", nil +} diff --git a/openrtb_ext/imp_concert.go b/openrtb_ext/imp_concert.go index 398710df3b3..d29da99347a 100644 --- a/openrtb_ext/imp_concert.go +++ b/openrtb_ext/imp_concert.go @@ -1,5 +1,5 @@ package openrtb_ext type ImpExtConcert struct { - PartnerID string `json:"partnerId"` -} \ No newline at end of file + PartnerId string `json:"partnerId"` +} From b1de33ee86141ec17d0a4adf3b880f5e5ff04e4b Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 11:50:27 -0600 Subject: [PATCH 12/48] runs format script --- adapters/concert/concert.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index aae560aefda..92f4e728052 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -31,16 +31,16 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } if request.Site != nil { - if request.Site.Publisher == nil { - request.Site.Publisher = &openrtb2.Publisher{} - } - request.Site.Publisher.ID = partnerId - } + if request.Site.Publisher == nil { + request.Site.Publisher = &openrtb2.Publisher{} + } + request.Site.Publisher.ID = partnerId + } requestJSON, err := json.Marshal(request) if err != nil { - return nil, []error{err} - } + return nil, []error{err} + } requestData := &adapters.RequestData{ Method: "POST", @@ -109,15 +109,15 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } func extractPartnerId(request *openrtb2.BidRequest) (string, error) { - if len(request.Imp) > 0 { - var extBidders openrtb_ext.ImpExtConcert - err := json.Unmarshal(request.Imp[0].Ext, &extBidders) - if err != nil { - return "", err - } + if len(request.Imp) > 0 { + var extBidders openrtb_ext.ImpExtConcert + err := json.Unmarshal(request.Imp[0].Ext, &extBidders) + if err != nil { + return "", err + } - return extBidders.PartnerId, nil - } + return extBidders.PartnerId, nil + } - return "", nil + return "", nil } From dffccd1284c1c1342abcf735b439f693f663cc71 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 14:52:44 -0600 Subject: [PATCH 13/48] scaffolds test files --- .../concert/concerttest/exemplary/audio.json | 5 +++ .../concert/concerttest/exemplary/banner.json | 5 +++ .../concert/concerttest/exemplary/video.json | 5 +++ adapters/concert/params_test.go | 45 +++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 adapters/concert/concerttest/exemplary/audio.json create mode 100644 adapters/concert/concerttest/exemplary/banner.json create mode 100644 adapters/concert/concerttest/exemplary/video.json create mode 100644 adapters/concert/params_test.go diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json new file mode 100644 index 00000000000..e46caed63bf --- /dev/null +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -0,0 +1,5 @@ +{ + "mockBidRequest": {}, + "httpCalls": [], + "expectedBidResponses": [] +} \ No newline at end of file diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json new file mode 100644 index 00000000000..e46caed63bf --- /dev/null +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -0,0 +1,5 @@ +{ + "mockBidRequest": {}, + "httpCalls": [], + "expectedBidResponses": [] +} \ No newline at end of file diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json new file mode 100644 index 00000000000..e46caed63bf --- /dev/null +++ b/adapters/concert/concerttest/exemplary/video.json @@ -0,0 +1,5 @@ +{ + "mockBidRequest": {}, + "httpCalls": [], + "expectedBidResponses": [] +} \ No newline at end of file diff --git a/adapters/concert/params_test.go b/adapters/concert/params_test.go new file mode 100644 index 00000000000..6d69db8706c --- /dev/null +++ b/adapters/concert/params_test.go @@ -0,0 +1,45 @@ +package concert + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v2/openrtb_ext" +) + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range validParams { + if err := validator.Validate(openrtb_ext.BidderConcert, json.RawMessage(p)); err != nil { + t.Errorf("Schema rejected valid params: %s", p) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderConcert, json.RawMessage(p)); err == nil { + t.Errorf("Schema allowed invalid params: %s", p) + } + } +} + +var validParams = []string{ + `{"publisherId": ""}`, + `{"publisherId": "concert_publisher_id"}`, +} + +var invalidParams = []string{ + `{"publisherId": 42}`, + `{"publisherId": ["concert_publisher_id"]}`, + `{"publisherId": {"id": "concert_publisher_id"}}`, +} \ No newline at end of file From 90e58ee00702dd1e204f70f72cff4191759be169 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 14:59:35 -0600 Subject: [PATCH 14/48] adds mock bid requests for each type --- .../concert/concerttest/exemplary/audio.json | 33 ++++++++++++++++- .../concert/concerttest/exemplary/banner.json | 36 ++++++++++++++++++- .../concert/concerttest/exemplary/video.json | 36 ++++++++++++++++++- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index e46caed63bf..acaf786ea0d 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -1,5 +1,36 @@ { - "mockBidRequest": {}, + "mockBidRequest": { + "id": "some-request-id", + "imp": [ + { + "id": "some-imp-id", + "audio": { + "mimes": ["audio/mp3"], + "minduration": 5, + "maxduration": 30 + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[1030, 590]] + } + } + } + ], + "site": { + "page": "http://www.example.com" + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" + } + }, "httpCalls": [], "expectedBidResponses": [] } \ No newline at end of file diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index e46caed63bf..bb453793be1 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -1,5 +1,39 @@ { - "mockBidRequest": {}, + "mockBidRequest": { + "id": "some-request-id", + "imp": [ + { + "id": "some-imp-id", + "banner": { + "format": [ + { + "w": 1030, + "h": 590 + } + ] + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[1030, 590]] + } + } + } + ], + "site": { + "page": "http://www.example.com" + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" + } + }, "httpCalls": [], "expectedBidResponses": [] } \ No newline at end of file diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index e46caed63bf..440efd87270 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -1,5 +1,39 @@ { - "mockBidRequest": {}, + "mockBidRequest": { + "id": "some-request-id", + "imp": [ + { + "id": "some-imp-id", + "video": { + "mimes": ["video/mp4"], + "minduration": 5, + "maxduration": 30, + "protocols": [1, 2], + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[640, 480]] + } + } + } + ], + "site": { + "page": "http://www.example.com" + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" + } + }, "httpCalls": [], "expectedBidResponses": [] } \ No newline at end of file From ed479ac09fb3918a27fea319f8d1ead0dc3c21f6 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 15:01:38 -0600 Subject: [PATCH 15/48] adds optional params from the prebid.js adapter --- adapters/concert/params_test.go | 2 +- static/bidder-params/concert.json | 32 +++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/adapters/concert/params_test.go b/adapters/concert/params_test.go index 6d69db8706c..a9d343fe2ad 100644 --- a/adapters/concert/params_test.go +++ b/adapters/concert/params_test.go @@ -42,4 +42,4 @@ var invalidParams = []string{ `{"publisherId": 42}`, `{"publisherId": ["concert_publisher_id"]}`, `{"publisherId": {"id": "concert_publisher_id"}}`, -} \ No newline at end of file +} diff --git a/static/bidder-params/concert.json b/static/bidder-params/concert.json index ebfdab5e0e0..32dc1d46484 100644 --- a/static/bidder-params/concert.json +++ b/static/bidder-params/concert.json @@ -4,10 +4,34 @@ "description": "A schema which validates params accepted by the Concert adapter", "type": "object", "properties": { - "partnerId": { - "type": "string", - "description": "The partner id assigned by concert." - } + "partnerId": { + "type": "string", + "description": "The partner id assigned by concert." + }, + "placementId": { + "type": "integer", + "description": "The placement id." + }, + "site": { + "type": "string", + "description": "The site name." + }, + "slot": { + "type": "string", + "description": "The slot name." + }, + "sizes": { + "type": "array", + "description": "All sizes this ad unit accepts.", + "items": { + "type": "array", + "items": { + "type": "integer" + }, + "minItems": 2, + "maxItems": 2 + } + } }, "required": ["partnerId"] } \ No newline at end of file From ca8dd1306da59aa33a8d15cc95d5f51327438e95 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 15:04:32 -0600 Subject: [PATCH 16/48] updates params test to include optional parameters --- adapters/concert/params_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/adapters/concert/params_test.go b/adapters/concert/params_test.go index a9d343fe2ad..dca3e9585d6 100644 --- a/adapters/concert/params_test.go +++ b/adapters/concert/params_test.go @@ -34,12 +34,17 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"publisherId": ""}`, - `{"publisherId": "concert_publisher_id"}`, + `{"partnerId": "partner_name"}`, + `{"partnerId": "partner_name", "placementId": 1234567}`, + `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name"}`, + `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name", "slot": "slot_name"}`, + `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name", "slot": "slot_name", "sizes": [[1030, 590]]}`, } var invalidParams = []string{ - `{"publisherId": 42}`, - `{"publisherId": ["concert_publisher_id"]}`, - `{"publisherId": {"id": "concert_publisher_id"}}`, + `{"partnerId": ""}`, + `{"placementId": 1234567}`, + `{"site": "site_name"}`, + `{"slot": "slot_name"}`, + `{"sizes": [[1030, 590]]}`, } From 701edbaad6f0146a45f24ae35fd75bb1a2fabd15 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 15:23:16 -0600 Subject: [PATCH 17/48] fixes formatting --- .../concert/concerttest/exemplary/video.json | 111 +++++++++++++----- adapters/concert/params_test.go | 20 ++-- 2 files changed, 91 insertions(+), 40 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 440efd87270..52ab7b603c5 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -1,39 +1,90 @@ { "mockBidRequest": { - "id": "some-request-id", - "imp": [ - { - "id": "some-imp-id", + "id": "some-request-id", + "imp": [ + { + "id": "some-imp-id", + "video": { + "mimes": ["video/mp4"], + "minduration": 5, + "maxduration": 30, + "protocols": [1, 2], + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[640, 480]] + } + } + } + ], + "site": { + "page": "http://www.example.com" + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://bidder-url.com/api/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", "video": { - "mimes": ["video/mp4"], - "minduration": 5, - "maxduration": 30, - "protocols": [1, 2], - "w": 640, - "h": 480 + "w": 640, + "h": 480, + "protocols": [1, 2], + "playbackmethod": [1], + "mimes": ["video/mp4", "video/webm"] }, "ext": { - "bidder": { - "partnerId": "partner_name", - "placementId": 1234567, - "site": "site_name", - "slot": "slot_name", - "sizes": [[640, 480]] - } + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[640, 480]] + } } - } - ], - "site": { - "page": "http://www.example.com" - }, - "device": { - "ua": "test-user-agent", - "ip": "123.123.123.123" + } + ] + } }, - "user": { - "buyeruid": "some-buyer-uid" + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "...", + "crid": "test-creative-id", + "w": 640, + "h": 480 + } + ] + } + ] + } } - }, - "httpCalls": [], + } + ], "expectedBidResponses": [] -} \ No newline at end of file + } \ No newline at end of file diff --git a/adapters/concert/params_test.go b/adapters/concert/params_test.go index dca3e9585d6..d0146a8d4ac 100644 --- a/adapters/concert/params_test.go +++ b/adapters/concert/params_test.go @@ -34,17 +34,17 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"partnerId": "partner_name"}`, - `{"partnerId": "partner_name", "placementId": 1234567}`, - `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name"}`, - `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name", "slot": "slot_name"}`, - `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name", "slot": "slot_name", "sizes": [[1030, 590]]}`, + `{"partnerId": "partner_name"}`, + `{"partnerId": "partner_name", "placementId": 1234567}`, + `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name"}`, + `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name", "slot": "slot_name"}`, + `{"partnerId": "partner_name", "placementId": 1234567, "site": "site_name", "slot": "slot_name", "sizes": [[1030, 590]]}`, } var invalidParams = []string{ - `{"partnerId": ""}`, - `{"placementId": 1234567}`, - `{"site": "site_name"}`, - `{"slot": "slot_name"}`, - `{"sizes": [[1030, 590]]}`, + `{"partnerId": ""}`, + `{"placementId": 1234567}`, + `{"site": "site_name"}`, + `{"slot": "slot_name"}`, + `{"sizes": [[1030, 590]]}`, } From 32b20c3bad65d8b820065569342cf36e1b74bcfd Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 15:26:54 -0600 Subject: [PATCH 18/48] adds httpcalls to banner mock data --- .../concert/concerttest/exemplary/banner.json | 112 +++++++++++++----- 1 file changed, 82 insertions(+), 30 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index bb453793be1..7a9e52b302a 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -1,39 +1,91 @@ { "mockBidRequest": { - "id": "some-request-id", - "imp": [ - { - "id": "some-imp-id", + "id": "some-request-id", + "imp": [ + { + "id": "some-imp-id", + "banner": { + "format": [ + { + "w": 1030, + "h": 590 + } + ] + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[1030, 590]] + } + } + } + ], + "site": { + "page": "http://www.example.com" + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://bidder-url.com/api/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", "banner": { - "format": [ - { - "w": 1030, - "h": 590 - } - ] + "format": [ + { + "w": 1030, + "h": 590 + } + ] }, "ext": { - "bidder": { - "partnerId": "partner_name", - "placementId": 1234567, - "site": "site_name", - "slot": "slot_name", - "sizes": [[1030, 590]] - } + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[1030, 590]] + } } - } - ], - "site": { - "page": "http://www.example.com" + } + ] + } }, - "device": { - "ua": "test-user-agent", - "ip": "123.123.123.123" - }, - "user": { - "buyeruid": "some-buyer-uid" + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "

Banner Ad

This is a mock banner ad

", + "crid": "test-creative-id", + "w": 1030, + "h": 590 + } + ] + } + ] + } } - }, - "httpCalls": [], + } + ], "expectedBidResponses": [] -} \ No newline at end of file + } \ No newline at end of file From e8ed6472bbba460480f672eb49b28127644567a6 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 15:28:22 -0600 Subject: [PATCH 19/48] adds httpcalls to audio mock data --- .../concert/concerttest/exemplary/audio.json | 103 +++++++++++++----- 1 file changed, 76 insertions(+), 27 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index acaf786ea0d..b5ef51d602c 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -1,36 +1,85 @@ { "mockBidRequest": { - "id": "some-request-id", - "imp": [ - { - "id": "some-imp-id", + "id": "some-request-id", + "imp": [ + { + "id": "some-imp-id", + "audio": { + "mimes": ["audio/mp3"], + "minduration": 5, + "maxduration": 30 + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[1030, 590]] + } + } + } + ], + "site": { + "page": "http://www.example.com" + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://bidder-url.com/api/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", "audio": { - "mimes": ["audio/mp3"], - "minduration": 5, - "maxduration": 30 + "mimes": ["audio/mp3"], + "minduration": 5, + "maxduration": 30 }, "ext": { - "bidder": { - "partnerId": "partner_name", - "placementId": 1234567, - "site": "site_name", - "slot": "slot_name", - "sizes": [[1030, 590]] - } + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[1030, 590]] + } } - } - ], - "site": { - "page": "http://www.example.com" - }, - "device": { - "ua": "test-user-agent", - "ip": "123.123.123.123" + } + ] + } }, - "user": { - "buyeruid": "some-buyer-uid" + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "...", + "crid": "test-creative-id", + "w": 1030, + "h": 590 + } + ] + } + ] + } } - }, - "httpCalls": [], + } + ], "expectedBidResponses": [] -} \ No newline at end of file + } \ No newline at end of file From aaebf0579f21a169eb1d743fd816e6a4d6efbaa9 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 22 Apr 2024 15:29:33 -0600 Subject: [PATCH 20/48] use correct endpoint --- adapters/concert/concerttest/exemplary/audio.json | 2 +- adapters/concert/concerttest/exemplary/banner.json | 2 +- adapters/concert/concerttest/exemplary/video.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index b5ef51d602c..b2949a05c1c 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -34,7 +34,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://bidder-url.com/api/bid", + "uri": "https://bids.concert.io/bids/openrtb", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index 7a9e52b302a..caa6cfe68d2 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -37,7 +37,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://bidder-url.com/api/bid", + "uri": "https://bids.concert.io/bids/openrtb", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 52ab7b603c5..3321913fda6 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -37,7 +37,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://bidder-url.com/api/bid", + "uri": "https://bids.concert.io/bids/openrtb", "body": { "id": "test-request-id", "imp": [ From 6a76468a4406e0a758341baf9eb7b39eb8061d04 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 23 Apr 2024 10:39:03 -0600 Subject: [PATCH 21/48] adds remaining properties for audio, video, and banner ad mocks --- .../concert/concerttest/exemplary/audio.json | 27 ++++++++++----- .../concert/concerttest/exemplary/banner.json | 33 +++++++++++++++++-- .../concert/concerttest/exemplary/video.json | 19 ++++++++++- 3 files changed, 67 insertions(+), 12 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index b2949a05c1c..c2463cea017 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -14,8 +14,7 @@ "partnerId": "partner_name", "placementId": 1234567, "site": "site_name", - "slot": "slot_name", - "sizes": [[1030, 590]] + "slot": "slot_name" } } } @@ -50,8 +49,7 @@ "partnerId": "partner_name", "placementId": 1234567, "site": "site_name", - "slot": "slot_name", - "sizes": [[1030, 590]] + "slot": "slot_name" } } } @@ -70,9 +68,7 @@ "impid": "test-imp-id", "price": 1.23, "adm": "...", - "crid": "test-creative-id", - "w": 1030, - "h": 590 + "crid": "test-creative-id" } ] } @@ -81,5 +77,20 @@ } } ], - "expectedBidResponses": [] + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "...", + "crid": "test-creative-id" + }, + "type": "audio" + } + ] + } + ] } \ No newline at end of file diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index caa6cfe68d2..760b92d6351 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -18,7 +18,12 @@ "placementId": 1234567, "site": "site_name", "slot": "slot_name", - "sizes": [[1030, 590]] + "sizes": [ + [ + 1030, + 590 + ] + ] } } } @@ -57,7 +62,12 @@ "placementId": 1234567, "site": "site_name", "slot": "slot_name", - "sizes": [[1030, 590]] + "sizes": [ + [ + 1030, + 590 + ] + ] } } } @@ -87,5 +97,22 @@ } } ], - "expectedBidResponses": [] + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "

Banner Ad

This is a mock banner ad

", + "crid": "test-creative-id", + "w": 1030, + "h": 590 + }, + "type": "banner" + } + ] + } + ] } \ No newline at end of file diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 3321913fda6..e8814b396be 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -86,5 +86,22 @@ } } ], - "expectedBidResponses": [] + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "...", + "crid": "test-creative-id", + "w": 640, + "h": 480 + }, + "type": "video" + } + ] + } + ] } \ No newline at end of file From 7b75b30023570a4275329a1d9a32a244aa5059d3 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 23 Apr 2024 10:43:13 -0600 Subject: [PATCH 22/48] adds additional invalid params entry --- adapters/concert/params_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/adapters/concert/params_test.go b/adapters/concert/params_test.go index d0146a8d4ac..4cf653d2b27 100644 --- a/adapters/concert/params_test.go +++ b/adapters/concert/params_test.go @@ -47,4 +47,5 @@ var invalidParams = []string{ `{"site": "site_name"}`, `{"slot": "slot_name"}`, `{"sizes": [[1030, 590]]}`, + `{"placementId": 1234567, "site": "site_name", "slot": "slot_name", "sizes": [[1030, 590]]}`, } From 5fa8d32d94260b7f7eab6828a466e0f8937552a5 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 23 Apr 2024 14:47:48 -0600 Subject: [PATCH 23/48] removes publisher id logic --- adapters/concert/concert.go | 83 ++++---- adapters/concert/concert_test.go | 7 +- .../concert/concerttest/exemplary/audio.json | 20 +- .../concert/concerttest/exemplary/banner.json | 3 +- .../concert/concerttest/exemplary/video.json | 197 +++++++++--------- static/bidder-params/concert.json | 3 +- 6 files changed, 160 insertions(+), 153 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 92f4e728052..14e93333a84 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -25,45 +25,19 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - partnerId, err := extractPartnerId(request) - if err != nil { - return nil, []error{err} - } - - if request.Site != nil { - if request.Site.Publisher == nil { - request.Site.Publisher = &openrtb2.Publisher{} - } - request.Site.Publisher.ID = partnerId - } - - requestJSON, err := json.Marshal(request) - if err != nil { - return nil, []error{err} + requestJSON, err := json.Marshal(request) + if err != nil { + return nil, []error{err} } - + requestData := &adapters.RequestData{ - Method: "POST", - Uri: a.endpoint, - Body: requestJSON, + Method: "POST", + Uri: a.endpoint, + Body: requestJSON, } - + return []*adapters.RequestData{requestData}, nil -} - -func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { - if bid.Ext != nil { - var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) - if err == nil && bidExt.Prebid != nil { - return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) - } - } - - return "", &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID), - } -} + } func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData.StatusCode == http.StatusNoContent { @@ -94,7 +68,8 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R var errors []error for _, seatBid := range response.SeatBid { for i, bid := range seatBid.Bid { - bidType, err := getMediaTypeForBid(bid) + imp, _ := getImpByID(bid.ImpID, request.Imp) + bidType, err := getMediaTypeForBid(bid, imp) if err != nil { errors = append(errors, err) continue @@ -108,16 +83,36 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return bidResponse, nil } -func extractPartnerId(request *openrtb2.BidRequest) (string, error) { - if len(request.Imp) > 0 { - var extBidders openrtb_ext.ImpExtConcert - err := json.Unmarshal(request.Imp[0].Ext, &extBidders) - if err != nil { - return "", err +func getImpByID(impID string, imps []openrtb2.Imp) (*openrtb2.Imp, error) { + for _, imp := range imps { + if imp.ID == impID { + return &imp, nil + } + } + return nil, fmt.Errorf("no matching imp found for id %s", impID) +} + +func getMediaTypeForBid(bid openrtb2.Bid, imp *openrtb2.Imp) (openrtb_ext.BidType, error) { + if bid.Ext != nil { + var bidExt openrtb_ext.ExtBid + err := json.Unmarshal(bid.Ext, &bidExt) + if err == nil && bidExt.Prebid != nil { + return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) } + } - return extBidders.PartnerId, nil + // Infer media type from imp object + if imp != nil { + if imp.Video != nil { + return openrtb_ext.BidTypeVideo, nil + } else if imp.Banner != nil { + return openrtb_ext.BidTypeBanner, nil + } else if imp.Audio != nil { + return openrtb_ext.BidTypeAudio, nil + } } - return "", nil + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID), + } } diff --git a/adapters/concert/concert_test.go b/adapters/concert/concert_test.go index 74f7d8df949..e8c06d06377 100644 --- a/adapters/concert/concert_test.go +++ b/adapters/concert/concert_test.go @@ -8,16 +8,13 @@ import ( "github.com/prebid/prebid-server/v2/openrtb_ext" ) -const testsDir = "concerttest" -const testsBidderEndpoint = "http://test-request.com/prebid" - func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderConcert, config.Adapter{ - Endpoint: testsBidderEndpoint}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + Endpoint: "https://bids.concert.io/bids/openrtb"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) } - adapterstest.RunJSONBidderTest(t, testsDir, bidder) + adapterstest.RunJSONBidderTest(t, "concerttest", bidder) } diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index c2463cea017..3270aed76e0 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -35,10 +35,10 @@ "expectedRequest": { "uri": "https://bids.concert.io/bids/openrtb", "body": { - "id": "test-request-id", + "id": "some-request-id", "imp": [ { - "id": "test-imp-id", + "id": "some-imp-id", "audio": { "mimes": ["audio/mp3"], "minduration": 5, @@ -53,7 +53,18 @@ } } } - ] + ], + "device": { + "ip": "123.123.123.123", + "ua": "test-user-agent" + }, + "site": { + "page": "http://www.example.com", + "publisher": {} + }, + "user": { + "buyeruid": "some-buyer-uid" + } } }, "mockResponse": { @@ -87,8 +98,7 @@ "price": 1.23, "adm": "...", "crid": "test-creative-id" - }, - "type": "audio" + } } ] } diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index 760b92d6351..fe9a128ee82 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -109,8 +109,7 @@ "crid": "test-creative-id", "w": 1030, "h": 590 - }, - "type": "banner" + } } ] } diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index e8814b396be..4fb3a478fbb 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -1,107 +1,112 @@ { - "mockBidRequest": { - "id": "some-request-id", - "imp": [ - { - "id": "some-imp-id", - "video": { - "mimes": ["video/mp4"], - "minduration": 5, - "maxduration": 30, - "protocols": [1, 2], - "w": 640, - "h": 480 - }, - "ext": { - "bidder": { - "partnerId": "partner_name", - "placementId": 1234567, - "site": "site_name", - "slot": "slot_name", - "sizes": [[640, 480]] - } + "mockBidRequest": { + "id": "some-request-id", + "imp": [ + { + "id": "some-imp-id", + "video": { + "mimes": ["video/mp4"], + "minduration": 5, + "maxduration": 30, + "protocols": [1, 2], + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[640, 480]] } } - ], - "site": { - "page": "http://www.example.com" - }, - "device": { - "ua": "test-user-agent", - "ip": "123.123.123.123" - }, - "user": { - "buyeruid": "some-buyer-uid" } + ], + "site": { + "page": "http://www.example.com" }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://bids.concert.io/bids/openrtb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "w": 640, - "h": 480, - "protocols": [1, 2], - "playbackmethod": [1], - "mimes": ["video/mp4", "video/webm"] - }, - "ext": { - "bidder": { - "partnerId": "partner_name", - "placementId": 1234567, - "site": "site_name", - "slot": "slot_name", - "sizes": [[640, 480]] - } + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bids.concert.io/bids/openrtb", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 640, + "h": 480, + "protocols": [1, 2], + "playbackmethod": [1], + "mimes": ["video/mp4", "video/webm"] + }, + "ext": { + "bidder": { + "partnerId": "partner_name", + "placementId": 1234567, + "site": "site_name", + "slot": "slot_name", + "sizes": [[640, 480]] } } - ] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [ - { - "bid": [ - { - "id": "test-bid-id", - "impid": "test-imp-id", - "price": 1.23, - "adm": "...", - "crid": "test-creative-id", - "w": 640, - "h": 480 - } - ] - } - ] + } + ], + "site": { + "page": "http://www.example.com", + "publisher": { + "id": "partner_name" + } } } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "...", + "crid": "test-creative-id", + "w": 640, + "h": 480 + } + ] + } + ] + } } - ], - "expectedBidResponses": [ - { - "bids": [ - { - "bid": { - "id": "test-bid-id", - "impid": "test-imp-id", - "price": 1.23, - "adm": "...", - "crid": "test-creative-id", - "w": 640, - "h": 480 - }, - "type": "video" + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id", + "impid": "test-imp-id", + "price": 1.23, + "adm": "...", + "crid": "test-creative-id", + "w": 640, + "h": 480 } - ] - } - ] - } \ No newline at end of file + } + ] + } + ] +} \ No newline at end of file diff --git a/static/bidder-params/concert.json b/static/bidder-params/concert.json index 32dc1d46484..5dd82b4d486 100644 --- a/static/bidder-params/concert.json +++ b/static/bidder-params/concert.json @@ -6,7 +6,8 @@ "properties": { "partnerId": { "type": "string", - "description": "The partner id assigned by concert." + "description": "The partner id assigned by concert.", + "minLength": 1 }, "placementId": { "type": "integer", From 1d48f83f87edac1272a4c48d7924ee4909aac1a6 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 23 Apr 2024 16:24:54 -0600 Subject: [PATCH 24/48] fixes json media type issue --- adapters/concert/concert.go | 28 +++++++++++-------- .../concert/concerttest/exemplary/audio.json | 22 ++++++++------- .../concert/concerttest/exemplary/banner.json | 19 ++++++++++--- .../concert/concerttest/exemplary/video.json | 24 ++++++++++------ 4 files changed, 59 insertions(+), 34 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 14e93333a84..a0fee07decd 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -3,13 +3,13 @@ package concert import ( "encoding/json" "fmt" - "net/http" - "github.com/prebid/openrtb/v20/openrtb2" "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" + "log" + "net/http" ) type adapter struct { @@ -25,19 +25,19 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - requestJSON, err := json.Marshal(request) - if err != nil { - return nil, []error{err} + requestJSON, err := json.Marshal(request) + if err != nil { + return nil, []error{err} } - + requestData := &adapters.RequestData{ - Method: "POST", - Uri: a.endpoint, - Body: requestJSON, + Method: "POST", + Uri: a.endpoint, + Body: requestJSON, } - + return []*adapters.RequestData{requestData}, nil - } +} func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData.StatusCode == http.StatusNoContent { @@ -80,6 +80,12 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R }) } } + + // Check if bidResponse.Bids is empty + if len(bidResponse.Bids) == 0 { + return nil, []error{fmt.Errorf("No bids returned")} + } + return bidResponse, nil } diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index 3270aed76e0..ae6a81122a1 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -1,9 +1,9 @@ { "mockBidRequest": { - "id": "some-request-id", + "id": "test-request-id", "imp": [ { - "id": "some-imp-id", + "id": "test-imp-id", "audio": { "mimes": ["audio/mp3"], "minduration": 5, @@ -35,21 +35,23 @@ "expectedRequest": { "uri": "https://bids.concert.io/bids/openrtb", "body": { - "id": "some-request-id", + "id": "test-request-id", "imp": [ { - "id": "some-imp-id", + "id": "test-imp-id", "audio": { - "mimes": ["audio/mp3"], + "mimes": ["audio/mpeg"], "minduration": 5, - "maxduration": 30 + "maxduration": 30, + "protocols": [1, 2] }, "ext": { "bidder": { "partnerId": "partner_name", "placementId": 1234567, "site": "site_name", - "slot": "slot_name" + "slot": "slot_name", + "sizes": [[300, 250]] } } } @@ -59,8 +61,7 @@ "ua": "test-user-agent" }, "site": { - "page": "http://www.example.com", - "publisher": {} + "page": "http://www.example.com" }, "user": { "buyeruid": "some-buyer-uid" @@ -98,7 +99,8 @@ "price": 1.23, "adm": "...", "crid": "test-creative-id" - } + }, + "type": "audio" } ] } diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index fe9a128ee82..84a13521dee 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -1,9 +1,9 @@ { "mockBidRequest": { - "id": "some-request-id", + "id": "test-request-id", "imp": [ { - "id": "some-imp-id", + "id": "test-imp-id", "banner": { "format": [ { @@ -71,7 +71,17 @@ } } } - ] + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "site": { + "page": "http://www.example.com" + }, + "user": { + "buyeruid": "some-buyer-uid" + } } }, "mockResponse": { @@ -109,7 +119,8 @@ "crid": "test-creative-id", "w": 1030, "h": 590 - } + }, + "type": "banner" } ] } diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 4fb3a478fbb..104d8be8d69 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -1,9 +1,9 @@ { "mockBidRequest": { - "id": "some-request-id", + "id": "test-request-id", "imp": [ { - "id": "some-imp-id", + "id": "test-imp-id", "video": { "mimes": ["video/mp4"], "minduration": 5, @@ -46,9 +46,10 @@ "video": { "w": 640, "h": 480, + "minduration": 5, + "maxduration": 30, "protocols": [1, 2], - "playbackmethod": [1], - "mimes": ["video/mp4", "video/webm"] + "mimes": ["video/mp4"] }, "ext": { "bidder": { @@ -62,10 +63,14 @@ } ], "site": { - "page": "http://www.example.com", - "publisher": { - "id": "partner_name" - } + "page": "http://www.example.com" + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123" + }, + "user": { + "buyeruid": "some-buyer-uid" } } }, @@ -104,7 +109,8 @@ "crid": "test-creative-id", "w": 640, "h": 480 - } + }, + "type": "video" } ] } From ab5d56fc9e810b6e0f8100859a62be5a61c240fa Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 23 Apr 2024 16:26:30 -0600 Subject: [PATCH 25/48] removes unused import --- adapters/concert/concert.go | 1 - 1 file changed, 1 deletion(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index a0fee07decd..22c60a5e89c 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -8,7 +8,6 @@ import ( "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" - "log" "net/http" ) From cc8ab0dbb7644f498354d099d746bb4a431abc36 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 23 Apr 2024 16:29:23 -0600 Subject: [PATCH 26/48] tests passing --- adapters/concert/concerttest/exemplary/audio.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index ae6a81122a1..47656f6f3c2 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -7,7 +7,8 @@ "audio": { "mimes": ["audio/mp3"], "minduration": 5, - "maxduration": 30 + "maxduration": 30, + "protocols": [1, 2] }, "ext": { "bidder": { @@ -40,7 +41,7 @@ { "id": "test-imp-id", "audio": { - "mimes": ["audio/mpeg"], + "mimes": ["audio/mp3"], "minduration": 5, "maxduration": 30, "protocols": [1, 2] @@ -50,8 +51,7 @@ "partnerId": "partner_name", "placementId": 1234567, "site": "site_name", - "slot": "slot_name", - "sizes": [[300, 250]] + "slot": "slot_name" } } } From 2f3d2c93203b06e50ee5c3ca529339e9d87667a5 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Wed, 24 Apr 2024 13:27:54 -0600 Subject: [PATCH 27/48] updates endpoint for testing and adds contenty type header --- adapters/concert/concert.go | 5 +++++ static/bidder-info/concert.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 22c60a5e89c..b5132979d89 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" "net/http" + "log" ) type adapter struct { @@ -29,10 +30,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte return nil, []error{err} } + requestData := &adapters.RequestData{ Method: "POST", Uri: a.endpoint, Body: requestJSON, + Headers: http.Header{ + "Content-Type": []string{"application/json"}, + }, } return []*adapters.RequestData{requestData}, nil diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index 2e6c555f951..02f96c74539 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -1,4 +1,4 @@ -endpoint: "https://bids.concert.io/bids/openrtb" +endpoint: "http://localhost:8080/bids/openrtb" endpointCompression: gzip geoscope: - global From ea30a3ed6ccd10d5d91d7ef7ff34fae624ced2ee Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Wed, 24 Apr 2024 13:28:21 -0600 Subject: [PATCH 28/48] removes unused import --- adapters/concert/concert.go | 1 - 1 file changed, 1 deletion(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index b5132979d89..7bae6b4da8c 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -9,7 +9,6 @@ import ( "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" "net/http" - "log" ) type adapter struct { From 87ca22b313180edbc1ed631578d2d02766d88f36 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 08:55:09 -0600 Subject: [PATCH 29/48] removes usersync from config file --- static/bidder-info/concert.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index 02f96c74539..5b614d8f61b 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -15,8 +15,4 @@ capabilities: mediaTypes: - banner - video - - audio -userSync: - redirect: - url: https://bids.concert.io/sync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect={{.RedirectURL}} - userMacro: $UID \ No newline at end of file + - audio \ No newline at end of file From 48f22ec1de9d13a5686a7fd7d0d9567154079662 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 11:14:12 -0600 Subject: [PATCH 30/48] adds adapterversion --- adapters/concert/concert.go | 23 +++++++++++++++++-- .../concert/concerttest/exemplary/audio.json | 6 +++++ .../concert/concerttest/exemplary/banner.json | 6 +++++ .../concert/concerttest/exemplary/video.json | 6 +++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 7bae6b4da8c..cf6372f1e63 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -15,6 +15,8 @@ type adapter struct { endpoint string } +const adapterVersion = "1.0.0" + // Builder builds a new instance of the Concert adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { bidder := &adapter{ @@ -29,14 +31,31 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte return nil, []error{err} } + // Unmarshal the request into a map + var requestMap map[string]interface{} + err = json.Unmarshal(requestJSON, &requestMap) + if err != nil { + return nil, []error{err} + } + + if requestMap["ext"] == nil { + requestMap["ext"] = make(map[string]interface{}) + } + requestMap["ext"].(map[string]interface{})["adapterVersion"] = adapterVersion + + // Marshal the map back into JSON + requestJSON, err = json.Marshal(requestMap) + if err != nil { + return nil, []error{err} + } requestData := &adapters.RequestData{ Method: "POST", Uri: a.endpoint, Body: requestJSON, Headers: http.Header{ - "Content-Type": []string{"application/json"}, - }, + "Content-Type": []string{"application/json"}, + }, } return []*adapters.RequestData{requestData}, nil diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index 47656f6f3c2..72bed702b2e 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -29,6 +29,9 @@ }, "user": { "buyeruid": "some-buyer-uid" + }, + "ext": { + "adapterVersion": "1.0.0" } }, "httpCalls": [ @@ -65,6 +68,9 @@ }, "user": { "buyeruid": "some-buyer-uid" + }, + "ext": { + "adapterVersion": "1.0.0" } } }, diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index 84a13521dee..318654cf509 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -37,6 +37,9 @@ }, "user": { "buyeruid": "some-buyer-uid" + }, + "ext": { + "adapterVersion": "1.0.0" } }, "httpCalls": [ @@ -81,6 +84,9 @@ }, "user": { "buyeruid": "some-buyer-uid" + }, + "ext": { + "adapterVersion": "1.0.0" } } }, diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 104d8be8d69..13afa539cab 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -32,6 +32,9 @@ }, "user": { "buyeruid": "some-buyer-uid" + }, + "ext": { + "adapterVersion": "1.0.0" } }, "httpCalls": [ @@ -71,6 +74,9 @@ }, "user": { "buyeruid": "some-buyer-uid" + }, + "ext": { + "adapterVersion": "1.0.0" } } }, From df36d41d4584e4d76869054661f65432e493bfe8 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 11:23:44 -0600 Subject: [PATCH 31/48] fixes go linting errors --- adapters/concert/concert.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index cf6372f1e63..0497e3ec2f8 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -103,9 +103,12 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } } - // Check if bidResponse.Bids is empty + if len(errors) > 0 { + return nil, errors + } + if len(bidResponse.Bids) == 0 { - return nil, []error{fmt.Errorf("No bids returned")} + return nil, []error{fmt.Errorf("no bids returned")} } return bidResponse, nil From 67ffa720d11e6e2a8c7118c0e73c6c79a209df2a Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 11:24:14 -0600 Subject: [PATCH 32/48] removes comment --- adapters/concert/concert.go | 1 - 1 file changed, 1 deletion(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 0497e3ec2f8..73d89f954b9 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -132,7 +132,6 @@ func getMediaTypeForBid(bid openrtb2.Bid, imp *openrtb2.Imp) (openrtb_ext.BidTyp } } - // Infer media type from imp object if imp != nil { if imp.Video != nil { return openrtb_ext.BidTypeVideo, nil From 700ce407a0073aee1eac306a0ffd99acd15d2458 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 11:25:19 -0600 Subject: [PATCH 33/48] removes comments --- adapters/concert/concert.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 73d89f954b9..fae5f07bf2f 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -31,7 +31,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte return nil, []error{err} } - // Unmarshal the request into a map var requestMap map[string]interface{} err = json.Unmarshal(requestJSON, &requestMap) if err != nil { @@ -43,7 +42,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } requestMap["ext"].(map[string]interface{})["adapterVersion"] = adapterVersion - // Marshal the map back into JSON requestJSON, err = json.Marshal(requestMap) if err != nil { return nil, []error{err} From 01c974b3abe4ff20bd4d531ca6be0c92bf7e8366 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 11:33:22 -0600 Subject: [PATCH 34/48] adds optional parameters to imp ext struct --- openrtb_ext/imp_concert.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openrtb_ext/imp_concert.go b/openrtb_ext/imp_concert.go index d29da99347a..940e3220f21 100644 --- a/openrtb_ext/imp_concert.go +++ b/openrtb_ext/imp_concert.go @@ -1,5 +1,9 @@ package openrtb_ext type ImpExtConcert struct { - PartnerId string `json:"partnerId"` + PartnerId string `json:"partnerId"` + PlacementId *int `json:"placementId,omitempty"` + Site *string `json:"site,omitempty"` + Slot *string `json:"slot,omitempty"` + Sizes *[][]int `json:"sizes,omitempty"` } From 5d71877e43e2affb034ca90e7061dac0f3f45380 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 13:40:00 -0600 Subject: [PATCH 35/48] formats impextconcert --- openrtb_ext/imp_concert.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openrtb_ext/imp_concert.go b/openrtb_ext/imp_concert.go index 940e3220f21..bd5ec245c86 100644 --- a/openrtb_ext/imp_concert.go +++ b/openrtb_ext/imp_concert.go @@ -1,9 +1,9 @@ package openrtb_ext type ImpExtConcert struct { - PartnerId string `json:"partnerId"` - PlacementId *int `json:"placementId,omitempty"` - Site *string `json:"site,omitempty"` - Slot *string `json:"slot,omitempty"` - Sizes *[][]int `json:"sizes,omitempty"` + PartnerId string `json:"partnerId"` + PlacementId *int `json:"placementId,omitempty"` + Site *string `json:"site,omitempty"` + Slot *string `json:"slot,omitempty"` + Sizes *[][]int `json:"sizes,omitempty"` } From 8dba23bc316a84aea9ec130416048ff29f9620ae Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Mon, 29 Apr 2024 13:43:58 -0600 Subject: [PATCH 36/48] use prod endpoint --- static/bidder-info/concert.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/bidder-info/concert.yaml b/static/bidder-info/concert.yaml index 5b614d8f61b..8251518f29a 100644 --- a/static/bidder-info/concert.yaml +++ b/static/bidder-info/concert.yaml @@ -1,4 +1,4 @@ -endpoint: "http://localhost:8080/bids/openrtb" +endpoint: "https://bids.concert.io/bids/openrtb" endpointCompression: gzip geoscope: - global From 0b435d21a7ea3a4b1f19282e2c895a902661b639 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Wed, 1 May 2024 11:34:26 -0600 Subject: [PATCH 37/48] uses partnerId for auth header to cbs --- adapters/concert/concert.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index fae5f07bf2f..738e4df8bfe 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -26,6 +26,11 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + bidderImpExt, err := getBidderExt(request.Imp[0]) + if err != nil { + return nil, []error{fmt.Errorf("get bidder ext: %v", err)} + } + requestJSON, err := json.Marshal(request) if err != nil { return nil, []error{err} @@ -41,6 +46,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte requestMap["ext"] = make(map[string]interface{}) } requestMap["ext"].(map[string]interface{})["adapterVersion"] = adapterVersion + requestMap["ext"].(map[string]interface{})["partnerId"] = bidderImpExt.PartnerId requestJSON, err = json.Marshal(requestMap) if err != nil { @@ -53,6 +59,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte Body: requestJSON, Headers: http.Header{ "Content-Type": []string{"application/json"}, + "Authorization": []string{"Bearer " + bidderImpExt.PartnerId}, }, } @@ -144,3 +151,14 @@ func getMediaTypeForBid(bid openrtb2.Bid, imp *openrtb2.Imp) (openrtb_ext.BidTyp Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID), } } + +func getBidderExt(imp openrtb2.Imp) (bidderImpExt openrtb_ext.ImpExtConcert, err error) { + var impExt adapters.ExtImpBidder + if err = json.Unmarshal(imp.Ext, &impExt); err != nil { + return bidderImpExt, fmt.Errorf("imp ext: %v", err) + } + if err = json.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { + return bidderImpExt, fmt.Errorf("bidder ext: %v", err) + } + return bidderImpExt, nil +} \ No newline at end of file From e3407bf733cec618e08a359c84348d4bdf511329 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Wed, 1 May 2024 11:43:54 -0600 Subject: [PATCH 38/48] adds partner ID to top level ext and as auth header --- adapters/concert/concert.go | 4 ++-- adapters/concert/concerttest/exemplary/audio.json | 6 ++++-- adapters/concert/concerttest/exemplary/banner.json | 6 ++++-- adapters/concert/concerttest/exemplary/video.json | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 738e4df8bfe..1b2e0d68fa4 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -58,7 +58,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte Uri: a.endpoint, Body: requestJSON, Headers: http.Header{ - "Content-Type": []string{"application/json"}, + "Content-Type": []string{"application/json"}, "Authorization": []string{"Bearer " + bidderImpExt.PartnerId}, }, } @@ -161,4 +161,4 @@ func getBidderExt(imp openrtb2.Imp) (bidderImpExt openrtb_ext.ImpExtConcert, err return bidderImpExt, fmt.Errorf("bidder ext: %v", err) } return bidderImpExt, nil -} \ No newline at end of file +} diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index 72bed702b2e..d549bbbc2c7 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -31,7 +31,8 @@ "buyeruid": "some-buyer-uid" }, "ext": { - "adapterVersion": "1.0.0" + "adapterVersion": "1.0.0", + "partnerId": "partner_name" } }, "httpCalls": [ @@ -70,7 +71,8 @@ "buyeruid": "some-buyer-uid" }, "ext": { - "adapterVersion": "1.0.0" + "adapterVersion": "1.0.0", + "partnerId": "partner_name" } } }, diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index 318654cf509..441706e8a70 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -39,7 +39,8 @@ "buyeruid": "some-buyer-uid" }, "ext": { - "adapterVersion": "1.0.0" + "adapterVersion": "1.0.0", + "partnerId": "partner_name" } }, "httpCalls": [ @@ -86,7 +87,8 @@ "buyeruid": "some-buyer-uid" }, "ext": { - "adapterVersion": "1.0.0" + "adapterVersion": "1.0.0", + "partnerId": "partner_name" } } }, diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 13afa539cab..098c490942c 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -34,7 +34,8 @@ "buyeruid": "some-buyer-uid" }, "ext": { - "adapterVersion": "1.0.0" + "adapterVersion": "1.0.0", + "partnerId": "partner_name" } }, "httpCalls": [ @@ -76,7 +77,8 @@ "buyeruid": "some-buyer-uid" }, "ext": { - "adapterVersion": "1.0.0" + "adapterVersion": "1.0.0", + "partnerId": "partner_name" } } }, From 8b4e82803279b18f9dd2109d9aa1881b7c67524a Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Wed, 1 May 2024 14:16:43 -0600 Subject: [PATCH 39/48] update auth header --- adapters/concert/concert.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 1b2e0d68fa4..0fe54aeac72 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -59,7 +59,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte Body: requestJSON, Headers: http.Header{ "Content-Type": []string{"application/json"}, - "Authorization": []string{"Bearer " + bidderImpExt.PartnerId}, + "Authorization": []string{"concert-prebid-server"}, }, } From dbdc395d920ec539606136555268f1de77ce05fc Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 2 May 2024 09:27:27 -0600 Subject: [PATCH 40/48] adds impids to makerequests return --- adapters/concert/concert.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 0fe54aeac72..db1b3883048 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -53,15 +53,16 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte return nil, []error{err} } - requestData := &adapters.RequestData{ - Method: "POST", - Uri: a.endpoint, - Body: requestJSON, - Headers: http.Header{ - "Content-Type": []string{"application/json"}, - "Authorization": []string{"concert-prebid-server"}, - }, - } + headers := http.Header{} + headers.Add("Content-Type", "application/json") + headers.Add("Authorization", "concert-prebid-server") + return []*adapters.RequestData{{ + Method: "POST", + Uri: a.endpoint, + Body: requestJSON, + Headers: headers, + ImpIDs: openrtb_ext.GetImpIDs(request.Imp), + }}, errs return []*adapters.RequestData{requestData}, nil } From 39570100175a98ea4aeb9c8c53869b4cbd15d2e0 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 2 May 2024 09:29:55 -0600 Subject: [PATCH 41/48] fixes return statement --- adapters/concert/concert.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index db1b3883048..ac08ddc1cd4 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -55,14 +55,15 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte headers := http.Header{} headers.Add("Content-Type", "application/json") + headers.Add("Accept", "application/json") headers.Add("Authorization", "concert-prebid-server") - return []*adapters.RequestData{{ + requestData := &adapters.RequestData{ Method: "POST", Uri: a.endpoint, Body: requestJSON, Headers: headers, ImpIDs: openrtb_ext.GetImpIDs(request.Imp), - }}, errs + } return []*adapters.RequestData{requestData}, nil } From fcd880ede7de91b98683254b076be90790f6514a Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 2 May 2024 09:41:25 -0600 Subject: [PATCH 42/48] updates test json files with impids in request obj --- adapters/concert/concerttest/exemplary/audio.json | 3 ++- adapters/concert/concerttest/exemplary/banner.json | 3 ++- adapters/concert/concerttest/exemplary/video.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index d549bbbc2c7..42eab0a241a 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -74,7 +74,8 @@ "adapterVersion": "1.0.0", "partnerId": "partner_name" } - } + }, + "impIDs":["test-imp-id"] }, "mockResponse": { "status": 200, diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index 441706e8a70..d12b6ee4e02 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -90,7 +90,8 @@ "adapterVersion": "1.0.0", "partnerId": "partner_name" } - } + }, + "impIDs":["test-imp-id"] }, "mockResponse": { "status": 200, diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 098c490942c..6e51369859a 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -80,7 +80,8 @@ "adapterVersion": "1.0.0", "partnerId": "partner_name" } - } + }, + "impIDs":["test-imp-id"] }, "mockResponse": { "status": 200, From ba289c206f0e6af0a776d32ed0c5cff2fb073b34 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 2 May 2024 12:19:26 -0600 Subject: [PATCH 43/48] removes authorization header - no longer needed in bidding server --- adapters/concert/concert.go | 1 - 1 file changed, 1 deletion(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index ac08ddc1cd4..ebb3b1efc24 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -56,7 +56,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte headers := http.Header{} headers.Add("Content-Type", "application/json") headers.Add("Accept", "application/json") - headers.Add("Authorization", "concert-prebid-server") requestData := &adapters.RequestData{ Method: "POST", Uri: a.endpoint, From 364eb9016b902f718e82c0284a098d89baaf3d11 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Wed, 15 May 2024 09:48:32 -0600 Subject: [PATCH 44/48] Checks MType --- adapters/concert/concert.go | 42 +++++++++---------- .../concert/concerttest/exemplary/audio.json | 6 ++- .../concert/concerttest/exemplary/banner.json | 6 ++- .../concert/concerttest/exemplary/video.json | 6 ++- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index ebb3b1efc24..018ad76afe7 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -3,12 +3,13 @@ package concert import ( "encoding/json" "fmt" + "net/http" + "github.com/prebid/openrtb/v20/openrtb2" "github.com/prebid/prebid-server/v2/adapters" "github.com/prebid/prebid-server/v2/config" "github.com/prebid/prebid-server/v2/errortypes" "github.com/prebid/prebid-server/v2/openrtb_ext" - "net/http" ) type adapter struct { @@ -96,8 +97,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R var errors []error for _, seatBid := range response.SeatBid { for i, bid := range seatBid.Bid { - imp, _ := getImpByID(bid.ImpID, request.Imp) - bidType, err := getMediaTypeForBid(bid, imp) + bidType, err := getMediaTypeForBid(bid) if err != nil { errors = append(errors, err) continue @@ -120,16 +120,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return bidResponse, nil } -func getImpByID(impID string, imps []openrtb2.Imp) (*openrtb2.Imp, error) { - for _, imp := range imps { - if imp.ID == impID { - return &imp, nil - } - } - return nil, fmt.Errorf("no matching imp found for id %s", impID) -} - -func getMediaTypeForBid(bid openrtb2.Bid, imp *openrtb2.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForBidFromExt(bid openrtb2.Bid) (openrtb_ext.BidType, error) { if bid.Ext != nil { var bidExt openrtb_ext.ExtBid err := json.Unmarshal(bid.Ext, &bidExt) @@ -138,18 +129,23 @@ func getMediaTypeForBid(bid openrtb2.Bid, imp *openrtb2.Imp) (openrtb_ext.BidTyp } } - if imp != nil { - if imp.Video != nil { - return openrtb_ext.BidTypeVideo, nil - } else if imp.Banner != nil { - return openrtb_ext.BidTypeBanner, nil - } else if imp.Audio != nil { - return openrtb_ext.BidTypeAudio, nil - } + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Failed to parse media type for bid: \"%s\"", bid.ImpID), } +} - return "", &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID), +func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { + switch bid.MType { + case openrtb2.MarkupBanner: + return openrtb_ext.BidTypeBanner, nil + case openrtb2.MarkupVideo: + return openrtb_ext.BidTypeVideo, nil + case openrtb2.MarkupAudio: + return openrtb_ext.BidTypeAudio, nil + case openrtb2.MarkupNative: + return "", fmt.Errorf("native media types are not yet supported") + default: + return getMediaTypeForBidFromExt(bid) } } diff --git a/adapters/concert/concerttest/exemplary/audio.json b/adapters/concert/concerttest/exemplary/audio.json index 42eab0a241a..66363d5a256 100644 --- a/adapters/concert/concerttest/exemplary/audio.json +++ b/adapters/concert/concerttest/exemplary/audio.json @@ -89,7 +89,8 @@ "impid": "test-imp-id", "price": 1.23, "adm": "...", - "crid": "test-creative-id" + "crid": "test-creative-id", + "mtype": 3 } ] } @@ -107,7 +108,8 @@ "impid": "test-imp-id", "price": 1.23, "adm": "...", - "crid": "test-creative-id" + "crid": "test-creative-id", + "mtype": 3 }, "type": "audio" } diff --git a/adapters/concert/concerttest/exemplary/banner.json b/adapters/concert/concerttest/exemplary/banner.json index d12b6ee4e02..6fc0df4e604 100644 --- a/adapters/concert/concerttest/exemplary/banner.json +++ b/adapters/concert/concerttest/exemplary/banner.json @@ -107,7 +107,8 @@ "adm": "

Banner Ad

This is a mock banner ad

", "crid": "test-creative-id", "w": 1030, - "h": 590 + "h": 590, + "mtype": 1 } ] } @@ -127,7 +128,8 @@ "adm": "

Banner Ad

This is a mock banner ad

", "crid": "test-creative-id", "w": 1030, - "h": 590 + "h": 590, + "mtype": 1 }, "type": "banner" } diff --git a/adapters/concert/concerttest/exemplary/video.json b/adapters/concert/concerttest/exemplary/video.json index 6e51369859a..fdb21d04d4a 100644 --- a/adapters/concert/concerttest/exemplary/video.json +++ b/adapters/concert/concerttest/exemplary/video.json @@ -97,7 +97,8 @@ "adm": "...", "crid": "test-creative-id", "w": 640, - "h": 480 + "h": 480, + "mtype": 2 } ] } @@ -117,7 +118,8 @@ "adm": "...", "crid": "test-creative-id", "w": 640, - "h": 480 + "h": 480, + "mtype": 2 }, "type": "video" } From 4c03143c4f69fcb615bd35d113b295ae57e1909b Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 16 May 2024 15:23:49 -0600 Subject: [PATCH 45/48] fallback for mtype no longer needed --- adapters/concert/concert.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index 018ad76afe7..ee535bfe83f 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -120,20 +120,6 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return bidResponse, nil } -func getMediaTypeForBidFromExt(bid openrtb2.Bid) (openrtb_ext.BidType, error) { - if bid.Ext != nil { - var bidExt openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &bidExt) - if err == nil && bidExt.Prebid != nil { - return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) - } - } - - return "", &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Failed to parse media type for bid: \"%s\"", bid.ImpID), - } -} - func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { switch bid.MType { case openrtb2.MarkupBanner: @@ -144,8 +130,10 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { return openrtb_ext.BidTypeAudio, nil case openrtb2.MarkupNative: return "", fmt.Errorf("native media types are not yet supported") - default: - return getMediaTypeForBidFromExt(bid) + default: + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Failed to parse media type for bid: \"%s\"", bid.ImpID), + } } } From 56423485a6f6e1897ef41c4b1010cfef3863ed70 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Thu, 16 May 2024 15:28:24 -0600 Subject: [PATCH 46/48] formatting --- adapters/concert/concert.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index ee535bfe83f..d4c0870befc 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -130,10 +130,10 @@ func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { return openrtb_ext.BidTypeAudio, nil case openrtb2.MarkupNative: return "", fmt.Errorf("native media types are not yet supported") - default: - return "", &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Failed to parse media type for bid: \"%s\"", bid.ImpID), - } + default: + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Failed to parse media type for bid: \"%s\"", bid.ImpID), + } } } From 9c3026567299f00f4e70c8c6e471d4f3a220983e Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 28 May 2024 08:59:45 -0600 Subject: [PATCH 47/48] updates error response handling in makebids --- adapters/concert/concert.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index d4c0870befc..c4ccdbc7966 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -69,22 +69,14 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if responseData.StatusCode == http.StatusNoContent { + if adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } - if responseData.StatusCode == http.StatusBadRequest { - err := &errortypes.BadInput{ - Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", - } - return nil, []error{err} - } - - if responseData.StatusCode != http.StatusOK { - err := &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), - } - return nil, []error{err} + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", responseData.StatusCode), + }} } var response openrtb2.BidResponse From 2c7b6f90bcaee39066edf20918488ce648c43ad3 Mon Sep 17 00:00:00 2001 From: Brett Bloxom Date: Tue, 28 May 2024 09:01:02 -0600 Subject: [PATCH 48/48] use response error message --- adapters/concert/concert.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/adapters/concert/concert.go b/adapters/concert/concert.go index c4ccdbc7966..26bb105842a 100644 --- a/adapters/concert/concert.go +++ b/adapters/concert/concert.go @@ -74,9 +74,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { - return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", responseData.StatusCode), - }} + return nil, []error{err} } var response openrtb2.BidResponse