Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/code-path-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: read

jobs:
notify:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion adapters/connatix/connatix.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ func buildRequestImp(imp *openrtb2.Imp, ext impExtIncoming, displayManagerVer st

impExt := impExt{
Connatix: impExtConnatix{
PlacementId: ext.Bidder.PlacementId,
PlacementId: ext.Bidder.PlacementId,
ViewabilityPercentage: ext.Bidder.ViewabilityPercentage,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
},
"ext": {
"bidder": {
"placementId": "some-placement-id"
"placementId": "some-placement-id",
"viewabilityPercentage": 0.6
}
}
}
Expand Down Expand Up @@ -78,7 +79,8 @@
"displaymanagerver": "test-1.0.0",
"ext": {
"connatix": {
"placementId": "some-placement-id"
"placementId": "some-placement-id",
"viewabilityPercentage": 0.6
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion adapters/connatix/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type impExt struct {
}

type impExtConnatix struct {
PlacementId string `json:"placementId,omitempty"`
PlacementId string `json:"placementId,omitempty"`
ViewabilityPercentage float64 `json:"viewabilityPercentage,omitempty"`
}

type bidExt struct {
Expand Down
116 changes: 116 additions & 0 deletions adapters/loopme/loopme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package loopme

import (
"encoding/json"
"fmt"
"net/http"

"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v3/adapters"
"github.com/prebid/prebid-server/v3/config"
"github.com/prebid/prebid-server/v3/errortypes"
"github.com/prebid/prebid-server/v3/openrtb_ext"
)

type adapter struct {
endpoint string
}

func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
errs := make([]error, 0, len(request.Imp))

reqDatas := make([]*adapters.RequestData, 0, len(request.Imp))

for _, imp := range request.Imp {
requestCopy := *request
requestCopy.Imp = []openrtb2.Imp{imp}
reqJSON, err := json.Marshal(requestCopy)
if err != nil {
errs = append(errs, err)
continue
}

headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
reqDatas = append(reqDatas, &adapters.RequestData{
Method: http.MethodPost,
Uri: a.endpoint,
Body: reqJSON,
Headers: headers,
ImpIDs: openrtb_ext.GetImpIDs(requestCopy.Imp),
})

}
return reqDatas, errs
}

func (a *adapter) MakeBids(bidReq *openrtb2.BidRequest, reqData *adapters.RequestData, respData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if adapters.IsResponseStatusCodeNoContent(respData) {
return nil, nil
}

if err := adapters.CheckResponseStatusCodeForErrors(respData); err != nil {
return nil, []error{err}
}

var bidResp openrtb2.BidResponse
if err := json.Unmarshal(respData.Body, &bidResp); err != nil {
return nil, []error{err}
}

if len(bidResp.SeatBid) == 0 || len(bidResp.SeatBid[0].Bid) == 0 {
return nil, nil
}

errs := make([]error, 0, len(bidResp.SeatBid[0].Bid))
resp := adapters.NewBidderResponseWithBidsCapacity(len(bidResp.SeatBid[0].Bid))

for _, sb := range bidResp.SeatBid {
for i := range sb.Bid {
bid := &sb.Bid[i]
bidType, err := getBidType(bid)
if err != nil {
errs = append(errs, err)
continue
}
resp.Bids = append(resp.Bids, &adapters.TypedBid{
Bid: bid,
BidType: bidType,
})
}
}

if len(resp.Bids) == 0 {
return nil, errs
}
if len(bidResp.Cur) != 0 {
resp.Currency = bidResp.Cur
}
return resp, errs
}

func getBidType(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.MarkupNative:
return openrtb_ext.BidTypeNative, nil
case openrtb2.MarkupAudio:
return openrtb_ext.BidTypeAudio, nil
default:
return "", &errortypes.BadServerResponse{
Message: fmt.Sprintf("Unsupported MType %d", bid.MType),
}
}
}

// Builder builds a new instance of the Loopme adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, cfg config.Adapter, serverCfg config.Server) (adapters.Bidder, error) {
bidder := &adapter{
endpoint: cfg.Endpoint,
}
return bidder, nil
}
29 changes: 29 additions & 0 deletions adapters/loopme/loopme_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package loopme

import (
"testing"

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

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(
openrtb_ext.BidderLoopme,
config.Adapter{
Endpoint: "http://loopme.example.com",
},
config.Server{
ExternalUrl: "http://hosturl.com",
GvlID: 109,
DataCenter: "2",
},
)

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

adapterstest.RunJSONBidderTest(t, "loopmetest", bidder)
}
152 changes: 152 additions & 0 deletions adapters/loopme/loopmetest/exemplary/app-formats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"mockBidRequest": {
"id": "test-request-id",
"app": {
"bundle": "com.prebid"
},
"device": {
"ifa": "ec943cb9-61ec-460f-a925-6489c3fcc4e3"
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
2,
3,
5,
6
],
"w": 1024,
"h": 576
},
"native": {
"request": "{json string 1}",
"ver": "1.2"
},
"ext": {
"bidder": {
"publisherId": "10000000"
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://loopme.example.com",
"body": {
"id": "test-request-id",
"app": {
"bundle": "com.prebid"
},
"device": {
"ifa": "ec943cb9-61ec-460f-a925-6489c3fcc4e3"
},
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"video": {
"mimes": [
"video/mp4"
],
"protocols": [
2,
3,
5,
6
],
"w": 1024,
"h": 576
},
"native": {
"request": "{json string 1}",
"ver": "1.2"
},
"ext": {
"bidder": {
"publisherId": "10000000"
}
}
}
]
},
"impIDs": [
"test-imp-id"
]
},
"mockResponse": {
"status": 200,
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json;charset=utf-8"
]
},
"body": {
"id": "test-request-id",
"seatbid": [
{
"seat": "loopme",
"bid": [
{
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.500000,
"adm": "some-test-ad",
"crid": "test-crid",
"w": 728,
"h": 90,
"mtype": 1
}
]
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-ad",
"crid": "test-crid",
"w": 728,
"h": 90,
"mtype": 1
},
"type": "banner"
}
]
}
]
}
Loading
Loading