Skip to content

Commit

Permalink
add support for reading pbadslot in imp[].ext.data and outputting it …
Browse files Browse the repository at this point in the history
…as imp.ext.gpid in yieldmo request (prebid#1935)
  • Loading branch information
ym-winston authored Aug 5, 2021
1 parent bca2fb1 commit cb1193a
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 1 deletion.
18 changes: 17 additions & 1 deletion adapters/yieldmo/yieldmo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ type YieldmoAdapter struct {
endpoint string
}

type ExtImpBidderYieldmo struct {
adapters.ExtImpBidder
Data *ExtData `json:"data,omitempty"`
}

type ExtData struct {
PbAdslot string `json:"pbadslot"`
}

type Ext struct {
PlacementId string `json:"placement_id"`
Gpid string `json:"gpid,omitempty"`
}

func (a *YieldmoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
Expand Down Expand Up @@ -62,7 +72,7 @@ func (a *YieldmoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.Re
func preprocess(request *openrtb2.BidRequest) error {
for i := 0; i < len(request.Imp); i++ {
var imp = request.Imp[i]
var bidderExt adapters.ExtImpBidder
var bidderExt ExtImpBidderYieldmo

if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return &errortypes.BadInput{
Expand All @@ -81,6 +91,12 @@ func preprocess(request *openrtb2.BidRequest) error {
var impExt Ext
impExt.PlacementId = yieldmoExt.PlacementId

if bidderExt.Data != nil {
if bidderExt.Data.PbAdslot != "" {
impExt.Gpid = bidderExt.Data.PbAdslot
}
}

impExtJSON, err := json.Marshal(impExt)
if err != nil {
return &errortypes.BadInput{
Expand Down
105 changes: 105 additions & 0 deletions adapters/yieldmo/yieldmotest/exemplary/with_gpid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"placementId": "123"
},
"data": {
"adserver": {
"name": "adserver_name",
"adslot": "adserver_adslot"
},
"pbadslot": "pbadslot_1"
}
}
}
],
"site": {
"id": "fake-site-id"
}
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://ads.yieldmo.com/openrtb2",
"body": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"placement_id": "123",
"gpid": "pbadslot_1"
}
}
],
"site": {
"id": "fake-site-id"
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "yieldmo",
"bid": [
{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.500000,
"adm": "some-test-ad",
"crid": "crid_10",
"h": 250,
"w": 300
}
]
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "EUR",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-ad",
"crid": "crid_10",
"w": 300,
"h": 250
},
"type": "banner"
}
]
}
]
}

0 comments on commit cb1193a

Please sign in to comment.