Skip to content
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

Merged
merged 6 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 46 additions & 25 deletions adapters/gumgum/gumgum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Comment on lines +26 to +28
Copy link
Collaborator

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.

Copy link
Contributor Author

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


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)
}
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

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 case where IrisID is not an empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 {
Expand Down
97 changes: 97 additions & 0 deletions adapters/gumgum/gumgumtest/supplemental/banner-only-in-format.json
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"
}
]
}
]
}
99 changes: 99 additions & 0 deletions adapters/gumgum/gumgumtest/supplemental/banner-with-pubId.json
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"
}
]
}
]
}
Loading