Skip to content

Commit

Permalink
Update LockerDome adapter - code review changes
Browse files Browse the repository at this point in the history
openrtb_ext/imp_lockerdome.go
* Delete unnecessary file

adapters/lockerdome/lockerdome.go
* Better error message for unmarshaling LockerDome bid response
* Inline bidsCapacity
* Move const unexpectedStatusCodeMessage to top

adapters/lockerdome/lockerdometest/exemplary/simple-banner.json
* Better error message for unmarshaling LockerDome bid response

adapters/lockerdome/lockerdometest/exemplary/simple-banner-multiple.json
* Add test case w/ multiple banner requests

config/config.go
* Inline lockerDomePlatformID
  • Loading branch information
margsliu committed Sep 11, 2019
1 parent 2d25fd1 commit b641e65
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 19 deletions.
14 changes: 7 additions & 7 deletions adapters/lockerdome/lockerdome.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/prebid/prebid-server/errortypes"
)

const unexpectedStatusCodeMessage = "Unexpected status code: %d. Run with request.debug = 1 for more info"

// Implements Bidder interface.
type LockerDomeAdapter struct {
endpoint string
Expand Down Expand Up @@ -41,8 +43,6 @@ func (adapter *LockerDomeAdapter) MakeRequests(openRTBRequest *openrtb.BidReques
return requestsToBidder, errs
}

const unexpectedStatusCodeMessage = "Unexpected status code: %d. Run with request.debug = 1 for more info"

// MakeBids unpacks the server's response into Bids.
func (adapter *LockerDomeAdapter) MakeBids(openRTBRequest *openrtb.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData) (bidderResponse *adapters.BidderResponse, errs []error) {

Expand All @@ -64,20 +64,20 @@ func (adapter *LockerDomeAdapter) MakeBids(openRTBRequest *openrtb.BidRequest, r

var openRTBBidderResponse openrtb.BidResponse
if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil {
return nil, []error{err}
return nil, []error{
fmt.Errorf("Error unmarshaling LockerDome bid response - %s", err.Error()),
}
}

if len(openRTBBidderResponse.SeatBid) == 0 {
return nil, nil
}

bidsCapacity := len(openRTBBidderResponse.SeatBid[0].Bid)
bidderResponse = adapters.NewBidderResponseWithBidsCapacity(bidsCapacity)
bidderResponse = adapters.NewBidderResponseWithBidsCapacity(len(openRTBBidderResponse.SeatBid[0].Bid))

var typedBid adapters.TypedBid
for _, seatBid := range openRTBBidderResponse.SeatBid {
for i := range seatBid.Bid {
typedBid = adapters.TypedBid{Bid: &seatBid.Bid[i], BidType: "banner"}
typedBid := adapters.TypedBid{Bid: &seatBid.Bid[i], BidType: "banner"}
bidderResponse.Bids = append(bidderResponse.Bids, &typedBid)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"adUnitId": "LD9434769725128806"
}
}
},
{
"id": "test-imp-id-2",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"adUnitId": "LD9360401292656742"
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://lockerdome.com/ladbid/prebidserver/openrtb2",
"body": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"adUnitId": "LD9434769725128806"
}
}
},
{
"id": "test-imp-id-2",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"adUnitId": "LD9360401292656742"
}
}
}
]
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "lockerdome",
"bid": [
{
"id": "729c0d99-3b45-4225-9ad5-64aef2b46df3",
"impid": "test-imp-id",
"price": 0.23,
"adm": "<html>test ad markup #1</html>",
"crid": "LD12134555163033624",
"h": 250,
"w": 300
},
{
"id": "9euij6w8-sj89-6397-6er4-5we9t1a67wkj",
"impid": "test-imp-id-2",
"price": 0.5,
"adm": "<html>test ad markup #2</html>",
"crid": "LD12258417590730764",
"h": 250,
"w": 300
}
]
}
]
}
}
}
],

"expectedBidResponses": [
{
"bids": [
{
"bid": {
"id": "729c0d99-3b45-4225-9ad5-64aef2b46df3",
"impid": "test-imp-id",
"price": 0.23,
"adm": "<html>test ad markup #1</html>",
"crid": "LD12134555163033624",
"w": 300,
"h": 250
},
"type": "banner"
},
{
"bid": {
"id": "9euij6w8-sj89-6397-6er4-5we9t1a67wkj",
"impid": "test-imp-id-2",
"price": 0.5,
"adm": "<html>test ad markup #2</html>",
"crid": "LD12258417590730764",
"w": 300,
"h": 250
},
"type": "banner"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{
"id": "729c0d99-3b45-4225-9ad5-64aef2b46df3",
"impid": "test-imp-id",
"price": 0.23,
"price": 0.60,
"adm": "<html>test ad markup</html>",
"crid": "LD12134555163033624",
"h": 250,
Expand All @@ -79,7 +79,7 @@
"bid": {
"id": "729c0d99-3b45-4225-9ad5-64aef2b46df3",
"impid": "test-imp-id",
"price": 0.23,
"price": 0.60,
"adm": "<html>test ad markup</html>",
"crid": "LD12134555163033624",
"w": 300,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
],

"expectedMakeBidsErrors": [
"json: cannot unmarshal string into Go value of type openrtb.BidResponse"
"Error unmarshaling LockerDome bid response - json: cannot unmarshal string into Go value of type openrtb.BidResponse"
]
}
3 changes: 1 addition & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ func (cfg *Configuration) setDerivedDefaults() {
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderImprovedigital, "https://ad.360yield.com/server_match?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dimprovedigital%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BPUB_USER_ID%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderIx, "https://ssum.casalemedia.com/usermatchredir?s=184932&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dix%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderLifestreet, "https://ads.lfstmedia.com/idsync/137062?synced=1&ttl=1s&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dlifestreet%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%24visitor_cookie%24%24")
lockerDomePlatformID := cfg.Adapters["lockerdome"].PlatformID
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderLockerDome, "https://lockerdome.com/usync/prebidserver?pid="+lockerDomePlatformID+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dlockerdome%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7B%7Buid%7D%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderLockerDome, "https://lockerdome.com/usync/prebidserver?pid="+cfg.Adapters["lockerdome"].PlatformID+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dlockerdome%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7B%7Buid%7D%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderOpenx, "https://rtb.openx.net/sync/prebid?r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dopenx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderPubmatic, "https://ads.pubmatic.com/AdServer/js/user_sync.html?predirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")
setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderPulsepoint, "https://bh.contextweb.com/rtset?pid=561205&ev=1&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dpulsepoint%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25%25VGUID%25%25")
Expand Down
7 changes: 0 additions & 7 deletions openrtb_ext/imp_lockerdome.go

This file was deleted.

0 comments on commit b641e65

Please sign in to comment.