Skip to content

Commit

Permalink
GumGum: adds slot param (prebid#1949)
Browse files Browse the repository at this point in the history
  • Loading branch information
susyt authored Aug 11, 2021
1 parent 914a1fd commit 2e3376a
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 0 deletions.
34 changes: 34 additions & 0 deletions adapters/gumgum/gumgum.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ func preprocess(imp *openrtb2.Imp) (*openrtb_ext.ExtImpGumGum, error) {
format := bannerCopy.Format[0]
bannerCopy.W = &(format.W)
bannerCopy.H = &(format.H)

if gumgumExt.Slot != 0 {
var err error
bannerExt := getBiggerFormat(bannerCopy.Format, gumgumExt.Slot)
bannerCopy.Ext, err = json.Marshal(&bannerExt)
if err != nil {
return nil, err
}
}

imp.Banner = &bannerCopy
}

Expand All @@ -169,6 +179,30 @@ func preprocess(imp *openrtb2.Imp) (*openrtb_ext.ExtImpGumGum, error) {
return &gumgumExt, nil
}

func getBiggerFormat(formatList []openrtb2.Format, slot float64) openrtb_ext.ExtImpGumGumBanner {
maxw := int64(0)
maxh := int64(0)
greatestVal := int64(0)
for _, size := range formatList {
var biggerSide int64
if size.W > size.H {
biggerSide = size.W
} else {
biggerSide = size.H
}

if biggerSide > greatestVal || (biggerSide == greatestVal && size.W >= maxw && size.H >= maxh) {
greatestVal = biggerSide
maxh = size.H
maxw = size.W
}
}

bannerExt := openrtb_ext.ExtImpGumGumBanner{Si: slot, MaxW: float64(maxw), MaxH: float64(maxh)}

return bannerExt
}

func getMediaTypeForImpID(impID string, imps []openrtb2.Imp) openrtb_ext.BidType {
for _, imp := range imps {
if imp.ID == impID && imp.Banner != nil {
Expand Down
107 changes: 107 additions & 0 deletions adapters/gumgum/gumgumtest/supplemental/banner-with-slot-param.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 300
}
]
},
"ext": {
"bidder": {
"zone": "dc9d6be1",
"slot": 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": {
"si": 12345678,
"maxw": 300,
"maxh": 300
}
},
"ext": {
"bidder": {
"zone": "dc9d6be1",
"slot": 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"
}
]
}
]
}
3 changes: 3 additions & 0 deletions adapters/gumgum/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var validParams = []string{
`{"zone":"dc9d6be1"}`,
`{"pubId":12345678}`,
`{"zone":"dc9d6be1", "pubId":12345678}`,
`{"zone":"dc9d6be1", "slot":1234567}`,
`{"pubId":12345678, "slot":1234567}`,
`{"pubId":12345678, "irisid": "iris_6f9285823a48bne5"}`,
`{"zone":"dc9d6be1", "irisid": "iris_6f9285823a48bne5"}`,
`{"zone":"dc9d6be1", "pubId":12345678, "irisid": "iris_6f9285823a48bne5"}`,
Expand All @@ -55,6 +57,7 @@ var invalidParams = []string{
`{"zone": true}`,
`{"placementId": 1, "zone":"1234567"}`,
`{"pubId":"123456"}`,
`{"slot":123456}`,
`{"zone":"1234567", "irisid": ""}`,
`{"zone":"1234567", "irisid": 1234}`,
`{"irisid": "iris_6f9285823a48bne5"}`,
Expand Down
8 changes: 8 additions & 0 deletions openrtb_ext/imp_gumgum.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ type ExtImpGumGum struct {
Zone string `json:"zone,omitempty"`
PubID float64 `json:"pubId,omitempty"`
IrisID string `json:"irisid,omitempty"`
Slot float64 `json:"slot,omitempty"`
}

// ExtImpGumGumVideo defines the contract for bidresponse.seatbid.bid[i].ext.gumgum.video
type ExtImpGumGumVideo struct {
IrisID string `json:"irisid,omitempty"`
}

// ExtImpGumGumBanner defines the contract for bidresponse.seatbid.bid[i].ext.gumgum.banner
type ExtImpGumGumBanner struct {
Si float64 `json:"si,omitempty"`
MaxW float64 `json:"maxw,omitempty"`
MaxH float64 `json:"maxh,omitempty"`
}
4 changes: 4 additions & 0 deletions static/bidder-params/gumgum.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"irisid": {
"type": "string",
"description": "A hashed IRIS.TV Content ID"
},
"slot": {
"type": "integer",
"description": "A slot id used to identify a slot placement mapped to a GumGum zone or publisher"
}
},
"anyOf": [
Expand Down

0 comments on commit 2e3376a

Please sign in to comment.