Skip to content

Commit

Permalink
Addressed code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchimishuk committed Oct 14, 2020
1 parent 671f5a8 commit ea7c95a
Show file tree
Hide file tree
Showing 12 changed files with 756 additions and 267 deletions.
14 changes: 11 additions & 3 deletions adapters/adoppler/adoppler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/url"
"text/template"

"github.com/golang/glog"
"github.com/mxmCherry/openrtb"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/errortypes"
Expand Down Expand Up @@ -37,8 +38,13 @@ type AdopplerAdapter struct {

func NewAdopplerBidder(endpoint string) *AdopplerAdapter {
e := endpoint + "/processHeaderBid/{{.AdUnit}}"
t, err := template.New("endpoint").Parse(e)
if err != nil {
glog.Fatalf("Unable to parse endpoint url template: %s", err)
return nil
}

return &AdopplerAdapter{template.Must(template.New("endpoint").Parse(e))}
return &AdopplerAdapter{t}
}

func (ads *AdopplerAdapter) MakeRequests(
Expand Down Expand Up @@ -73,7 +79,9 @@ func (ads *AdopplerAdapter) MakeRequests(

uri, err := ads.bidUri(ext)
if err != nil {
errs = append(errs, &errortypes.BadInput{err.Error()})
e := fmt.Sprintf("Unable to build bid URI: %s",
err.Error())
errs = append(errs, &errortypes.BadInput{e})
continue
}
data := &adapters.RequestData{
Expand Down Expand Up @@ -187,7 +195,7 @@ func (ads *AdopplerAdapter) bidUri(ext *openrtb_ext.ExtImpAdoppler) (string, err
if ext.Client == "" {
params.AccountID = DefaultClient
} else {
params.AccountID = ext.Client
params.AccountID = url.PathEscape(ext.Client)
}

return macros.ResolveMacros(*ads.endpoint, params)
Expand Down
67 changes: 52 additions & 15 deletions adapters/adoppler/adopplertest/exemplary/custom-client.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,52 @@
{"mockBidRequest": {"id": "req1",
"imp":[{"id": "imp1",
"banner": {"w": 100,
"h": 200},
"ext": {"bidder": {"adunit": "unit1",
"client": "client1"}}}]},
"httpCalls": [{"expectedRequest": {"uri": "http://client1.trustedmarketplace.com/processHeaderBid/unit1",
"body": {"id": "req1-unit1",
"imp": [{"id": "imp1",
"banner": {"w": 100, "h": 200},
"ext": {"bidder": {"adunit": "unit1",
"client": "client1"}}}]}},
"mockResponse": {"status": 204,
"body": ""}}],
"expectedBidResponses": []}
{
"mockBidRequest":{
"id":"req1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1",
"client":"client1"
}
}
}
]
},
"httpCalls":[
{
"expectedRequest":{
"uri":"http://client1.trustedmarketplace.com/processHeaderBid/unit1",
"body":{
"id":"req1-unit1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1",
"client":"client1"
}
}
}
]
}
},
"mockResponse":{
"status":204,
"body":""
}
}
],
"expectedBidResponses":[

]
}
63 changes: 50 additions & 13 deletions adapters/adoppler/adopplertest/exemplary/default-client.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
{"mockBidRequest": {"id": "req1",
"imp":[{"id": "imp1",
"banner": {"w": 100,
"h": 200},
"ext": {"bidder": {"adunit": "unit1"}}}]},
"httpCalls": [{"expectedRequest": {"uri": "http://app.trustedmarketplace.com/processHeaderBid/unit1",
"body": {"id": "req1-unit1",
"imp": [{"id": "imp1",
"banner": {"w": 100, "h": 200},
"ext": {"bidder": {"adunit": "unit1"}}}]}},
"mockResponse": {"status": 204,
"body": ""}}],
"expectedBidResponses": []}
{
"mockBidRequest":{
"id":"req1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1"
}
}
}
]
},
"httpCalls":[
{
"expectedRequest":{
"uri":"http://app.trustedmarketplace.com/processHeaderBid/unit1",
"body":{
"id":"req1-unit1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1"
}
}
}
]
}
},
"mockResponse":{
"status":204,
"body":""
}
}
],
"expectedBidResponses":[

]
}
118 changes: 50 additions & 68 deletions adapters/adoppler/adopplertest/exemplary/multibid.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,50 @@
{"mockBidRequest": {"id": "req1",
"imp":[{"id": "imp1",
"banner": {"w": 100,
"h": 200},
"ext": {"bidder": {"adunit": "unit1"}}},
{"id": "imp2",
"video": {"minduration": 120,
"mimes": ["video/mp4"]},
"ext": {"bidder": {"adunit": "unit2"}}},
{"id": "imp3",
"native": {"request": "{}"},
"ext": {"bidder": {"adunit": "unit3"}}}],
"source": {"ext": {"schain": {"ver": "1.0"}}},
"regs": {"ext": {"us_privacy": "1YNY"}}},
"httpCalls": [{"expectedRequest": {"uri": "http://app.trustedmarketplace.com/processHeaderBid/unit1",
"body": {"id": "req1-unit1",
"imp": [{"id": "imp1",
"banner": {"w": 100, "h": 200},
"ext": {"bidder": {"adunit": "unit1"}}}],
"source": {"ext": {"schain": {"ver": "1.0"}}},
"regs": {"ext": {"us_privacy": "1YNY"}}}},
"mockResponse": {"status": 200,
"body": {"id": "req1-imp1-resp1",
"seatbid": [{"bid": [{"id": "req1-imp1-bid1",
"impid": "imp1",
"price": 0.12,
"adm": "<b>a banner</b>"}]}],
"cur": "USD"}}},
{"expectedRequest": {"uri": "http://app.trustedmarketplace.com/processHeaderBid/unit2",
"body": {"id": "req1-unit2",
"imp": [{"id": "imp2",
"video": {"minduration": 120,
"mimes": ["video/mp4"]},
"ext": {"bidder": {"adunit": "unit2"}}}],
"source": {"ext": {"schain": {"ver": "1.0"}}},
"regs": {"ext": {"us_privacy": "1YNY"}}}},
"mockResponse": {"status": 200,
"body": {"id": "req1-imp2-resp2",
"seatbid": [{"bid": [{"id": "req1-imp2-bid1",
"impid": "imp2",
"price": 0.24,
"adm": "<VAST />",
"cat": ["IAB1", "IAB2"],
"ext": {"ads": {"video": {"duration": 121}}}}]}],
"cur": "USD"}}},
{"expectedRequest": {"uri": "http://app.trustedmarketplace.com/processHeaderBid/unit3",
"body": {"id": "req1-unit3",
"imp": [{"id": "imp3",
"native": {"request": "{}"},
"ext": {"bidder": {"adunit": "unit3"}}}],
"source": {"ext": {"schain": {"ver": "1.0"}}},
"regs": {"ext": {"us_privacy": "1YNY"}}}},
"mockResponse": {"status": 204,
"body": ""}}],
"expectedBidResponses": [{"currency": "USD",
"bids": [{"bid": {"id": "req1-imp1-bid1",
"impid": "imp1",
"price": 0.12,
"adm": "<b>a banner</b>"},
"type": "banner"}]},
{"currency": "USD",
"bids": [{"bid": {"id": "req1-imp2-bid1",
"impid": "imp2",
"price": 0.24,
"adm": "<VAST />",
"cat": ["IAB1", "IAB2"],
"ext": {"ads": {"video": {"duration": 121}}}},
"type": "video"}]}]}
{
"mockBidRequest":{
"id":"req1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1"
}
}
}
]
},
"httpCalls":[
{
"expectedRequest":{
"uri":"http://app.trustedmarketplace.com/processHeaderBid/unit1",
"body":{
"id":"req1-unit1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1"
}
}
}
]
}
},
"mockResponse":{
"status":204,
"body":""
}
}
],
"expectedBidResponses":[

]
}
63 changes: 50 additions & 13 deletions adapters/adoppler/adopplertest/exemplary/no-bid.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
{"mockBidRequest": {"id": "req1",
"imp":[{"id": "imp1",
"banner": {"w": 100,
"h": 200},
"ext": {"bidder": {"adunit": "unit1"}}}]},
"httpCalls": [{"expectedRequest": {"uri": "http://app.trustedmarketplace.com/processHeaderBid/unit1",
"body": {"id": "req1-unit1",
"imp": [{"id": "imp1",
"banner": {"w": 100, "h": 200},
"ext": {"bidder": {"adunit": "unit1"}}}]}},
"mockResponse": {"status": 204,
"body": ""}}],
"expectedBidResponses": []}
{
"mockBidRequest":{
"id":"req1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1"
}
}
}
]
},
"httpCalls":[
{
"expectedRequest":{
"uri":"http://app.trustedmarketplace.com/processHeaderBid/unit1",
"body":{
"id":"req1-unit1",
"imp":[
{
"id":"imp1",
"banner":{
"w":100,
"h":200
},
"ext":{
"bidder":{
"adunit":"unit1"
}
}
}
]
}
},
"mockResponse":{
"status":204,
"body":""
}
}
],
"expectedBidResponses":[

]
}
Loading

0 comments on commit ea7c95a

Please sign in to comment.