Skip to content

Commit

Permalink
Rise: Change the name of the mandatory field (#2929)
Browse files Browse the repository at this point in the history
Authored by: @zkosanovic
  • Loading branch information
zkosanovic authored Jul 31, 2023
1 parent 8ffa1c6 commit 2c3ec84
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 26 deletions.
14 changes: 9 additions & 5 deletions adapters/rise/rise.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/prebid/openrtb/v19/openrtb2"

"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/openrtb_ext"
Expand All @@ -26,9 +27,9 @@ func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (

// MakeRequests prepares the HTTP requests which should be made to fetch bids.
func (a *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) {
publisherID, err := extractPublisherID(openRTBRequest)
org, err := extractOrg(openRTBRequest)
if err != nil {
errs = append(errs, fmt.Errorf("extractPublisherID: %w", err))
errs = append(errs, fmt.Errorf("extractOrg: %w", err))
return nil, errs
}

Expand All @@ -43,7 +44,7 @@ func (a *adapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, _ *adapters.

return append(requestsToBidder, &adapters.RequestData{
Method: http.MethodPost,
Uri: a.endpointURL + "?publisher_id=" + publisherID,
Uri: a.endpointURL + "?publisher_id=" + org,
Body: openRTBRequestJSON,
Headers: headers,
}), nil
Expand Down Expand Up @@ -87,7 +88,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData
return bidResponse, errs
}

func extractPublisherID(openRTBRequest *openrtb2.BidRequest) (string, error) {
func extractOrg(openRTBRequest *openrtb2.BidRequest) (string, error) {
var err error
for _, imp := range openRTBRequest.Imp {
var bidderExt adapters.ExtImpBidder
Expand All @@ -100,12 +101,15 @@ func extractPublisherID(openRTBRequest *openrtb2.BidRequest) (string, error) {
return "", fmt.Errorf("unmarshal ImpExtRise: %w", err)
}

if impExt.Org != "" {
return strings.TrimSpace(impExt.Org), nil
}
if impExt.PublisherID != "" {
return strings.TrimSpace(impExt.PublisherID), nil
}
}

return "", errors.New("no publisherID supplied")
return "", errors.New("no org or publisher_id supplied")
}

func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) {
Expand Down
8 changes: 4 additions & 4 deletions adapters/rise/risetest/exemplary/banner-and-video-app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand All @@ -41,7 +41,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand Down Expand Up @@ -98,7 +98,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand All @@ -121,7 +121,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand Down
8 changes: 4 additions & 4 deletions adapters/rise/risetest/exemplary/banner-and-video-gdpr.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand All @@ -41,7 +41,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand Down Expand Up @@ -83,7 +83,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand All @@ -106,7 +106,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand Down
4 changes: 2 additions & 2 deletions adapters/rise/risetest/exemplary/banner-and-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand Down Expand Up @@ -123,7 +123,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand Down
117 changes: 117 additions & 0 deletions adapters/rise/risetest/exemplary/simple-banner-both-ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 300
}
]
},
"ext": {
"bidder": {
"org": "72720",
"publisher_id": "72721",
"path": "mvo",
"zone": "1r"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://localhost/prebid_server?publisher_id=72720",
"body": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 300
}
]
},
"ext": {
"bidder": {
"org": "72720",
"publisher_id": "72721",
"zone": "1r",
"path": "mvo"
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "Rhythmone",
"bid": [
{
"id": "7706636740145184841",
"impid": "test-imp-id",
"price": 0.500000,
"adid": "29681110",
"adm": "some-test-ad",
"adomain": [
"yahoo.com"
],
"cid": "958",
"crid": "29681110",
"h": 250,
"w": 300,
"mtype": 1
}
]
}
],
"bidid": "5778926625248726496",
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"bids": [{
"bid": {
"id": "7706636740145184841",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-ad",
"adid": "29681110",
"adomain": [
"yahoo.com"
],
"cid": "958",
"crid": "29681110",
"w": 300,
"h": 250,
"mtype": 1
},
"type": "banner"
}]
}
]
}
4 changes: 2 additions & 2 deletions adapters/rise/risetest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand Down Expand Up @@ -55,7 +55,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand Down
4 changes: 2 additions & 2 deletions adapters/rise/risetest/supplemental/bad-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand Down Expand Up @@ -55,7 +55,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand Down
2 changes: 1 addition & 1 deletion adapters/rise/risetest/supplemental/missing-bidder.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"expectedMakeRequestsErrors": [
{
"value": "extractPublisherID: unmarshal ImpExtRise: unexpected end of JSON input",
"value": "extractOrg: unmarshal ImpExtRise: unexpected end of JSON input",
"comparison": "literal"
}
]
Expand Down
2 changes: 1 addition & 1 deletion adapters/rise/risetest/supplemental/missing-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"expectedMakeRequestsErrors": [
{
"value": "extractPublisherID: unmarshal bidderExt: unexpected end of JSON input",
"value": "extractOrg: unmarshal bidderExt: unexpected end of JSON input",
"comparison": "literal"
}
]
Expand Down
4 changes: 2 additions & 2 deletions adapters/rise/risetest/supplemental/missing-mtype.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"path": "mvo",
"zone": "1r"
}
Expand Down Expand Up @@ -55,7 +55,7 @@
},
"ext": {
"bidder": {
"publisher_id": "72721",
"org": "72721",
"zone": "1r",
"path": "mvo"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
},
"ext": {
"bidder": {
"org": "",
"publisher_id": ""
}}
}
]
},
"expectedMakeRequestsErrors": [
{
"value": "extractPublisherID: no publisherID supplied",
"value": "extractOrg: no org or publisher_id supplied",
"comparison": "literal"
}
]
Expand Down
1 change: 1 addition & 0 deletions openrtb_ext/imp_rise.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package openrtb_ext
// ImpExtRise defines the contract for bidrequest.imp[i].ext.prebid.bidder.rise
type ImpExtRise struct {
PublisherID string `json:"publisher_id"`
Org string `json:"org"`
}
11 changes: 9 additions & 2 deletions static/bidder-params/rise.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
"description": "A schema which validates params accepted by the Rise adapter",
"type": "object",
"properties": {
"org": {
"type": "string",
"description": "The organization ID."
},
"publisher_id": {
"type": "string",
"description": "The publisher ID"
"description": "Deprecated, use org instead."
}
},
"required": ["publisher_id"]
"oneOf": [
{ "required": ["org"] },
{ "required": ["publisher_id"] }
]
}

0 comments on commit 2c3ec84

Please sign in to comment.