Skip to content

Commit

Permalink
Fixing placement parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickloughrey committed Jul 5, 2024
1 parent 2cf98db commit 914cd4c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
29 changes: 24 additions & 5 deletions adapters/triplelift_native/triplelift_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,29 @@ type TripleliftNativeExtInfo struct {
PublisherWhitelistMap map[string]struct{}
}

type ExtImpData struct {
TagCode string `json:"tag_code"`
}

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

func getBidType(ext TripleliftRespExt) openrtb_ext.BidType {
return openrtb_ext.BidTypeNative
}

func processImp(imp *openrtb2.Imp, req *openrtb2.BidRequest) error {
func processImp(imp *openrtb2.Imp, request *openrtb2.BidRequest) error {
// get the triplelift extension
var ext adapters.ExtImpBidder
var tlext openrtb_ext.ExtImpTriplelift
var siteCopy openrtb2.Site
var extData ExtImpData

if request.Site != nil {
siteCopy = *request.Site
}

if err := json.Unmarshal(imp.Ext, &ext); err != nil {
return err
Expand All @@ -54,10 +69,14 @@ func processImp(imp *openrtb2.Imp, req *openrtb2.BidRequest) error {
if tlext.InvCode == "" {
return fmt.Errorf("no inv_code specified")
}
if req.Site != nil {
siteCopy := *req.Site
if siteCopy.Domain == "msn.com" {
imp.TagID = tlext.TagCode

fmt.Println(extData)
fmt.Println(extData.TagCode)
fmt.Println(ext)
if extData.TagCode != "" {
if siteCopy.Publisher.Domain == "msn.com" {
fmt.Println(extData.TagCode)
imp.TagID = extData.TagCode
} else {
imp.TagID = tlext.InvCode
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"mockBidRequest": {
"id": "test-request-id",
"site": { "publisher": {"id":"foo","name":"foo"}, "domain": "msn.com"},
"site": { "publisher": {"id":"foo","name":"foo", "domain": "msn.com"}},
"imp": [
{
"native": {
Expand Down Expand Up @@ -38,16 +38,19 @@
"bidder": {
"inventoryCode": "foo",
"floor" : 20
},
"data": {
"tag_code": "bar"
}
}
}
],
"site": {
"publisher": {
"id": "foo",
"name": "foo"
},
"domain": "msn.com"
"site": {
"publisher": {
"id":"foo",
"name":"foo",
"domain": "msn.com"
}
}
},
"impIDs":["test-imp-id"]
Expand Down
5 changes: 2 additions & 3 deletions openrtb_ext/imp_triplelift.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package openrtb_ext

// ExtImpTriplelift defines the contract for bidrequest.imp[i].ext.prebid.bidder.triplelift
type ExtImpTriplelift struct {
InvCode string `json:"inventoryCode"`
Floor *float64 `json:"floor"`
TagCode string `json:"tag_code"`
InvCode string `json:"inventoryCode"`
Floor *float64 `json:"floor"`
}
4 changes: 0 additions & 4 deletions static/bidder-params/triplelift_native.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"type": "string",
"description": "TripleLift inventory code for this ad unit (provided to you by your partner manager)"
},
"tag_code": {
"type": "string",
"description": "TripleLift placement name for MSN"
},
"floor" : {"description" : "the bid floor, in usd", "type": "number" }
},
"required": ["inventoryCode"]
Expand Down

0 comments on commit 914cd4c

Please sign in to comment.