Skip to content

Commit

Permalink
Undertone: adding GPID support (#3078)
Browse files Browse the repository at this point in the history
Co-authored-by: Shahaf Sameach <[email protected]>
Co-authored-by: Shahaf Sameach <[email protected]>
  • Loading branch information
3 people authored Sep 7, 2023
1 parent d6bca29 commit ea079a9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
30 changes: 20 additions & 10 deletions adapters/undertone/undertone.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ type undertoneParams struct {
Version string `json:"version"`
}

type impExt struct {
Bidder *openrtb_ext.ExtImpUndertone `json:"bidder,omitempty"`
Gpid string `json:"gpid,omitempty"`
}

func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) {
bidder := &adapter{
endpoint: config.Endpoint,
Expand Down Expand Up @@ -158,24 +163,29 @@ func getImpsAndPublisherId(bidRequest *openrtb2.BidRequest) ([]openrtb2.Imp, int
var validImps []openrtb2.Imp

for _, imp := range bidRequest.Imp {
var extImpBidder adapters.ExtImpBidder
if err := json.Unmarshal(imp.Ext, &extImpBidder); err != nil {
errs = append(errs, getInvalidImpErr(imp.ID, err))
continue
}

var extImpUndertone openrtb_ext.ExtImpUndertone
if err := json.Unmarshal(extImpBidder.Bidder, &extImpUndertone); err != nil {
var ext impExt
if err := json.Unmarshal(imp.Ext, &ext); err != nil {
errs = append(errs, getInvalidImpErr(imp.ID, err))
continue
}

if publisherId == 0 {
publisherId = extImpUndertone.PublisherID
publisherId = ext.Bidder.PublisherID
}

imp.TagID = strconv.Itoa(extImpUndertone.PlacementID)
imp.TagID = strconv.Itoa(ext.Bidder.PlacementID)
imp.Ext = nil

if ext.Gpid != "" {
ext.Bidder = nil
impExtJson, err := json.Marshal(&ext)
if err != nil {
errs = append(errs, getInvalidImpErr(imp.ID, err))
continue
}
imp.Ext = impExtJson
}

validImps = append(validImps, imp)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"bidder": {
"publisherId": 1234,
"placementId": 123456
}
},
"gpid": "gpid-value"
}
}
],
Expand Down Expand Up @@ -116,7 +117,10 @@
4
]
},
"tagid": "123456"
"tagid": "123456",
"ext": {
"gpid": "gpid-value"
}
}
],
"app": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"bidder": {
"publisherId": 1234,
"placementId": 12345
}
},
"gpid": "gpid-value"
}
},
{
Expand Down Expand Up @@ -87,7 +88,10 @@
}
]
},
"tagid": "12345"
"tagid": "12345",
"ext": {
"gpid": "gpid-value"
}
},
{
"id": "test-imp-video-id",
Expand Down

0 comments on commit ea079a9

Please sign in to comment.