-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversant: Make requests in USD #3611
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/prebid/openrtb/v20/adcom1" | ||
"github.com/prebid/openrtb/v20/openrtb2" | ||
|
@@ -18,6 +19,10 @@ type ConversantAdapter struct { | |
} | ||
|
||
func (c *ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { | ||
//Backend needs USD or it will reject the request | ||
if len(request.Cur) > 0 && request.Cur[0] != "USD" { | ||
request.Cur = []string{"USD"} | ||
} | ||
for i := 0; i < len(request.Imp); i++ { | ||
var bidderExt adapters.ExtImpBidder | ||
if err := json.Unmarshal(request.Imp[i].Ext, &bidderExt); err != nil { | ||
|
@@ -50,7 +55,10 @@ func (c *ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo * | |
request.App.ID = cnvrExt.SiteID | ||
} | ||
} | ||
parseCnvrParams(&request.Imp[i], cnvrExt) | ||
err := parseCnvrParams(&request.Imp[i], cnvrExt, reqInfo) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
//create the request body | ||
|
@@ -72,7 +80,7 @@ func (c *ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo * | |
}}, nil | ||
} | ||
|
||
func parseCnvrParams(imp *openrtb2.Imp, cnvrExt openrtb_ext.ExtImpConversant) { | ||
func parseCnvrParams(imp *openrtb2.Imp, cnvrExt openrtb_ext.ExtImpConversant, reqInfo *adapters.ExtraRequestInfo) []error { | ||
imp.DisplayManager = "prebid-s2s" | ||
imp.DisplayManagerVer = "2.0.0" | ||
|
||
|
@@ -130,6 +138,17 @@ func parseCnvrParams(imp *openrtb2.Imp, cnvrExt openrtb_ext.ExtImpConversant) { | |
imp.Video.MaxDuration = *cnvrExt.MaxDuration | ||
} | ||
} | ||
if imp.BidFloor > 0 && imp.BidFloorCur != "" && strings.ToUpper(imp.BidFloorCur) != "USD" { | ||
floor, err := reqInfo.ConvertCurrency(imp.BidFloor, imp.BidFloorCur, "USD") | ||
if err != nil { | ||
return []error{&errortypes.BadInput{ | ||
Message: fmt.Sprintf("Unable to convert provided bid floor currency from %s to USD", imp.BidFloorCur), | ||
}} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would the floor not be greater than 0 after a currency conversion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking I didn't want a negative floor, but now I think better to pass it through than mysteriously dropping it. fixed |
||
imp.BidFloorCur = "USD" | ||
imp.BidFloor = floor | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add the json test case for this change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added this to one of the test cases |
||
return nil | ||
} | ||
|
||
func (c *ConversantAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the json test cases for this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added this to one of the test cases