diff --git a/adapters/adgeneration/adgeneration.go b/adapters/adgeneration/adgeneration.go index 110ec5ce98a..55fafde1d85 100644 --- a/adapters/adgeneration/adgeneration.go +++ b/adapters/adgeneration/adgeneration.go @@ -55,8 +55,13 @@ func (adg *AdgenerationAdapter) MakeRequests(request *openrtb2.BidRequest, reqIn headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") - if request.Device != nil && len(request.Device.UA) > 0 { - headers.Add("User-Agent", request.Device.UA) + if request.Device != nil { + if len(request.Device.UA) > 0 { + headers.Add("User-Agent", request.Device.UA) + } + if len(request.Device.IP) > 0 { + headers.Add("X-Forwarded-For", request.Device.IP) + } } bidRequestArray := make([]*adapters.RequestData, 0, numRequests) @@ -102,7 +107,6 @@ func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb2.BidRequ v := url.Values{} v.Set("posall", "SSPLOC") v.Set("id", id) - v.Set("sdktype", "0") v.Set("hb", "true") v.Set("t", "json3") v.Set("currency", adg.getCurrency(request)) @@ -112,12 +116,32 @@ func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb2.BidRequ if adSize != "" { v.Set("sizes", adSize) } + if request.Device != nil && request.Device.OS == "android" { + v.Set("sdktype", "1") + } else if request.Device != nil && request.Device.OS == "ios" { + v.Set("sdktype", "2") + } else { + v.Set("sdktype", "0") + } if request.Site != nil && request.Site.Page != "" { v.Set("tp", request.Site.Page) } if request.Source != nil && request.Source.TID != "" { v.Set("transactionid", request.Source.TID) } + if request.App != nil && request.App.Bundle != "" { + v.Set("appbundle", request.App.Bundle) + } + if request.App != nil && request.App.Name != "" { + v.Set("appname", request.App.Name) + } + if request.Device != nil && request.Device.OS == "ios" && request.Device.IFA != "" { + v.Set("idfa", request.Device.IFA) + } + if request.Device != nil && request.Device.OS == "android" && request.Device.IFA != "" { + v.Set("advertising_id", request.Device.IFA) + } + return &v } @@ -263,7 +287,7 @@ func removeWrapper(ad string) string { func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &AdgenerationAdapter{ config.Endpoint, - "1.0.2", + "1.0.3", "JPY", } return bidder, nil diff --git a/adapters/adgeneration/adgeneration_test.go b/adapters/adgeneration/adgeneration_test.go index d5d93ac4e0b..c186f19f4c5 100644 --- a/adapters/adgeneration/adgeneration_test.go +++ b/adapters/adgeneration/adgeneration_test.go @@ -23,7 +23,7 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "adgenerationtest", bidder) } -func TestgetRequestUri(t *testing.T) { +func TestGetRequestUri(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderAdgeneration, config.Adapter{ Endpoint: "https://d.socdm.com/adsv/v1"}) diff --git a/adapters/adgeneration/adgenerationtest/exemplary/single-banner-android.json b/adapters/adgeneration/adgenerationtest/exemplary/single-banner-android.json new file mode 100644 index 00000000000..487d44692e0 --- /dev/null +++ b/adapters/adgeneration/adgenerationtest/exemplary/single-banner-android.json @@ -0,0 +1,166 @@ +{ + "mockBidRequest":{ + "id": "some-request-id", + "site": { + "page": "http://example.com/test.html" + }, + "device": { + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36", + "ip": "0.0.0.0", + "os": "android", + "ifa": "advertising_id" + }, + "app": { + "name": "adgneration" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "id": "58278" + } + } + } + ], + "tmax": 500 + }, + "httpCalls": [ + { + "internalRequest": { + "id": "some-request-id", + "site": { + "page": "http://example.com/test.html" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "id": "58278" + } + } + } + ], + "tmax": 500 + }, + "expectedRequest":{ + "uri": "https://d.socdm.com/adsv/v1?adapterver=1.0.3&advertising_id=advertising_id&appname=adgneration¤cy=JPY&hb=true&id=58278&posall=SSPLOC&sdkname=prebidserver&sdktype=1&sizes=300x250&t=json3&tp=http%3A%2F%2Fexample.com%2Ftest.html", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ], + "User-Agent": [ + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36" + ], + "X-Forwarded-For": [ + "0.0.0.0" + ] + } + }, + "mockResponse":{ + "status": 200, + "body": { + "ad": "\n \n \n