Skip to content

Commit

Permalink
Adnuntius: Read device information from ortb Request (prebid#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikael-lundin authored and jorgeluisrocha committed Sep 22, 2022
1 parent 7de7c43 commit 1c99a28
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 2 deletions.
13 changes: 11 additions & 2 deletions adapters/adnuntius/adnuntius.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,19 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E
return a.generateRequests(*request)
}

func setHeaders() http.Header {
func setHeaders(ortbRequest openrtb2.BidRequest) http.Header {

headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
if ortbRequest.Device != nil {
if ortbRequest.Device.IP != "" {
headers.Add("X-Forwarded-For", ortbRequest.Device.IP)
}
if ortbRequest.Device.UA != "" {
headers.Add("user-agent", ortbRequest.Device.UA)
}
}
return headers
}

Expand Down Expand Up @@ -113,7 +122,7 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter) (string, []err
func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, []error) {
var requestData []*adapters.RequestData
networkAdunitMap := make(map[string][]adnAdunit)
headers := setHeaders()
headers := setHeaders(ortbRequest)

endpoint, err := makeEndpointUrl(ortbRequest, a)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"mockBidRequest": {
"id": "test-request-id",
"user": {
"id": "1kjh3429kjh295jkl",
"ext": {
"consent": "CONSENT_STRING"
}
},
"device": {
"ip": "158.174.81.143",
"ua": "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Mobile Safari/537.36"
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"auId": "123"
}
}
}
]
},

"httpCalls": [
{
"expectedRequest": {
"headers": {
"Content-Type": [
"application/json;charset=utf-8"
],
"Accept": [
"application/json"
],
"X-Forwarded-For": [
"158.174.81.143"
],
"User-Agent": [
"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Mobile Safari/537.36"
]
},
"uri": "http://whatever.url?format=json&tzo=0",
"body": {
"adUnits": [
{
"auId": "123",
"targetId": "123-test-imp-id"
}
],
"metaData": {
"usi": "1kjh3429kjh295jkl"
},
"context": "unknown"
}
},
"mockResponse": {
"status": 200,
"body": {
"adUnits": [
{
"auId": "0000000000000123",
"targetId": "123-test-imp-id",
"html": "<ADCODE>",
"responseId": "adn-rsp-900646517",
"ads": [
{
"destinationUrls": {
"url": "http://www.google.com"
},
"bid": {
"amount": 20.0,
"currency": "NOK"
},
"adId": "adn-id-1559784094",
"creativeWidth": "980",
"creativeHeight": "240",
"creativeId": "jn9hpzvlsf8cpdmm",
"lineItemId": "q7y9qm5b0xt9htrv"
}
]
}
]
}
}
}
],
"expectedBidResponses": [
{
"bids": [
{
"bid": {
"id": "adn-id-1559784094",
"impid": "test-imp-id",
"price": 20000,
"adm": "<ADCODE>",
"adid": "adn-id-1559784094",
"adomain": ["google.com"],
"cid": "q7y9qm5b0xt9htrv",
"crid": "jn9hpzvlsf8cpdmm",
"w": 980,
"h": 240
},
"type": "banner"
}
],
"currency": "NOK"
}
]
}

0 comments on commit 1c99a28

Please sign in to comment.