Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
[Synacormedia] Add tagId bidder parameter (prebid#1165)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreykress authored Jan 31, 2020
1 parent c1ec382 commit 948f4d6
Show file tree
Hide file tree
Showing 18 changed files with 253 additions and 45 deletions.
4 changes: 2 additions & 2 deletions adapters/synacormedia/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func TestInvalidParams(t *testing.T) {
}

var validParams = []string{
`{"seatId": "123"}`,
`{"seatId": "123", "tagId":"234"}`,
}

var invalidParams = []string{
`{"seatId": 123}`,
`{"seatId": 123, "tagId":234}`,
}
19 changes: 15 additions & 4 deletions adapters/synacormedia/synacormedia.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type SynacorMediaAdapter struct {

type SyncEndpointTemplateParams struct {
SeatId string
TagId string
}

type ReqExt struct {
Expand Down Expand Up @@ -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
}
}

Expand All @@ -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}

// create JSON Request Body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand All @@ -24,23 +25,25 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://1927.technoratimedia.com/openrtb/bids/1927",
"uri": "http://prebid.technoratimedia.com/openrtb/bids/prebid",
"body": {
"id": "test-request-id",
"ext": {
"seatId": "1927"
"seatId": "prebid"
},
"imp": [
{
"id":"test-imp-id",
"tagid": "demo1",
"banner": {
"format": [
{"w":300,"h":250}
]
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"imp": [
{
"id": "i3",
"tagid": "3020",
"video": {
"w": 300,
"h": 250,
Expand All @@ -21,8 +20,9 @@
},
"metric": [],
"ext": {
"bidder":{
"seatId":"1927"
"bidder": {
"seatId":"prebid",
"tagId": "demo1"
}
}
}
Expand All @@ -31,7 +31,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://1927.technoratimedia.com/openrtb/bids/1927",
"uri": "http://prebid.technoratimedia.com/openrtb/bids/prebid",
"body": {
"id": "1",
"site": {
Expand All @@ -40,12 +40,12 @@
"publisher": {}
},
"ext": {
"seatId": "1927"
"seatId": "prebid"
},
"imp": [
{
"id": "i3",
"tagid": "3020",
"tagid": "demo1",
"video": {
"w": 300,
"h": 250,
Expand All @@ -56,7 +56,8 @@
},
"ext": {
"bidder":{
"seatId":"1927"
"seatId":"prebid",
"tagId": "demo1"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion adapters/synacormedia/synacormediatest/params/banner.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"seatId": "123"
"seatId": "123",
"tagId": "234"
}
3 changes: 2 additions & 1 deletion adapters/synacormedia/synacormediatest/params/video.json
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
Expand Up @@ -9,7 +9,8 @@
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand All @@ -19,21 +20,23 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://1927.technoratimedia.com/openrtb/bids/1927",
"uri": "http://prebid.technoratimedia.com/openrtb/bids/prebid",
"body": {
"id": "test-request-id",
"ext": {
"seatId": "1927"
"seatId": "prebid"
},
"imp": [
{
"id":"test-imp-id",
"tagid": "demo1",
"audio": {
"mimes": ["video/mp4"]
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand All @@ -28,15 +29,16 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://1927.technoratimedia.com/openrtb/bids/1927",
"uri": "http://prebid.technoratimedia.com/openrtb/bids/prebid",
"body": {
"id": "test-request-id",
"ext": {
"seatId": "1927"
"seatId": "prebid"
},
"imp": [
{
"id":"test-imp-id",
"tagid": "demo1",
"banner": {
"format": [
{"w":300,"h":250},
Expand All @@ -45,7 +47,8 @@
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"ext": {
"bidder": {
"seatId": 1927
"seatId": 1927,
"tagId": "demo1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"ext": {
"bidder": {
"tagId": "demo1"
}
}
}
Expand All @@ -22,7 +23,7 @@

"expectedMakeRequestsErrors": [
{
"value": "Impression missing seat id",
"value": "Invalid Impression",
"comparison": "literal"
}
]
Expand Down
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"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand All @@ -19,21 +20,23 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://1927.technoratimedia.com/openrtb/bids/1927",
"uri": "http://prebid.technoratimedia.com/openrtb/bids/prebid",
"body": {
"id": "test-request-id",
"ext": {
"seatId": "1927"
"seatId": "prebid"
},
"imp": [
{
"id":"test-imp-id",
"tagid": "demo1",
"native": {
"request": ""
},
"ext": {
"bidder": {
"seatId": "1927"
"seatId": "prebid",
"tagId": "demo1"
}
}
}
Expand Down
Loading

0 comments on commit 948f4d6

Please sign in to comment.