-
Notifications
You must be signed in to change notification settings - Fork 761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Synacormedia] Add tagId bidder parameter #1165
Changes from all commits
25b2e04
13db7de
139ebd0
76bf60a
3d1769b
6a12cb5
3fb8d16
9095d6a
2240273
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ type SynacorMediaAdapter struct { | |
|
||
type SyncEndpointTemplateParams struct { | ||
SeatId string | ||
TagId string | ||
} | ||
|
||
type ReqExt struct { | ||
|
@@ -55,14 +56,23 @@ func (a *SynacorMediaAdapter) makeRequest(request *openrtb.BidRequest) (*adapter | |
var firstExtImp *openrtb_ext.ExtImpSynacormedia = nil | ||
|
||
for _, imp := range request.Imp { | ||
validImp, err := getExtImpObj(&imp) | ||
validExtImpObj, err := getExtImpObj(&imp) // getExtImpObj returns {seatId:"", tagId:""} | ||
if err != nil { | ||
errs = append(errs, err) | ||
continue | ||
} | ||
// if the bid request is missing seatId or TagId then ignore it | ||
if validExtImpObj.SeatId == "" || validExtImpObj.TagId == "" { | ||
errs = append(errs, &errortypes.BadServerResponse{ | ||
Message: fmt.Sprintf("Invalid Impression"), | ||
}) | ||
continue | ||
} | ||
// right here is where we need to take out the tagId and then add it to imp | ||
imp.TagID = validExtImpObj.TagId | ||
validImps = append(validImps, imp) | ||
if firstExtImp == nil { | ||
firstExtImp = validImp | ||
firstExtImp = validExtImpObj | ||
} | ||
} | ||
|
||
|
@@ -72,11 +82,12 @@ func (a *SynacorMediaAdapter) makeRequest(request *openrtb.BidRequest) (*adapter | |
|
||
var err error | ||
|
||
if firstExtImp == nil || firstExtImp.SeatId == "" { | ||
if firstExtImp == nil || firstExtImp.SeatId == "" || firstExtImp.TagId == "" { | ||
return nil, append(errs, &errortypes.BadServerResponse{ | ||
Message: fmt.Sprintf("Impression missing seat id"), | ||
Message: fmt.Sprintf("Invalid Impression"), | ||
}) | ||
} | ||
// this is where the empty seatId is filled | ||
re = &ReqExt{SeatId: firstExtImp.SeatId} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TagId is a part of the Imp object, so for each Imp in request.Imp we get the TagId out of the Ext object and add it to the root of the Imp object and then add all those Imps to validImps. Those become the new request.Imp that gets sent out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may wish to consider using a different error message here and on line 67 so the unique error message may assist in debugging. |
||
|
||
// create JSON Request Body | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"seatId": "123" | ||
"seatId": "123", | ||
"tagId": "234" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"seatId": "123" | ||
"seatId": "123", | ||
"tagId": "234" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ | |
}, | ||
"ext": { | ||
"bidder": { | ||
"seatId": 1927 | ||
"seatId": 1927, | ||
"tagId": "demo1" | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"imp": [ | ||
{ | ||
"id": "test-imp-id", | ||
"banner": { | ||
"format": [ | ||
{ | ||
"w": 300, | ||
"h": 250 | ||
} | ||
] | ||
}, | ||
"ext": { | ||
"bidder": { | ||
"seatId": "prebid" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
|
||
"expectedMakeRequestsErrors": [ | ||
{ | ||
"value": "Invalid Impression", | ||
"comparison": "literal" | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a possibility that the first element of the
Imp
array coming with a non-nilvalidExtImpObj
has an emptyseatId=""
ortagId=""
values and subsequent elements insideImp
come with non-emptyseatId
and/ortagId
s. Are we sure we want to discard the entire request and return error in line 78 below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code to note any empty tagId or seatID values, then skip over them. There is a unit test for this now.