-
Notifications
You must be signed in to change notification settings - Fork 750
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
Flipp: use height value from server response #3940
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
70dec6e
OFF-1457: height should use the compactHeight and standardHeight fiel…
MishelleBit 18cf454
Merge remote-tracking branch 'prebid/master'
MishelleBit cbe75ab
handle diff types of customData
MishelleBit 7c84694
use jsonutil instead of json
MishelleBit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,16 +21,20 @@ import ( | |
) | ||
|
||
const ( | ||
bannerType = "banner" | ||
inlineDivName = "inline" | ||
flippBidder = "flipp" | ||
defaultCurrency = "USD" | ||
bannerType = "banner" | ||
inlineDivName = "inline" | ||
flippBidder = "flipp" | ||
defaultCurrency = "USD" | ||
defaultStandardHeight int64 = 2400 | ||
defaultCompactHeight int64 = 600 | ||
) | ||
|
||
var ( | ||
count int64 = 1 | ||
adTypes = []int64{4309, 641} | ||
dtxTypes = []int64{5061} | ||
count int64 = 1 | ||
adTypes = []int64{4309, 641} | ||
dtxTypes = []int64{5061} | ||
flippExtParams openrtb_ext.ImpExtFlipp | ||
customDataKey string | ||
) | ||
|
||
type adapter struct { | ||
|
@@ -199,10 +203,18 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R | |
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) | ||
bidResponse.Currency = defaultCurrency | ||
for _, imp := range request.Imp { | ||
params, _, _, err := jsonparser.Get(imp.Ext, "bidder") | ||
if err != nil { | ||
return nil, []error{fmt.Errorf("flipp params not found. %v", err)} | ||
} | ||
err = json.Unmarshal(params, &flippExtParams) | ||
if err != nil { | ||
return nil, []error{fmt.Errorf("unable to extract flipp params. %v", err)} | ||
} | ||
for _, decision := range campaignResponseBody.Decisions.Inline { | ||
if *decision.Prebid.RequestID == imp.ID { | ||
b := &adapters.TypedBid{ | ||
Bid: buildBid(decision, imp.ID), | ||
Bid: buildBid(decision, imp.ID, flippExtParams), | ||
BidType: openrtb_ext.BidType(bannerType), | ||
} | ||
bidResponse.Bids = append(bidResponse.Bids, b) | ||
|
@@ -219,7 +231,7 @@ func getAdTypes(creativeType string) []int64 { | |
return adTypes | ||
} | ||
|
||
func buildBid(decision *InlineModel, impId string) *openrtb2.Bid { | ||
func buildBid(decision *InlineModel, impId string, flippExtParams openrtb_ext.ImpExtFlipp) *openrtb2.Bid { | ||
bid := &openrtb2.Bid{ | ||
CrID: fmt.Sprint(decision.CreativeID), | ||
Price: *decision.Prebid.Cpm, | ||
|
@@ -231,7 +243,20 @@ func buildBid(decision *InlineModel, impId string) *openrtb2.Bid { | |
if decision.Contents[0].Data.Width != 0 { | ||
bid.W = decision.Contents[0].Data.Width | ||
} | ||
bid.H = 0 | ||
customDataInterface := decision.Contents[0].Data.CustomData | ||
customDataMap := customDataInterface.(map[string]interface{}) | ||
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 a test case where customdata is a different type to verify this adapter code gracefully handles and error and doesn't panic on an incorrect response. |
||
|
||
bid.H = defaultStandardHeight | ||
customDataKey = "standardHeight" | ||
if flippExtParams.Options.StartCompact { | ||
bid.H = defaultCompactHeight | ||
customDataKey = "compactHeight" | ||
} | ||
if value, exists := customDataMap[customDataKey]; exists { | ||
if floatVal, ok := value.(float64); ok { | ||
bid.H = int64(floatVal) | ||
} | ||
} | ||
} | ||
return bid | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 use
jsonutil.Unmarshal
instead.