Skip to content

Commit

Permalink
[Criteo] Set bidMeta with networkName (#2763)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pgb-Criteo committed May 23, 2023
1 parent df76979 commit ef17c58
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
24 changes: 22 additions & 2 deletions adapters/criteo/criteo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ type adapter struct {
endpoint string
}

type BidExt struct {
Prebid ExtPrebid `json:"prebid"`
}

type ExtPrebid struct {
BidType openrtb_ext.BidType `json:"type"`
NetworkName string `json:"networkName"`
}

func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) {
bidder := &adapter{
endpoint: config.Endpoint,
Expand Down Expand Up @@ -67,7 +76,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R

for _, seatBid := range response.SeatBid {
for i := range seatBid.Bid {
var bidExt openrtb_ext.ExtBid
var bidExt BidExt
if err := json.Unmarshal(seatBid.Bid[i].Ext, &bidExt); err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: fmt.Sprintf("Missing ext.prebid.type in bid for impression : %s.", seatBid.Bid[i].ImpID),
Expand All @@ -76,11 +85,22 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R

b := &adapters.TypedBid{
Bid: &seatBid.Bid[i],
BidType: bidExt.Prebid.Type,
BidType: bidExt.Prebid.BidType,
BidMeta: getBidMeta(bidExt),
}
bidResponse.Bids = append(bidResponse.Bids, b)
}
}

return bidResponse, nil
}

func getBidMeta(ext BidExt) *openrtb_ext.ExtBidPrebidMeta {
var bidMeta *openrtb_ext.ExtBidPrebidMeta
if ext.Prebid.NetworkName != "" {
bidMeta = &openrtb_ext.ExtBidPrebidMeta{
NetworkName: ext.Prebid.NetworkName,
}
}
return bidMeta
}
6 changes: 4 additions & 2 deletions adapters/criteo/criteotest/exemplary/simple-banner-inapp.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"h": 250,
"ext": {
"prebid": {
"type": "banner"
"type": "banner",
"networkName": "Criteo"
}
}
}
Expand All @@ -110,7 +111,8 @@
"h": 250,
"ext": {
"prebid": {
"type": "banner"
"type": "banner",
"networkName": "Criteo"
}
}
},
Expand Down

0 comments on commit ef17c58

Please sign in to comment.