-
Notifications
You must be signed in to change notification settings - Fork 742
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
GumGum: adds pubId and irisid properties/parameters #1664
Changes from all commits
8f5b940
19d83f5
440398e
4faf1ee
8b4214e
2bb2519
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 |
---|---|---|
|
@@ -22,34 +22,33 @@ type GumGumAdapter struct { | |
// MakeRequests makes the HTTP requests which should be made to fetch bids. | ||
func (g *GumGumAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { | ||
var validImps []openrtb.Imp | ||
var trackingId string | ||
var siteCopy openrtb.Site | ||
if request.Site != nil { | ||
siteCopy = *request.Site | ||
} | ||
|
||
numRequests := len(request.Imp) | ||
errs := make([]error, 0, numRequests) | ||
|
||
for i := 0; i < numRequests; i++ { | ||
imp := request.Imp[i] | ||
zone, err := preprocess(&imp) | ||
gumgumExt, err := preprocess(&imp) | ||
if err != nil { | ||
errs = append(errs, err) | ||
} else if request.Imp[i].Banner != nil { | ||
bannerCopy := *request.Imp[i].Banner | ||
if bannerCopy.W == nil && bannerCopy.H == nil && len(bannerCopy.Format) > 0 { | ||
format := bannerCopy.Format[0] | ||
bannerCopy.W = &(format.W) | ||
bannerCopy.H = &(format.H) | ||
} else { | ||
if gumgumExt.Zone != "" { | ||
siteCopy.ID = gumgumExt.Zone | ||
} | ||
request.Imp[i].Banner = &bannerCopy | ||
validImps = append(validImps, request.Imp[i]) | ||
trackingId = zone | ||
} else if request.Imp[i].Video != nil { | ||
err := validateVideoParams(request.Imp[i].Video) | ||
if err != nil { | ||
errs = append(errs, err) | ||
} else { | ||
validImps = append(validImps, request.Imp[i]) | ||
trackingId = zone | ||
|
||
if gumgumExt.PubID != 0 { | ||
if siteCopy.Publisher != nil { | ||
siteCopy.Publisher.ID = strconv.FormatFloat(gumgumExt.PubID, 'f', -1, 64) | ||
} else { | ||
siteCopy.Publisher = &openrtb.Publisher{ID: strconv.FormatFloat(gumgumExt.PubID, 'f', -1, 64)} | ||
} | ||
} | ||
|
||
validImps = append(validImps, imp) | ||
} | ||
} | ||
|
||
|
@@ -60,8 +59,6 @@ func (g *GumGumAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt | |
request.Imp = validImps | ||
|
||
if request.Site != nil { | ||
siteCopy := *request.Site | ||
siteCopy.ID = trackingId | ||
request.Site = &siteCopy | ||
} | ||
|
||
|
@@ -127,25 +124,49 @@ func (g *GumGumAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe | |
return bidResponse, errs | ||
} | ||
|
||
func preprocess(imp *openrtb.Imp) (string, error) { | ||
func preprocess(imp *openrtb.Imp) (*openrtb_ext.ExtImpGumGum, error) { | ||
var bidderExt adapters.ExtImpBidder | ||
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { | ||
err = &errortypes.BadInput{ | ||
Message: err.Error(), | ||
} | ||
return "", err | ||
return nil, err | ||
} | ||
|
||
var gumgumExt openrtb_ext.ExtImpGumGum | ||
if err := json.Unmarshal(bidderExt.Bidder, &gumgumExt); err != nil { | ||
err = &errortypes.BadInput{ | ||
Message: err.Error(), | ||
} | ||
return "", err | ||
return nil, err | ||
} | ||
|
||
if imp.Banner != nil && imp.Banner.W == nil && imp.Banner.H == nil && len(imp.Banner.Format) > 0 { | ||
bannerCopy := *imp.Banner | ||
format := bannerCopy.Format[0] | ||
bannerCopy.W = &(format.W) | ||
bannerCopy.H = &(format.H) | ||
imp.Banner = &bannerCopy | ||
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. Perhaps we should only copy the Banner and update the imp inside the above if statement? No need to do the work of copying the Banner if we aren't going to change anything. |
||
} | ||
|
||
if imp.Video != nil { | ||
err := validateVideoParams(imp.Video) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if gumgumExt.IrisID != "" { | ||
videoCopy := *imp.Video | ||
videoExt := openrtb_ext.ExtImpGumGumVideo{IrisID: gumgumExt.IrisID} | ||
videoCopy.Ext, err = json.Marshal(&videoExt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
imp.Video = &videoCopy | ||
Comment on lines
+158
to
+165
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 JSON test case where 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. video-with-irisid.json test added! |
||
} | ||
} | ||
|
||
zone := gumgumExt.Zone | ||
return zone, nil | ||
return &gumgumExt, nil | ||
} | ||
|
||
func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"imp": [ | ||
{ | ||
"id": "test-imp-id", | ||
"banner": { | ||
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 250 | ||
}, | ||
{ | ||
"w": 300, | ||
"h": 300 | ||
} | ||
] | ||
}, | ||
"ext": { | ||
"bidder": { | ||
"zone": "dc9d6be1" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
|
||
"httpCalls": [ | ||
{ | ||
"expectedRequest": { | ||
"uri": "https://g2.gumgum.com/providers/prbds2s/bid", | ||
"body":{ | ||
"id": "test-request-id", | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}, { | ||
"w": 300, | ||
"h": 300 | ||
}], | ||
"w": 300, | ||
"h": 250 | ||
}, | ||
"ext": { | ||
"bidder": { | ||
"zone": "dc9d6be1" | ||
} | ||
} | ||
}] | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"seatbid": [ | ||
{ | ||
"bid": [ | ||
{ | ||
"crid": "2068416", | ||
"adm": "some-test-ad", | ||
"adid": "2068416", | ||
"price": 5, | ||
"id": "5736a50b-6b05-42a8-aa6d-b0a4649dcd05", | ||
"impid": "test-imp-id", | ||
"cid": "4747" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
|
||
"expectedBidResponses": [ | ||
{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"crid": "2068416", | ||
"adm": "some-test-ad", | ||
"adid": "2068416", | ||
"price": 5, | ||
"id": "5736a50b-6b05-42a8-aa6d-b0a4649dcd05", | ||
"impid": "test-imp-id", | ||
"cid": "4747" | ||
}, | ||
"type": "banner" | ||
} | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"imp": [ | ||
{ | ||
"id": "test-imp-id", | ||
"banner": { | ||
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 250 | ||
}, | ||
{ | ||
"w": 300, | ||
"h": 300 | ||
} | ||
], | ||
"w": 300, | ||
"h": 250 | ||
}, | ||
"ext": { | ||
"bidder": { | ||
"pubId": 12345678 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
|
||
"httpCalls": [ | ||
{ | ||
"expectedRequest": { | ||
"uri": "https://g2.gumgum.com/providers/prbds2s/bid", | ||
"body":{ | ||
"id": "test-request-id", | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}, { | ||
"w": 300, | ||
"h": 300 | ||
}], | ||
"w": 300, | ||
"h": 250 | ||
}, | ||
"ext": { | ||
"bidder": { | ||
"pubId": 12345678 | ||
} | ||
} | ||
}] | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"seatbid": [ | ||
{ | ||
"bid": [ | ||
{ | ||
"crid": "2068416", | ||
"adm": "some-test-ad", | ||
"adid": "2068416", | ||
"price": 5, | ||
"id": "5736a50b-6b05-42a8-aa6d-b0a4649dcd05", | ||
"impid": "test-imp-id", | ||
"cid": "4747" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
|
||
"expectedBidResponses": [ | ||
{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"crid": "2068416", | ||
"adm": "some-test-ad", | ||
"adid": "2068416", | ||
"price": 5, | ||
"id": "5736a50b-6b05-42a8-aa6d-b0a4649dcd05", | ||
"impid": "test-imp-id", | ||
"cid": "4747" | ||
}, | ||
"type": "banner" | ||
} | ||
] | ||
} | ||
] | ||
} |
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 a JSON test where the site is not nil.
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.
banner-with-site.json test added