Skip to content
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

New Adapter: Adyoulike #1700

Merged
merged 81 commits into from
Mar 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
b6ae82b
add bidder name
guiann Dec 2, 2019
2a1dceb
create some files for adYoulike adapter
guiann Dec 2, 2019
de5974f
fix macro syntax in bidder url
guiann Dec 3, 2019
637105e
register possible parameters for adyoulike bidder
guiann Dec 3, 2019
f2c4a64
add metadata files describing adyoulike bidder adapter
guiann Dec 3, 2019
919f3d8
fix adyoulike objects naming
guiann Dec 3, 2019
8735218
update url with real prebid server partner id
guiann Dec 4, 2019
3110d51
add native add type to adyoulike adapter
guiann Dec 5, 2019
7a7e97c
exchange misplaces urls: user sync instead of bidder endpoint
guiann Dec 5, 2019
59bbe10
Merge branch 'master' into Add-AdYouLike-Adapter
guiann Oct 9, 2020
59ae0dd
add adyoulike in syncers list
guiann Oct 9, 2020
d68b6ca
fix usync and end point urls
guiann Oct 9, 2020
bacce93
fix merge issues
guiann Oct 9, 2020
dd0da6d
add parameters in json schema
guiann Oct 9, 2020
6bac7e8
add bidder name
guiann Dec 2, 2019
256bf51
create some files for adYoulike adapter
guiann Dec 2, 2019
b391165
register possible parameters for adyoulike bidder
guiann Dec 3, 2019
2cc7c73
add metadata files describing adyoulike bidder adapter
guiann Dec 3, 2019
8f881eb
fix adyoulike objects naming
guiann Dec 3, 2019
b4882a7
add native add type to adyoulike adapter
guiann Dec 5, 2019
a9bec7e
add adyoulike in syncers list
guiann Oct 9, 2020
001c3cf
fix usync and end point urls
guiann Oct 9, 2020
7dea0ba
fix merge issues
guiann Oct 9, 2020
8112e41
add parameters in json schema
guiann Oct 9, 2020
a5c8beb
Merge remote-tracking branch 'Adyoulike/Add-AdYouLike-Adapter' into A…
guiann Feb 9, 2021
ce17d51
add flag for video imp
guiann Feb 11, 2021
ca60064
fix merge issue, remove double lines
guiann Feb 11, 2021
d47c1ef
fix missing curly braket
guiann Feb 11, 2021
672d72b
add missing bidder name
guiann Feb 12, 2021
1b0865b
remove camel case from json
guiann Feb 12, 2021
20c859a
update usync url
guiann Feb 12, 2021
1e02962
remove camel case
guiann Feb 12, 2021
5333392
fix typo
guiann Feb 12, 2021
172423d
Fix builder
Feb 12, 2021
c9050d8
Merge remote-tracking branch 'Adyoulike/Add-AdYouLike-Adapter' into A…
guiann Feb 12, 2021
eeef5fe
add placement in tagId
guiann Feb 12, 2021
c96c3a3
add unit tests on ayl adapter
guiann Feb 15, 2021
c1a5360
fix syncer with unit tests
guiann Feb 15, 2021
3eb8b3a
Merge remote-tracking branch 'prebid/master' into Add-AdYouLike-Adapter
guiann Feb 15, 2021
ca5f7c8
update contact email
guiann Feb 15, 2021
340b70b
update usync url
guiann Feb 15, 2021
c14f352
Merge pull request #1 from Adyoulike/Add-AdYouLike-Adapter
guiann Feb 15, 2021
26c1878
set partner id
guiann Feb 15, 2021
83b928c
Merge branch 'Add-AdYouLike-Adapter'
guiann Feb 15, 2021
d761278
add jenkins file
guiann Feb 16, 2021
9cf49d5
add port script before run
guiann Feb 17, 2021
caf8b66
Merge remote-tracking branch 'prebid/master'
guiann Feb 17, 2021
a8182c1
let the infra team setup and launch prebid server
guiann Feb 18, 2021
af7b423
set broker endpoint to preprod fortest purpose
guiann Feb 18, 2021
a2112d4
add deploy step and message to make sure all is fine
guiann Feb 18, 2021
6c30df3
rename adyoulikeadapter to adapter
guiann Feb 18, 2021
aef0912
remove useless parameter check
guiann Feb 18, 2021
b56f4cc
add ayl GVL vendor id
guiann Feb 18, 2021
6f0ba28
Merge remote-tracking branch 'prebid/master' into Add-AdYouLike-Adapter
guiann Feb 19, 2021
0959a27
Merge remote-tracking branch 'prebid/master'
guiann Feb 19, 2021
e7916c3
set version string as image tag
guiann Feb 19, 2021
50bfcf6
test with params
guiann Feb 19, 2021
ae42eb4
add a parameter example
guiann Feb 19, 2021
185afc6
revert go mod
guiann Feb 19, 2021
f45f267
regexp for non empty tag param
guiann Feb 19, 2021
1b7f130
revert go sum
guiann Feb 19, 2021
b12f2b8
fix usync test
guiann Feb 23, 2021
68123ab
add params test
guiann Feb 23, 2021
43d31a5
moved some test cases to JSON format
guiann Feb 23, 2021
2d9a54f
add params test files
guiann Feb 23, 2021
84a7500
Merge branch 'master' into Add-AdYouLike-Adapter
guiann Feb 23, 2021
5486eba
remove old test with mock in go code
guiann Feb 24, 2021
615907f
revert protected files
guiann Feb 24, 2021
77cb7b6
add usync callback url
guiann Feb 24, 2021
d7f0a94
unused method removed
guiann Feb 25, 2021
69f253b
update comment
guiann Feb 25, 2021
043baa8
removed duplicated test for tagId
guiann Feb 25, 2021
3c18268
run gofmt
guiann Feb 25, 2021
d4c2b0f
removed unused import
guiann Feb 25, 2021
cd6b975
Merge remote-tracking branch 'prebid/master' into Add-AdYouLike-Adapter
guiann Feb 25, 2021
bf86a2e
update usersync callback url
guiann Feb 26, 2021
5b5cecb
Add error cases in supplemental tests
guiann Feb 26, 2021
1b43d18
run gofmt
guiann Feb 26, 2021
91726dc
Merge remote-tracking branch 'prebid/master' into Add-AdYouLike-Adapter
guiann Feb 26, 2021
76ee62e
fix VISITOR macro
guiann Mar 4, 2021
878f472
Merge remote-tracking branch 'prebid/master' into Add-AdYouLike-Adapter
guiann Mar 4, 2021
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
137 changes: 137 additions & 0 deletions adapters/adyoulike/adyoulike.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package adyoulike

