Skip to content

Commit

Permalink
adquery: added device ip and ua to bidder request (#1) (#3288)
Browse files Browse the repository at this point in the history
  • Loading branch information
wgalecki authored Nov 20, 2023
1 parent 01f3320 commit 94d8682
Show file tree
Hide file tree
Showing 21 changed files with 570 additions and 206 deletions.
33 changes: 28 additions & 5 deletions adapters/adquery/adquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (
}

func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
headers.Add("x-openrtb-version", "2.5")
headers := buildHeaders(request)

var result []*adapters.RequestData
var errs []error
Expand Down Expand Up @@ -112,13 +109,27 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData
return bidResponse, nil
}

func buildHeaders(bidReq *openrtb2.BidRequest) http.Header {
headers := http.Header{}

headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
headers.Add("X-Openrtb-Version", "2.5")

if bidReq.Device != nil && len(bidReq.Device.IP) > 0 {
headers.Add("X-Forwarded-For", bidReq.Device.IP)
}

return headers
}

func buildRequest(bidReq *openrtb2.BidRequest, imp *openrtb2.Imp, ext *openrtb_ext.ImpExtAdQuery) *BidderRequest {
userId := ""
if bidReq.User != nil {
userId = bidReq.User.ID
}

return &BidderRequest{
bidderRequest := &BidderRequest{
V: prebidVersion,
PlacementCode: ext.PlacementID,
AuctionId: "",
Expand All @@ -132,6 +143,18 @@ func buildRequest(bidReq *openrtb2.BidRequest, imp *openrtb2.Imp, ext *openrtb_e
BidderRequestsCount: 1,
Sizes: getImpSizes(imp),
}

if bidReq.Device != nil {
bidderRequest.BidIp = bidReq.Device.IP
bidderRequest.BidIpv6 = bidReq.Device.IPv6
bidderRequest.BidUa = bidReq.Device.UA
}

if bidReq.Site != nil {
bidderRequest.BidPageUrl = bidReq.Site.Page
}

return bidderRequest
}

func parseExt(ext json.RawMessage) (*openrtb_ext.ImpExtAdQuery, error) {
Expand Down
2 changes: 1 addition & 1 deletion adapters/adquery/adquery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderAdquery, config.Adapter{
Endpoint: "https://bidder.adquery.io/prebid/bid"},
Endpoint: "https://bidder2.adquery.io/prebid/bid"},
config.Server{ExternalUrl: "http://hosturl.com", GvlID: 902, DataCenter: "2"})

if buildErr != nil {
Expand Down
9 changes: 8 additions & 1 deletion adapters/adquery/adquerytest/exemplary/empty.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
"user": {
"id": "xyz"
},
"site": {
"page": "https://www.example.com"
},
"device": {
"ip": "104.28.131.104",
"ua": "PostmanRuntime/7.26.8"
},
"imp": [],
"bidder": "adquery"
},
"httpCalls": [],
"expectedBidResponses": []
}
}
55 changes: 34 additions & 21 deletions adapters/adquery/adquerytest/exemplary/many-imps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
"user": {
"id": "d93f2a0e5f0fe2cc3a6e"
},
"site": {
"page": "https://www.example.com"
},
"device": {
"ip": "104.28.131.104",
"ua": "PostmanRuntime/7.26.8"
},
"imp": [
{
"id": "1",
Expand All @@ -27,7 +34,8 @@
"type": "banner"
}
}
},{
},
{
"id": "2",
"tagid": "test-banner-imp-id-2",
"bidder": "adquery",
Expand All @@ -52,21 +60,25 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "https://bidder.adquery.io/prebid/bid",
"uri": "https://bidder2.adquery.io/prebid/bid",
"headers": {
"Accept": ["application/json"],
"Content-Type": ["application/json;charset=utf-8"],
"X-Openrtb-Version": ["2.5"]
"X-Openrtb-Version": ["2.5"],
"X-Forwarded-For": ["104.28.131.104"]
},
"body": {
"adUnitCode": "test-banner-imp-id",
"bidId": "22e26bd9a702bc1",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidPageUrl": "",
"bidder": "adquery",
"bidderRequestId": "22e26bd9a702bc",
"bidRequestsCount": 1,
"bidderRequestsCount": 1,
"bidId": "22e26bd9a702bc1",
"bidIp": "104.28.131.104",
"bidIpv6": "",
"bidPageUrl": "https://www.example.com",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidRequestsCount": 1,
"bidUa": "PostmanRuntime/7.26.8",
"placementCode": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f897",
"sizes": "320x100,300x250",
"type": "banner",
Expand Down Expand Up @@ -98,9 +110,7 @@
"urlAdq": "https://adquery.io",
"creationId": 7211,
"currency": "EUR",
"adDomains": [
"https://s1.adquery.io"
],
"adDomains": ["https://s1.adquery.io"],
"tag": "<ad-adquery-prebid data-qid=\"fc08aacb07eac44421ed\" data-type=\"banner320x50\" data-width=\"320\" date-height=\"50\" data-placement=\"d30f79cf7fef47bd7a5611719f936539bec0d2e9\" data-eventTracker=\"https://bidder.adquery.io/prebid/ev/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-externalEmissionCodes=\"\" data-impressionTracker=\"https://bidder.adquery.io/prebid/im/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-viewabilityTracker=\"https://bidder.adquery.io/prebid/vi/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-clickTracker=\"https://bidder.adquery.io/prebid/cl/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?url=https%3A%2F%2Fbrodacid.pl%2F%3Futm_source%3Dmobile_open%26utm_medium%3Dcpc%26utm_campaign%3Dhi2023\" data-link=\"https://brodacid.pl/?utm_source=mobile_open&utm_medium=cpc&utm_campaign=hi2023\" data-src=\"banner/2023-06-05/17591\" data-ext=\"zip\" data-media-type=\"3\" data-isExpand=\"\" data-domain=\"https://bidder.adquery.io\" data-isVideoFloating=\"\" data-content=\"\" data-creationType=\"16\"> </ad-adquery>",
"adqLib": "https://api.adquery.io/js/adquery-0.1.js?time=10",
"mediaType": {
Expand All @@ -117,23 +127,28 @@
}
}
}
},{
},
{
"expectedRequest": {
"uri": "https://bidder.adquery.io/prebid/bid",
"uri": "https://bidder2.adquery.io/prebid/bid",
"headers": {
"Accept": ["application/json"],
"Content-Type": ["application/json;charset=utf-8"],
"X-Openrtb-Version": ["2.5"]
"X-Openrtb-Version": ["2.5"],
"X-Forwarded-For": ["104.28.131.104"]
},
"body": {
"adUnitCode": "test-banner-imp-id-2",
"bidId": "22e26bd9a702bc2",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidPageUrl": "",
"bidder": "adquery",
"bidderRequestId": "22e26bd9a702bc",
"bidRequestsCount": 1,
"bidderRequestsCount": 1,
"bidId": "22e26bd9a702bc2",
"bidIp": "104.28.131.104",
"bidIpv6": "",
"bidPageUrl": "https://www.example.com",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidRequestsCount": 1,
"bidUa": "PostmanRuntime/7.26.8",
"placementCode": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f898",
"sizes": "300x250",
"type": "banner",
Expand Down Expand Up @@ -165,9 +180,7 @@
"urlAdq": "https://adquery.io",
"creationId": 7211,
"currency": "EUR",
"adDomains": [
"https://s1.adquery.io"
],
"adDomains": ["https://s1.adquery.io"],
"tag": "<ad-adquery-prebid data-qid=\"fc08aacb07eac44421ed\" data-type=\"banner320x50\" data-width=\"320\" date-height=\"50\" data-placement=\"d30f79cf7fef47bd7a5611719f936539bec0d2e9\" data-eventTracker=\"https://bidder.adquery.io/prebid/ev/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-externalEmissionCodes=\"\" data-impressionTracker=\"https://bidder.adquery.io/prebid/im/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-viewabilityTracker=\"https://bidder.adquery.io/prebid/vi/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-clickTracker=\"https://bidder.adquery.io/prebid/cl/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?url=https%3A%2F%2Fbrodacid.pl%2F%3Futm_source%3Dmobile_open%26utm_medium%3Dcpc%26utm_campaign%3Dhi2023\" data-link=\"https://brodacid.pl/?utm_source=mobile_open&utm_medium=cpc&utm_campaign=hi2023\" data-src=\"banner/2023-06-05/17591\" data-ext=\"zip\" data-media-type=\"3\" data-isExpand=\"\" data-domain=\"https://bidder.adquery.io\" data-isVideoFloating=\"\" data-content=\"\" data-creationType=\"16\"> </ad-adquery>",
"adqLib": "https://api.adquery.io/js/adquery-0.1.js?time=10",
"mediaType": {
Expand Down Expand Up @@ -224,4 +237,4 @@
]
}
]
}
}
37 changes: 23 additions & 14 deletions adapters/adquery/adquerytest/exemplary/no-currency.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
"user": {
"id": "d93f2a0e5f0fe2cc3a6e"
},
"site": {
"page": "https://www.example.com"
},
"device": {
"ip": "104.28.131.104",
"ua": "PostmanRuntime/7.26.8"
},
"imp": [
{
"id": "1",
Expand All @@ -22,10 +29,10 @@
]
},
"ext": {
"bidder": {
"placementId": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f897",
"type": "banner"
}
"bidder": {
"placementId": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f897",
"type": "banner"
}
}
}
],
Expand All @@ -34,21 +41,25 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "https://bidder.adquery.io/prebid/bid",
"uri": "https://bidder2.adquery.io/prebid/bid",
"headers": {
"Accept": ["application/json"],
"Content-Type": ["application/json;charset=utf-8"],
"X-Openrtb-Version": ["2.5"]
"X-Openrtb-Version": ["2.5"],
"X-Forwarded-For": ["104.28.131.104"]
},
"body": {
"adUnitCode": "test-banner-imp-id",
"bidId": "22e26bd9a702bc1",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidPageUrl": "",
"bidder": "adquery",
"bidderRequestId": "22e26bd9a702bc",
"bidRequestsCount": 1,
"bidderRequestsCount": 1,
"bidId": "22e26bd9a702bc1",
"bidIp": "104.28.131.104",
"bidIpv6": "",
"bidPageUrl": "https://www.example.com",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidRequestsCount": 1,
"bidUa": "PostmanRuntime/7.26.8",
"placementCode": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f897",
"sizes": "320x100,300x250",
"type": "banner",
Expand Down Expand Up @@ -79,9 +90,7 @@
"domain": "https://bidder.adquery.io",
"urlAdq": "https://adquery.io",
"creationId": 7211,
"adDomains": [
"https://s1.adquery.io"
],
"adDomains": ["https://s1.adquery.io"],
"tag": "<ad-adquery-prebid data-qid=\"fc08aacb07eac44421ed\" data-type=\"banner320x50\" data-width=\"320\" date-height=\"50\" data-placement=\"d30f79cf7fef47bd7a5611719f936539bec0d2e9\" data-eventTracker=\"https://bidder.adquery.io/prebid/ev/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-externalEmissionCodes=\"\" data-impressionTracker=\"https://bidder.adquery.io/prebid/im/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-viewabilityTracker=\"https://bidder.adquery.io/prebid/vi/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-clickTracker=\"https://bidder.adquery.io/prebid/cl/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?url=https%3A%2F%2Fbrodacid.pl%2F%3Futm_source%3Dmobile_open%26utm_medium%3Dcpc%26utm_campaign%3Dhi2023\" data-link=\"https://brodacid.pl/?utm_source=mobile_open&utm_medium=cpc&utm_campaign=hi2023\" data-src=\"banner/2023-06-05/17591\" data-ext=\"zip\" data-media-type=\"3\" data-isExpand=\"\" data-domain=\"https://bidder.adquery.io\" data-isVideoFloating=\"\" data-content=\"\" data-creationType=\"16\"> </ad-adquery>",
"adqLib": "https://api.adquery.io/js/adquery-0.1.js?time=10",
"mediaType": {
Expand Down Expand Up @@ -120,4 +129,4 @@
]
}
]
}
}
38 changes: 24 additions & 14 deletions adapters/adquery/adquerytest/exemplary/ok.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"user": {
"id": "d93f2a0e5f0fe2cc3a6e"
},
"site": {
"page": "https://www.example.com"
},
"device": {
"ip": "104.28.131.104",
"ipv6": "2001:4860:4860::8888",
"ua": "PostmanRuntime/7.26.8"
},
"imp": [
{
"id": "1",
Expand All @@ -22,10 +30,10 @@
]
},
"ext": {
"bidder": {
"placementId": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f897",
"type": "banner"
}
"bidder": {
"placementId": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f897",
"type": "banner"
}
}
}
],
Expand All @@ -34,21 +42,25 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "https://bidder.adquery.io/prebid/bid",
"uri": "https://bidder2.adquery.io/prebid/bid",
"headers": {
"Accept": ["application/json"],
"Content-Type": ["application/json;charset=utf-8"],
"X-Openrtb-Version": ["2.5"]
"X-Openrtb-Version": ["2.5"],
"X-Forwarded-For": ["104.28.131.104"]
},
"body": {
"adUnitCode": "test-banner-imp-id",
"bidId": "22e26bd9a702bc1",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidPageUrl": "",
"bidder": "adquery",
"bidderRequestId": "22e26bd9a702bc",
"bidRequestsCount": 1,
"bidderRequestsCount": 1,
"bidId": "22e26bd9a702bc1",
"bidIp": "104.28.131.104",
"bidIpv6": "2001:4860:4860::8888",
"bidPageUrl": "https://www.example.com",
"bidQid": "d93f2a0e5f0fe2cc3a6e",
"bidRequestsCount": 1,
"bidUa": "PostmanRuntime/7.26.8",
"placementCode": "6d93f2a0e5f0fe2cc3a6e9e3ade964b43b07f897",
"sizes": "320x100,300x250",
"type": "banner",
Expand Down Expand Up @@ -80,9 +92,7 @@
"urlAdq": "https://adquery.io",
"creationId": 7211,
"currency": "EUR",
"adDomains": [
"https://s1.adquery.io"
],
"adDomains": ["https://s1.adquery.io"],
"tag": "<ad-adquery-prebid data-qid=\"fc08aacb07eac44421ed\" data-type=\"banner320x50\" data-width=\"320\" date-height=\"50\" data-placement=\"d30f79cf7fef47bd7a5611719f936539bec0d2e9\" data-eventTracker=\"https://bidder.adquery.io/prebid/ev/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-externalEmissionCodes=\"\" data-impressionTracker=\"https://bidder.adquery.io/prebid/im/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-viewabilityTracker=\"https://bidder.adquery.io/prebid/vi/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?ad=1\" data-clickTracker=\"https://bidder.adquery.io/prebid/cl/d30f79cf7fef47bd7a5611719f936539bec0d2e9/22e26bd9a702bc?url=https%3A%2F%2Fbrodacid.pl%2F%3Futm_source%3Dmobile_open%26utm_medium%3Dcpc%26utm_campaign%3Dhi2023\" data-link=\"https://brodacid.pl/?utm_source=mobile_open&utm_medium=cpc&utm_campaign=hi2023\" data-src=\"banner/2023-06-05/17591\" data-ext=\"zip\" data-media-type=\"3\" data-isExpand=\"\" data-domain=\"https://bidder.adquery.io\" data-isVideoFloating=\"\" data-content=\"\" data-creationType=\"16\"> </ad-adquery>",
"adqLib": "https://api.adquery.io/js/adquery-0.1.js?time=10",
"mediaType": {
Expand Down Expand Up @@ -121,4 +131,4 @@
]
}
]
}
}
Loading

0 comments on commit 94d8682

Please sign in to comment.