-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adform adapter lacked gross/net parameter support #2084
Changes from 2 commits
d2b553c
05d9d4b
1504712
063990f
a3bfae6
fffd6b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,11 @@ type adapter struct { | |
endpoint string | ||
} | ||
|
||
type adfRequestExt struct { | ||
openrtb_ext.ExtRequest | ||
PriceType string `json:"pt"` | ||
} | ||
|
||
// Builder builds a new instance of the Adf adapter for the given bidder with the given config. | ||
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { | ||
bidder := &adapter{ | ||
|
@@ -47,6 +52,27 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte | |
|
||
imp.TagID = adfImpExt.MasterTagID.String() | ||
validImps = append(validImps, imp) | ||
|
||
if adfImpExt.PriceType != "" { | ||
var requestExt adfRequestExt | ||
|
||
if len(request.Ext) > 0 { | ||
if err := json.Unmarshal(request.Ext, &requestExt); err != nil { | ||
errors = append(errors, err) | ||
continue | ||
} | ||
} else { | ||
requestExt = adfRequestExt{} | ||
} | ||
|
||
requestExt.PriceType = adfImpExt.PriceType | ||
|
||
var err error | ||
if request.Ext, err = json.Marshal(&requestExt); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 60: you marshal req.Ext as many times as many imps are there in reqiest - it's located inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All priceTypes need to be the same, but really only the first one should be used and not the last one if they should differ. |
||
errors = append(errors, err) | ||
continue | ||
} | ||
} | ||
} | ||
|
||
request.Imp = validImps | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"ext":{ | ||
"prebid":{ | ||
"aliases":{ | ||
"adfalias": "adf" | ||
} | ||
} | ||
}, | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"mid": "828782", | ||
"priceType": "gross" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test case where there are 2 imps in request with different There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if that is really needed but I can add one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Thank you @VeronikaSolovei9 for the feedback! |
||
}, | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
} | ||
}], | ||
"site": { | ||
"publisher": { | ||
"id": "1" | ||
}, | ||
"page": "some-page-url" | ||
}, | ||
"device": { | ||
"w": 1920, | ||
"h": 800 | ||
} | ||
}, | ||
"httpCalls": [{ | ||
"expectedRequest": { | ||
"uri": "https://adx.adform.net/adx/openrtb", | ||
"body": { | ||
"id": "test-request-id", | ||
"ext": { | ||
"prebid":{ | ||
"aliases":{ | ||
"adfalias": "adf" | ||
} | ||
}, | ||
"pt": "gross" | ||
}, | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"mid": "828782", | ||
"priceType": "gross" | ||
} | ||
}, | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
}, | ||
"tagid": "828782" | ||
}], | ||
"site": { | ||
"publisher": { | ||
"id": "1" | ||
}, | ||
"page": "some-page-url" | ||
}, | ||
"device": { | ||
"w": 1920, | ||
"h": 800 | ||
} | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-request-id", | ||
"seatbid": [{ | ||
"bid": [{ | ||
"id": "test-bid-id", | ||
"impid": "test-imp-id", | ||
"price": 10, | ||
"adm": "{banner html}", | ||
"adomain": [ "test.com" ], | ||
"crid": "test-creative-id", | ||
"ext": { | ||
"prebid": { | ||
"type": "banner" | ||
} | ||
} | ||
}] | ||
}], | ||
"cur": "USD" | ||
} | ||
} | ||
}], | ||
"expectedBidResponses": [{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"id": "test-bid-id", | ||
"impid": "test-imp-id", | ||
"price": 10, | ||
"adm": "{banner html}", | ||
"crid": "test-creative-id", | ||
"adomain": [ "test.com" ], | ||
"ext": { | ||
"prebid": { | ||
"type": "banner" | ||
} | ||
} | ||
}, | ||
"type": "banner" | ||
} | ||
] | ||
}] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"mid": "828782", | ||
"priceType": "gross" | ||
} | ||
}, | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
} | ||
}], | ||
"site": { | ||
"publisher": { | ||
"id": "1" | ||
}, | ||
"page": "some-page-url" | ||
}, | ||
"device": { | ||
"w": 1920, | ||
"h": 800 | ||
} | ||
}, | ||
"httpCalls": [{ | ||
"expectedRequest": { | ||
"uri": "https://adx.adform.net/adx/openrtb", | ||
"body": { | ||
"id": "test-request-id", | ||
"ext": { | ||
"prebid": { | ||
}, | ||
"pt": "gross" | ||
}, | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"mid": "828782", | ||
"priceType": "gross" | ||
} | ||
}, | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
}, | ||
"tagid": "828782" | ||
}], | ||
"site": { | ||
"publisher": { | ||
"id": "1" | ||
}, | ||
"page": "some-page-url" | ||
}, | ||
"device": { | ||
"w": 1920, | ||
"h": 800 | ||
} | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-request-id", | ||
"seatbid": [{ | ||
"bid": [{ | ||
"id": "test-bid-id", | ||
"impid": "test-imp-id", | ||
"price": 10, | ||
"adm": "{banner html}", | ||
"adomain": [ "test.com" ], | ||
"crid": "test-creative-id", | ||
"ext": { | ||
"prebid": { | ||
"type": "banner" | ||
} | ||
} | ||
}] | ||
}], | ||
"cur": "USD" | ||
} | ||
} | ||
}], | ||
"expectedBidResponses": [{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"id": "test-bid-id", | ||
"impid": "test-imp-id", | ||
"price": 10, | ||
"adm": "{banner html}", | ||
"crid": "test-creative-id", | ||
"adomain": [ "test.com" ], | ||
"ext": { | ||
"prebid": { | ||
"type": "banner" | ||
} | ||
} | ||
}, | ||
"type": "banner" | ||
} | ||
] | ||
}] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"mockBidRequest": { | ||
"id": "test-request-id", | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"mid": "828782", | ||
"priceType": "net" | ||
} | ||
}, | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
} | ||
}], | ||
"site": { | ||
"publisher": { | ||
"id": "1" | ||
}, | ||
"page": "some-page-url" | ||
}, | ||
"device": { | ||
"w": 1920, | ||
"h": 800 | ||
} | ||
}, | ||
"httpCalls": [{ | ||
"expectedRequest": { | ||
"uri": "https://adx.adform.net/adx/openrtb", | ||
"body": { | ||
"id": "test-request-id", | ||
"ext": { | ||
"prebid": { | ||
}, | ||
"pt": "net" | ||
}, | ||
"imp": [{ | ||
"id": "test-imp-id", | ||
"ext": { | ||
"bidder": { | ||
"mid": "828782", | ||
"priceType": "net" | ||
} | ||
}, | ||
"banner": { | ||
"format": [{ | ||
"w": 300, | ||
"h": 250 | ||
}] | ||
}, | ||
"tagid": "828782" | ||
}], | ||
"site": { | ||
"publisher": { | ||
"id": "1" | ||
}, | ||
"page": "some-page-url" | ||
}, | ||
"device": { | ||
"w": 1920, | ||
"h": 800 | ||
} | ||
} | ||
}, | ||
"mockResponse": { | ||
"status": 200, | ||
"body": { | ||
"id": "test-request-id", | ||
"seatbid": [{ | ||
"bid": [{ | ||
"id": "test-bid-id", | ||
"impid": "test-imp-id", | ||
"price": 10, | ||
"adm": "{banner html}", | ||
"adomain": [ "test.com" ], | ||
"crid": "test-creative-id", | ||
"ext": { | ||
"prebid": { | ||
"type": "banner" | ||
} | ||
} | ||
}] | ||
}], | ||
"cur": "USD" | ||
} | ||
} | ||
}], | ||
"expectedBidResponses": [{ | ||
"currency": "USD", | ||
"bids": [ | ||
{ | ||
"bid": { | ||
"id": "test-bid-id", | ||
"impid": "test-imp-id", | ||
"price": 10, | ||
"adm": "{banner html}", | ||
"crid": "test-creative-id", | ||
"adomain": [ "test.com" ], | ||
"ext": { | ||
"prebid": { | ||
"type": "banner" | ||
} | ||
} | ||
}, | ||
"type": "banner" | ||
} | ||
] | ||
}] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
statement can be omitted if you init requestExt like this:requestExt := adfRequestExt{}
(line 57)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! It will be initiated even if it may not be needed but no harm done in that I guess.