import (
"encoding/json"
"errors"
"fmt"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/openrtb_ext"
"net/http"

"github.com/buger/jsonparser"
"github.com/mxmCherry/openrtb"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/errortypes"
)

func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) {
return &adapter{
endpoint: config.Endpoint,
}, nil
}

type adapter struct {
endpoint string
}

func (a *adapter) MakeRequests(
openRTBRequest *openrtb.BidRequest,
reqInfo *adapters.ExtraRequestInfo,
) (
requestsToBidder []*adapters.RequestData,
errs []error,
) {
var err error
var tagID string

reqCopy := *openRTBRequest
reqCopy.Imp = []openrtb.Imp{}
for ind, imp := range openRTBRequest.Imp {
guiann marked this conversation as resolved.
Show resolved Hide resolved
reqCopy.Imp = append(reqCopy.Imp, imp)

tagID, err = jsonparser.GetString(reqCopy.Imp[ind].Ext, "bidder", "placement")
if err != nil {
errs = append(errs, err)
continue
}
guiann marked this conversation as resolved.
Show resolved Hide resolved

reqCopy.Imp[ind].TagID = tagID
guiann marked this conversation as resolved.
Show resolved Hide resolved
}

openRTBRequestJSON, err := json.Marshal(reqCopy)
if err != nil {
errs = append(errs, err)
}

if len(errs) > 0 {
return nil, errs
}

headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
headers.Add("x-openrtb-version", "2.5")

requestToBidder := &adapters.RequestData{
Method: "POST",
Uri: a.endpoint,
Body: openRTBRequestJSON,
Headers: headers,
}
requestsToBidder = append(requestsToBidder, requestToBidder)

return requestsToBidder, errs
}

const unexpectedStatusCodeFormat = "" +
"Unexpected status code: %d. Run with request.debug = 1 for more info"

