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

Commit

Permalink
[mgid adapter] make placementId optional (prebid#972)
Browse files Browse the repository at this point in the history
* new mgid adapter

* increase coverage

* remove extra imports

* [mgid] optional placementId
  • Loading branch information
Gaudeamus authored and guscarreon committed Aug 1, 2019
1 parent cb9cf0c commit 9f2fbdb
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 11 deletions.
6 changes: 5 additions & 1 deletion adapters/mgid/mgid.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ func preprocess(request *openrtb.BidRequest) (path string, err error) {
if path == "" {
path = mgidExt.AccountId
}
request.Imp[i].TagID = mgidExt.PlacementId
if mgidExt.PlacementId == "" {
request.Imp[i].TagID = imp.ID
} else {
request.Imp[i].TagID = mgidExt.PlacementId + "/" + imp.ID
}

cur := ""
if mgidExt.Currency != "" && mgidExt.Currency != "USD" {
Expand Down
133 changes: 133 additions & 0 deletions adapters/mgid/mgidtest/exemplary/noplacementid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"accountId": "123"
}
}
}
],
"device": {
"ua": "test-user-agent",
"ip": "123.123.123.123",
"language": "en",
"dnt": 0
},
"site": {
"domain": "www.publisher.com",
"page": "http://www.publisher.com/awesome/site"
},
"user": {
"buyeruid": "test_reader_id"
}
},

"httpCalls": [
{
"expectedRequest": {
"headers": {
"Accept": ["application/json"],
"Content-Type": ["application/json;charset=utf-8"]
},
"uri": "https://prebid.mgid.com/prebid/123",
"body": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"tagid": "test-imp-id",
"ext": {
"bidder": {
"accountId": "123"
}
}
}
],
"site": {
"domain": "www.publisher.com",
"page": "http://www.publisher.com/awesome/site"
},
"tmax": 200,
"user": {
"buyeruid": "test_reader_id"
},
"device": {
"ua": "test-user-agent",
"ip": "123.123.123.123",
"dnt": 0,
"language": "en"
}
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"seatbid": [
{
"bid": [
{
"id": "test-bid-id",
"impid": "test-imp-id",
"price": 3.5,
"nurl": "nurl",
"adm": "some-test-ad",
"w": 300,
"h": 250
}
]
}
]
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "test-bid-id",
"impid": "test-imp-id",
"price": 3.5,
"adm": "some-test-ad",
"nurl": "nurl",
"w": 300,
"h": 250
},
"type": "banner"
}
]
}
]
}
2 changes: 1 addition & 1 deletion adapters/mgid/mgidtest/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
]
},
"tagid": "456",
"tagid": "456/test-imp-id",
"ext": {
"bidder": {
"accountId": "123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
}
]
},
"tagid": "456",
"tagid": "456/test-imp-id",
"ext": {
"bidder": {
"accountId": "123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}
]
},
"tagid": "456",
"tagid": "456/test-imp-id",
"ext": {
"bidder": {
"accountId": "123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
]
},
"tagid": "456",
"tagid": "456/test-imp-id",
"ext": {
"bidder": {
"accountId": "123",
Expand Down
2 changes: 1 addition & 1 deletion adapters/mgid/mgidtest/supplemental/status_204.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"imp": [
{
"id": "test-imp-id",
"tagid": "321",
"tagid": "321/test-imp-id",
"banner": {
"format": [
{
Expand Down
2 changes: 1 addition & 1 deletion adapters/mgid/mgidtest/supplemental/status_not200.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"imp": [
{
"id": "test-imp-id",
"tagid": "321",
"tagid": "321/test-imp-id",
"banner": {
"format": [
{
Expand Down
2 changes: 1 addition & 1 deletion adapters/mgid/mgidtest/supplemental/video.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"imp": [
{
"id": "test-imp-id",
"tagid": "456",
"tagid": "456/test-imp-id",
"video": {
"mimes": ["video/mp4"],
"protocols": [2, 5],
Expand Down
2 changes: 1 addition & 1 deletion openrtb_ext/imp_mgid.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb_ext
// ExtImpMgid defines the contract for bidrequest.imp[i].ext.mgid
type ExtImpMgid struct {
AccountId string `json:"accountId"`
PlacementId string `json:"placementId"`
PlacementId string `json:"placementId,omitempty"`
Cur string `json:"cur"`
Currency string `json:"currency"`
BidFloor float64 `json:"bidfloor"`
Expand Down
4 changes: 2 additions & 2 deletions static/bidder-params/mgid.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"placementId": {
"type": "string",
"description": "Internal Mgid Placement ID"
"description": "optional internal Mgid Placement ID"
},
"cur": {
"type": "string",
Expand All @@ -30,5 +30,5 @@
"description": "optional minimum acceptable bid, in CPM, USD by default"
}
},
"required": ["accountId","placementId"]
"required": ["accountId"]
}

0 comments on commit 9f2fbdb

Please sign in to comment.