Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions adapters/adnuntius/adnuntius.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,15 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters
}

}
var extUser openrtb_ext.ExtUser
if ortbRequest.User != nil && ortbRequest.User.Ext != nil {
if err := jsonutil.Unmarshal(ortbRequest.User.Ext, &extUser); err != nil {
return nil, []error{fmt.Errorf("failed to parse Ext User: %v", err)}
}
}

endpoint, err := makeEndpointUrl(ortbRequest, a, noCookies, extUser)

endpoint, err := makeEndpointUrl(ortbRequest, a, noCookies)
if err != nil {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("failed to parse URL: %s", err),
Expand All @@ -119,13 +126,6 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters
return nil, []error{fmt.Errorf("failed to parse site Ext: %v", err)}
}

var extUser openrtb_ext.ExtUser
if ortbRequest.User != nil && ortbRequest.User.Ext != nil {
if err := jsonutil.Unmarshal(ortbRequest.User.Ext, &extUser); err != nil {
return nil, []error{fmt.Errorf("failed to parse Ext User: %v", err)}
}
}

for _, networkAdunits := range networkAdunitMap {

adnuntiusRequest := adnRequest{
Expand All @@ -134,13 +134,6 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters
KeyValues: extSite.Data,
}

// Will change when our adserver can accept multiple user IDS
if extUser.Eids != nil && len(extUser.Eids) > 0 {
if len(extUser.Eids[0].UIDs) > 0 {
adnuntiusRequest.MetaData.Usi = extUser.Eids[0].UIDs[0].ID
}
}

ortbUser := ortbRequest.User
if ortbUser != nil {
ortbUserId := ortbRequest.User.ID
Expand Down
11 changes: 10 additions & 1 deletion adapters/adnuntius/adnuntius_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func setHeaders(ortbRequest openrtb2.BidRequest) http.Header {
return headers
}

func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter, noCookies bool) (string, []error) {
func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter, noCookies bool, extUser openrtb_ext.ExtUser) (string, []error) {
uri, err := url.Parse(a.endpoint)
if err != nil {
return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)}
Expand Down Expand Up @@ -80,6 +80,15 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter, noCookies bool
q.Set("noCookies", "true")
}

if extUser.Eids != nil && len(extUser.Eids) > 0 {
if len(extUser.Eids[0].UIDs) > 0 {
eidsJSON, err := jsonutil.Marshal(extUser.Eids)
if err == nil {
q.Set("eids", string(eidsJSON))
}
}
}

q.Set("tzo", strconv.Itoa(tzo))
q.Set("format", "prebidServer")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"mockBidRequest": {
"id": "test-request-id",
"user": {
"id": "1kjh3429kjh295jkl",
"ext":{
"eids" : [
{
"source": "adserver.org",
"uids": [
{ "id": "111111111111", "atype": 1, "ext": { "rtiPartner": "TDID" } }
]
},
{
"source": "pubcid.org",
"uids": [
{ "id": "22222222-2222-2222-2222-222222222222", "atype": 1 }
]
}
]
}
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"auId": "123"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://whatever.url?eids=%5B%7B%22source%22%3A%22adserver.org%22%2C%22uids%22%3A%5B%7B%22id%22%3A%22111111111111%22%2C%22atype%22%3A1%2C%22ext%22%3A%7B+%22rtiPartner%22%3A+%22TDID%22+%7D%7D%5D%7D%2C%7B%22source%22%3A%22pubcid.org%22%2C%22uids%22%3A%5B%7B%22id%22%3A%2222222222-2222-2222-2222-222222222222%22%2C%22atype%22%3A1%7D%5D%7D%5D&format=prebidServer&tzo=0",
"body": {
"adUnits": [
{
"auId": "123",
"targetId": "123-test-imp-id:banner",
"nativeRequest": {},
"dimensions": [[300,250],[300,600]]
}
],
"metaData": {
"usi": "1kjh3429kjh295jkl"
},
"context": "unknown"
},
"impIDs":["test-imp-id"]
},
"mockResponse": {
"status": 200,
"body": {
"adUnits": [
{
"auId": "0000000000000123",
"targetId": "123-test-imp-id:banner",
"matchedAdCount": 1,
"html": "<ADCODE>",
"responseId": "adn-rsp-900646517",
"ads": [
{
"destinationUrls": {
"url": "http://www.google.com"
},
"advertiserDomains": ["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",
"mtype": 1,
"w": 980,
"h": 240
},
"type": "banner"
}
],
"currency": "NOK"
}
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"mockBidRequest": {
"id": "test-request-id",
"user": {
"ext":{
"eids" : [
{
"source": "adserver.org",
"uids": [
{ "id": "111111111111", "atype": 1, "ext": { "rtiPartner": "TDID" } }
]
},
{
"source": "pubcid.org",
"uids": [
{ "id": "22222222-2222-2222-2222-222222222222", "atype": 1 }
]
}
]
}
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"auId": "123"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://whatever.url?eids=%5B%7B%22source%22%3A%22adserver.org%22%2C%22uids%22%3A%5B%7B%22id%22%3A%22111111111111%22%2C%22atype%22%3A1%2C%22ext%22%3A%7B+%22rtiPartner%22%3A+%22TDID%22+%7D%7D%5D%7D%2C%7B%22source%22%3A%22pubcid.org%22%2C%22uids%22%3A%5B%7B%22id%22%3A%2222222222-2222-2222-2222-222222222222%22%2C%22atype%22%3A1%7D%5D%7D%5D&format=prebidServer&tzo=0",
"body": {
"adUnits": [
{
"auId": "123",
"targetId": "123-test-imp-id:banner",
"nativeRequest": {},
"dimensions": [[300,250],[300,600]]
}
],
"metaData": {},
"context": "unknown"
},
"impIDs":["test-imp-id"]
},
"mockResponse": {
"status": 200,
"body": {
"adUnits": [
{
"auId": "0000000000000123",
"targetId": "123-test-imp-id:banner",
"matchedAdCount": 1,
"html": "<ADCODE>",
"responseId": "adn-rsp-900646517",
"ads": [
{
"destinationUrls": {
"url": "http://www.google.com"
},
"advertiserDomains": ["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",
"mtype": 1,
"w": 980,
"h": 240
},
"type": "banner"
}
],
"currency": "NOK"
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
"user": {
"ext":{
"eids" : [
{
"source": "idProvider",
"uids": [
{ "id": "userId", "atype": 1, "ext": { "stype": "ppuid" } }
]
}
]
}
},
Expand Down Expand Up @@ -48,10 +42,8 @@
"nativeRequest": {},
"dimensions": [[300,250],[300,600]]
}
],
"metaData": {
"usi": "userId"
},
],
"metaData": {},
"context": "unknown"
},
"impIDs":["test-imp-id"]
Expand Down Expand Up @@ -115,3 +107,4 @@
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"expectedMakeRequestsErrors": [
{
"value": "failed to parse URL: [failed to parse GDPR information: failed to parse ExtUser in Adnuntius GDPR check: expect { or n, but found \"]",
"value": "failed to parse Ext User: expect { or n, but found \"",
"comparison": "literal"
}
]
Expand Down
Loading