func (a *adapter) MakeBids(
openRTBRequest *openrtb.BidRequest,
requestToBidder *adapters.RequestData,
bidderRawResponse *adapters.ResponseData,
) (
bidderResponse *adapters.BidderResponse,
errs []error,
) {
switch bidderRawResponse.StatusCode {
guiann marked this conversation as resolved.
Show resolved Hide resolved
case http.StatusOK:
break
case http.StatusNoContent:
return nil, []error{errors.New("MakeBids error: No Content")}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guiann : We have noticed that this behavior is causing some debugging issues. In the case where you simply have no bids to offer, returning an error implies that there was some issue with the request that needs to be resolved to get your bidder to actually bid in the auction. Or if this is actually an indication of a real error, something more informative than "No Content" is needed for any meaningful debugging to occur.

case http.StatusBadRequest:
err := &errortypes.BadInput{
Message: fmt.Sprintf(unexpectedStatusCodeFormat, bidderRawResponse.StatusCode),
}
return nil, []error{err}
default:
err := &errortypes.BadServerResponse{
Message: fmt.Sprintf(unexpectedStatusCodeFormat, bidderRawResponse.StatusCode),
}
return nil, []error{err}
}

var openRTBBidderResponse openrtb.BidResponse
if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil {
return nil, []error{err}
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(openRTBRequest.Imp))
bidResponse.Currency = openRTBBidderResponse.Cur
for _, seatBid := range openRTBBidderResponse.SeatBid {
for idx := range seatBid.Bid {
b := &adapters.TypedBid{
Bid: &seatBid.Bid[idx],
BidType: getMediaTypeForImp(seatBid.Bid[idx].ImpID, openRTBRequest.Imp),
}
bidResponse.Bids = append(bidResponse.Bids, b)
}
}
return bidResponse, nil
}

// getMediaTypeForBid determines which type of bid.
func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType {
mediaType := openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == impID {
if imp.Banner == nil && imp.Video != nil {
mediaType = openrtb_ext.BidTypeVideo
} else if imp.Banner == nil && imp.Native != nil {
mediaType = openrtb_ext.BidTypeNative
}
guiann marked this conversation as resolved.
Show resolved Hide resolved
}
}

return mediaType
}
22 changes: 22 additions & 0 deletions adapters/adyoulike/adyoulike_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package adyoulike

import (
"testing"

"github.com/prebid/prebid-server/adapters/adapterstest"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/openrtb_ext"
)

const testsBidderEndpoint = "https://localhost/bid/4"

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderAdyoulike, config.Adapter{
Endpoint: testsBidderEndpoint})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}

adapterstest.RunJSONBidderTest(t, "adyouliketest", bidder)
}
169 changes: 169 additions & 0 deletions adapters/adyoulike/adyouliketest/exemplary/multiformat-impression.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "banner-imp-id",
"banner": {
"format": [
{
"w": 300,
"h": 250
}
]
},
"ext": {
"bidder": {
"placement": "12345"
}
}
},
{
"id": "video-imp-id",
"video": {
"w": 640,
"h": 480
},
"ext": {
"bidder": {
"placement": "54321"
}
}
},
{
"id": "native-imp-id",
"native": {
"title": "required"
},
"ext": {
"bidder": {
"placement": "123123"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "https://localhost/bid/4",
"body": {
"id": "test-request-id",
"imp": [
{
"banner": {
"format": [
{
"h": 250,
"w": 300
}
]
},
"ext": {
"bidder": {
"placement": "12345"
}
},
"id": "banner-imp-id",
"tagid": "12345"
},
{
"ext": {
"bidder": {
"placement": "54321"
}
},
"id": "video-imp-id",
"tagid": "54321",
"video": {
"h": 480,
"mimes": null,
"w": 640
}
},
{
"ext": {
"bidder": {
"placement": "123123"
}
},
"id": "native-imp-id",
"native": {
"request": ""
},
"tagid": "123123"
}
]
}
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-response-id",
"seatbid": [{
"seat": "1",
"bid": [{
"id": "12340",
"impid": "banner-imp-id",
"price": 300,
"adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2Fhtml%3E",
"nurl": "http://example.com/winnoticeurl0"
},
{
"id": "12341",
"impid": "video-imp-id",
"price": 301,
"adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2FVAST%3E",
"nurl": "http://example.com/winnoticeurl1"
},
{
"id": "12342",
"impid": "native-imp-id",
"price": 302,
"adm": "{'json':'response','for':'native'}",
"nurl": "http://example.com/winnoticeurl2"
}
]
}]
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "12340",
"impid": "banner-imp-id",
"price": 300,
"nurl": "http://example.com/winnoticeurl0",
"adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2Fhtml%3E"
},
"type": "banner"
},
{
"bid": {
"id": "12341",
"impid": "video-imp-id",
"price": 301,
"nurl": "http://example.com/winnoticeurl1",
"adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2FVAST%3E"
},
"type": "video"
},
{
"bid": {
"id": "12342",
"impid": "native-imp-id",
"price": 302,
"nurl": "http://example.com/winnoticeurl2",
"adm": "{'json':'response','for':'native'}"
},
"type": "native"
}
]
}
]
}
3 changes: 3 additions & 0 deletions adapters/adyoulike/adyouliketest/params/race/banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"placement": "19f1b372c7548ec1fe734d2c9f8dc688"
}
3 changes: 3 additions & 0 deletions adapters/adyoulike/adyouliketest/params/race/video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"placement": "19f1b372c7548ec1fe734d2c9f8dc688"
}
Loading