Skip to content

Commit

Permalink
New adapter Edge226
Browse files Browse the repository at this point in the history
  • Loading branch information
Edge226Ads committed Oct 3, 2023
1 parent 0df50db commit 2dde5cd
Show file tree
Hide file tree
Showing 11 changed files with 321 additions and 374 deletions.
39 changes: 15 additions & 24 deletions adapters/edge226/edge226.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-server/openrtb_ext"
)

Expand Down Expand Up @@ -98,14 +97,11 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestDa
}

func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if responseData.StatusCode == http.StatusNoContent {
if adapters.IsResponseStatusCodeNoContent(responseData) {
return nil, nil
}

if responseData.StatusCode != http.StatusOK {
err := &errortypes.BadServerResponse{
Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode),
}
if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil {
return nil, []error{err}
}

Expand All @@ -118,7 +114,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
bidResponse.Currency = response.Cur
for _, seatBid := range response.SeatBid {
for i := range seatBid.Bid {
bidType, err := getMediaTypeForImp(seatBid.Bid[i].ImpID, request.Imp)
bidType, err := getBidMediaType(&seatBid.Bid[i])
if err != nil {
return nil, []error{err}
}
Expand All @@ -133,22 +129,17 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
return bidResponse, nil
}

func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
for _, imp := range imps {
if imp.ID == impID {
if imp.Banner != nil {
return openrtb_ext.BidTypeBanner, nil
}
if imp.Video != nil {
return openrtb_ext.BidTypeVideo, nil
}
if imp.Native != nil {
return openrtb_ext.BidTypeNative, nil
}
}
}

return "", &errortypes.BadInput{
Message: fmt.Sprintf("Failed to find impression \"%s\"", impID),
func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
case openrtb2.MarkupAudio:
return openrtb_ext.BidTypeAudio, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", fmt.Errorf("Unable to fetch mediaType in multi-format: %s", bid.ImpID)
}
}
2 changes: 1 addition & 1 deletion adapters/edge226/edge226_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.BidderEdge226, config.Adapter{
Endpoint: "http://ssp.dauup.com/pserver"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
Endpoint: "http://test.com/pserver"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
Expand Down
18 changes: 5 additions & 13 deletions adapters/edge226/edge226test/exemplary/endpointId.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssp.dauup.com/pserver",
"uri": "http://test.com/pserver",
"body": {
"id": "test-request-id",
"imp": [
Expand Down Expand Up @@ -84,17 +84,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "banner"
}
}
"mtype": 1
}
],
"seat": "edge226"
Expand All @@ -113,17 +109,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "banner"
}
}
"mtype": 1
},
"type": "banner"
}
Expand Down
24 changes: 8 additions & 16 deletions adapters/edge226/edge226test/exemplary/simple-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"ext": {
"bidder": {
"placementId": "test"
"endpointId": "test"
}
}
}
Expand All @@ -36,7 +36,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssp.dauup.com/pserver",
"uri": "http://test.com/pserver",
"body": {
"id": "test-request-id",
"imp": [
Expand All @@ -57,8 +57,8 @@
},
"ext": {
"bidder": {
"placementId": "test",
"type": "publisher"
"endpointId": "test",
"type": "network"
}
}
}
Expand All @@ -84,17 +84,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "banner"
}
}
"mtype": 1
}
],
"seat": "edge226"
Expand All @@ -113,17 +109,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "banner"
}
}
"mtype": 1
},
"type": "banner"
}
Expand Down
18 changes: 5 additions & 13 deletions adapters/edge226/edge226test/exemplary/simple-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssp.dauup.com/pserver",
"uri": "http://test.com/pserver",
"body": {
"id": "test-request-id",
"imp": [
Expand Down Expand Up @@ -68,17 +68,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "native"
}
}
"mtype": 4
}
],
"seat": "edge226"
Expand All @@ -97,17 +93,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"adm": "<iframe id=\"adm-banner-16\" width=\"300\" height=\"250\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=882b2510ed6d6c94fa69c99aa522a708\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 300,
"h": 250,
"ext": {
"prebid": {
"type": "native"
}
}
"mtype": 4
},
"type": "native"
}
Expand Down
14 changes: 3 additions & 11 deletions adapters/edge226/edge226test/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssp.dauup.com/pserver",
"uri": "http://test.com/pserver",
"body": {
"id": "test-request-id",
"device": {
Expand Down Expand Up @@ -86,11 +86,7 @@
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"ext": {
"prebid": {
"type": "video"
}
}
"mtype": 2
}
],
"seat": "edge226"
Expand All @@ -114,11 +110,7 @@
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"ext": {
"prebid": {
"type": "video"
}
}
"mtype": 2
},
"type": "video"
}
Expand Down
18 changes: 5 additions & 13 deletions adapters/edge226/edge226test/exemplary/simple-web-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "http://ssp.dauup.com/pserver",
"uri": "http://test.com/pserver",
"body": {
"id": "test-request-id",
"imp": [
Expand Down Expand Up @@ -84,17 +84,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-1\" width=\"468\" height=\"60\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=bc2d316f39931a07d9a8dd249bf85fc0\"></iframe>",
"adm": "<iframe id=\"adm-banner-1\" width=\"468\" height=\"60\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=bc2d316f39931a07d9a8dd249bf85fc0\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 468,
"h": 60,
"ext": {
"prebid": {
"type": "banner"
}
}
"mtype": 1
}
],
"seat": "edge226"
Expand All @@ -113,17 +109,13 @@
"id": "test_bid_id",
"impid": "test-imp-id",
"price": 0.27543,
"adm": "<iframe id=\"adm-banner-1\" width=\"468\" height=\"60\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://ssp.dauup.com/pserver&k=bc2d316f39931a07d9a8dd249bf85fc0\"></iframe>",
"adm": "<iframe id=\"adm-banner-1\" width=\"468\" height=\"60\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" style=\"{overflow:hidden}\" src=\"http://test.com/pserver&k=bc2d316f39931a07d9a8dd249bf85fc0\"></iframe>",
"cid": "test_cid",
"crid": "test_crid",
"dealid": "test_dealid",
"w": 468,
"h": 60,
"ext": {
"prebid": {
"type": "banner"
}
}
"mtype": 1
},
"type": "banner"
}
Expand Down
Loading

0 comments on commit 2dde5cd

Please sign in to comment.