Skip to content

Commit dd7f333

Browse files
authored
Merge branch 'prebid:master' into master
2 parents 04a954e + db40c2e commit dd7f333

217 files changed

Lines changed: 10942 additions & 993 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publishonly.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: PublishOnly
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
imageToPublish:
7+
type: string
8+
required: true
9+
description: 'Already built docker image to publish to docker hub'
10+
11+
publish-docker-image:
12+
name: Publish docker image
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Login to docker Hub
16+
id: login
17+
uses: docker/login-action@v2.1.0
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USER }}
20+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
21+
- name: Publish to docker Hub
22+
if: steps.login.outcome == 'success'
23+
run: |
24+
docker push docker.io/prebid/prebid-server:${{ inputs.imageToPublish }}

adapters/adnuntius/adnuntius_types.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ type NativeRequest struct {
1818
}
1919

2020
type adnRequestAdunit struct {
21-
AuId string `json:"auId"`
22-
TargetId string `json:"targetId"`
23-
AdType string `json:"adType,omitempty"`
24-
NativeRequest NativeRequest `json:"nativeRequest,omitempty"`
25-
Dimensions [][]int64 `json:"dimensions,omitempty"`
26-
MaxDeals int `json:"maxDeals,omitempty"`
21+
AuId string `json:"auId"`
22+
TargetId string `json:"targetId"`
23+
AdType string `json:"adType,omitempty"`
24+
NativeRequest NativeRequest `json:"nativeRequest,omitempty"`
25+
Dimensions [][]int64 `json:"dimensions,omitempty"`
26+
MaxDeals int `json:"maxDeals,omitempty"`
27+
Category []string `json:"c,omitempty"`
28+
Segments []string `json:"segments,omitempty"`
29+
Keywords []string `json:"keywords,omitempty"`
30+
KeyValues map[string][]string `json:"kv,omitempty"`
31+
AdUnitMatchingLabel []string `json:"auml,omitempty"`
2732
}
2833

2934
type extDeviceAdnuntius struct {

adapters/adnuntius/adnuntius_utils.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,27 @@ func generateAdUnit(imp openrtb2.Imp, adnuntiusExt openrtb_ext.ImpExtAdnunitus,
191191
if adnuntiusExt.MaxDeals > 0 {
192192
adUnit.MaxDeals = adnuntiusExt.MaxDeals
193193
}
194+
195+
if adnuntiusExt.Targeting.Category != nil {
196+
adUnit.Category = adnuntiusExt.Targeting.Category
197+
}
198+
199+
if adnuntiusExt.Targeting.Segments != nil {
200+
adUnit.Segments = adnuntiusExt.Targeting.Segments
201+
}
202+
203+
if adnuntiusExt.Targeting.Keywords != nil {
204+
adUnit.Keywords = adnuntiusExt.Targeting.Keywords
205+
}
206+
207+
if adnuntiusExt.Targeting.KeyValues != nil {
208+
adUnit.KeyValues = adnuntiusExt.Targeting.KeyValues
209+
}
210+
211+
if adnuntiusExt.Targeting.AdUnitMatchingLabel != nil {
212+
adUnit.AdUnitMatchingLabel = adnuntiusExt.Targeting.AdUnitMatchingLabel
213+
}
214+
194215
return adUnit
195216
}
196217

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"mockBidRequest": {
3+
"id": "test-request-id",
4+
"user": {
5+
"id": "1kjh3429kjh295jkl"
6+
},
7+
"imp": [
8+
{
9+
"id": "test-imp-id",
10+
"banner": {
11+
"format": [
12+
{
13+
"w": 300,
14+
"h": 250
15+
}
16+
]
17+
},
18+
"ext": {
19+
"bidder": {
20+
"auId": "123",
21+
"targeting": {
22+
"c": ["automotive", "tech"],
23+
"segments": ["segment1", "segment2"],
24+
"keywords": ["car", "tech", "mobile"],
25+
"kv": {
26+
"brand": ["toyota", "honda"],
27+
"price": ["10000", "20000"]
28+
},
29+
"auml": ["premium", "standard"]
30+
}
31+
}
32+
}
33+
}
34+
]
35+
},
36+
"httpCalls": [
37+
{
38+
"expectedRequest": {
39+
"uri": "http://whatever.url?format=prebidServer&tzo=0",
40+
"body": {
41+
"adUnits": [
42+
{
43+
"auId": "123",
44+
"targetId": "123-test-imp-id:banner",
45+
"nativeRequest": {},
46+
"dimensions": [[300,250]],
47+
"c": ["automotive", "tech"],
48+
"segments": ["segment1", "segment2"],
49+
"keywords": ["car", "tech", "mobile"],
50+
"kv": {
51+
"brand": ["toyota", "honda"],
52+
"price": ["10000", "20000"]
53+
},
54+
"auml": ["premium", "standard"]
55+
}
56+
],
57+
"metaData": {
58+
"usi": "1kjh3429kjh295jkl"
59+
},
60+
"context": "unknown"
61+
},
62+
"impIDs":["test-imp-id"]
63+
},
64+
"mockResponse": {
65+
"status": 200,
66+
"body": {
67+
"adUnits": [
68+
{
69+
"auId": "0000000000000123",
70+
"targetId": "123-test-imp-id:banner",
71+
"matchedAdCount": 1,
72+
"html": "<ADCODE>",
73+
"responseId": "adn-rsp-900646517",
74+
"ads": [
75+
{
76+
"destinationUrls": {
77+
"url": "http://www.google.com"
78+
},
79+
"advertiserDomains": ["google.com"],
80+
"bid": {
81+
"amount": 20.0,
82+
"currency": "NOK"
83+
},
84+
"adId": "adn-id-1559784094",
85+
"creativeWidth": "300",
86+
"creativeHeight": "250",
87+
"creativeId": "jn9hpzvlsf8cpdmm",
88+
"lineItemId": "q7y9qm5b0xt9htrv"
89+
}
90+
]
91+
}
92+
]
93+
}
94+
}
95+
}
96+
],
97+
"expectedBidResponses": [
98+
{
99+
"bids": [
100+
{
101+
"bid": {
102+
"id": "adn-id-1559784094",
103+
"impid": "test-imp-id",
104+
"price": 20000,
105+
"adm": "<ADCODE>",
106+
"adid": "adn-id-1559784094",
107+
"adomain": [
108+
"google.com"
109+
],
110+
"cid": "q7y9qm5b0xt9htrv",
111+
"crid": "jn9hpzvlsf8cpdmm",
112+
"mtype": 1,
113+
"w": 300,
114+
"h": 250
115+
},
116+
"type": "banner"
117+
}
118+
],
119+
"currency": "NOK"
120+
}
121+
]
122+
}
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
package boldwin_rapid
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"text/template"
7+
8+
"net/http"
9+
10+
"github.com/prebid/openrtb/v20/openrtb2"
11+
"github.com/prebid/prebid-server/v3/adapters"
12+
"github.com/prebid/prebid-server/v3/config"
13+
"github.com/prebid/prebid-server/v3/macros"
14+
"github.com/prebid/prebid-server/v3/openrtb_ext"
15+
"github.com/prebid/prebid-server/v3/util/jsonutil"
16+
)
17+
18+
type adapter struct {
19+
endpoint *template.Template
20+
}
21+
22+
func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) {
23+
endpointTemplate, err := template.New("endpointTemplate").Parse(config.Endpoint)
24+
if err != nil {
25+
return nil, fmt.Errorf("unable to parse endpoint template: %v", err)
26+
}
27+
28+
bidder := &adapter{
29+
endpoint: endpointTemplate,
30+
}
31+
32+
return bidder, nil
33+
}
34+
35+
func (a *adapter) buildEndpointURL(boldwinExt openrtb_ext.ImpExtBoldwinRapid) (string, error) {
36+
endpointParams := macros.EndpointTemplateParams{
37+
PublisherID: boldwinExt.Pid,
38+
PlacementID: boldwinExt.Tid,
39+
}
40+
41+
return macros.ResolveMacros(a.endpoint, endpointParams)
42+
}
43+
44+
func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
45+
var adapterRequests []*adapters.RequestData
46+
47+
reqCopy := *request
48+
headers := a.getHeaders(request)
49+
50+
for _, imp := range request.Imp {
51+
// Create a new request with just this impression
52+
reqCopy.Imp = []openrtb2.Imp{imp}
53+
54+
var bidderExt adapters.ExtImpBidder
55+
var boldwinExt openrtb_ext.ImpExtBoldwinRapid
56+
57+
// Use the current impression's Ext
58+
if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil {
59+
return nil, []error{err}
60+
}
61+
62+
if err := jsonutil.Unmarshal(bidderExt.Bidder, &boldwinExt); err != nil {
63+
return nil, []error{err}
64+
}
65+
66+
endpoint, err := a.buildEndpointURL(boldwinExt)
67+
if err != nil {
68+
return nil, []error{err}
69+
}
70+
71+
adapterReq, err := a.makeRequest(&reqCopy, endpoint, headers)
72+
if err != nil {
73+
return nil, []error{err}
74+
}
75+
76+
if adapterReq != nil {
77+
adapterRequests = append(adapterRequests, adapterReq)
78+
}
79+
}
80+
81+
return adapterRequests, nil
82+
}
83+
84+
func (a *adapter) getHeaders(request *openrtb2.BidRequest) http.Header {
85+
headers := http.Header{}
86+
headers.Add("Content-Type", "application/json;charset=utf-8")
87+
headers.Add("Accept", "application/json")
88+
headers.Add("x-openrtb-version", "2.5")
89+
headers.Add("Host", "rtb.beardfleet.com") // required header for the request
90+
91+
if request.Device != nil {
92+
if request.Device.UA != "" {
93+
headers.Add("User-Agent", request.Device.UA)
94+
}
95+
96+
if len(request.Device.IPv6) > 0 {
97+
headers.Set("X-Forwarded-For", request.Device.IPv6)
98+
}
99+
100+
if len(request.Device.IP) > 0 {
101+
headers.Set("X-Forwarded-For", request.Device.IP)
102+
headers.Add("IP", request.Device.IP)
103+
}
104+
}
105+
106+
return headers
107+
}
108+
109+
func (a *adapter) makeRequest(request *openrtb2.BidRequest, endpoint string, headers http.Header) (*adapters.RequestData, error) {
110+
reqJSON, err := json.Marshal(request)
111+
if err != nil {
112+
return nil, fmt.Errorf("failed to marshal request: %w", err)
113+
}
114+
115+
return &adapters.RequestData{
116+
Method: "POST",
117+
Uri: endpoint,
118+
Body: reqJSON,
119+
Headers: headers,
120+
ImpIDs: openrtb_ext.GetImpIDs(request.Imp),
121+
}, nil
122+
}
123+
124+
func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
125+
if adapters.IsResponseStatusCodeNoContent(responseData) {
126+
return nil, nil
127+
}
128+
129+
err := adapters.CheckResponseStatusCodeForErrors(responseData)
130+
if err != nil {
131+
return nil, []error{err}
132+
}
133+
134+
var response openrtb2.BidResponse
135+
if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil {
136+
return nil, []error{err}
137+
}
138+
139+
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))
140+
if response.Cur != "" {
141+
bidResponse.Currency = response.Cur
142+
}
143+
144+
for _, seatBid := range response.SeatBid {
145+
for i := range seatBid.Bid {
146+
bidType, err := getBidMediaType(&seatBid.Bid[i])
147+
if err != nil {
148+
return nil, []error{err}
149+
}
150+
151+
b := &adapters.TypedBid{
152+
Bid: &seatBid.Bid[i],
153+
BidType: bidType,
154+
}
155+
bidResponse.Bids = append(bidResponse.Bids, b)
156+
}
157+
}
158+
return bidResponse, nil
159+
}
160+
161+
func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
162+
switch bid.MType {
163+
case openrtb2.MarkupBanner:
164+
return openrtb_ext.BidTypeBanner, nil
165+
case openrtb2.MarkupVideo:
166+
return openrtb_ext.BidTypeVideo, nil
167+
case openrtb2.MarkupNative:
168+
return openrtb_ext.BidTypeNative, nil
169+
default:
170+
return "", fmt.Errorf("Unable to fetch mediaType in multi-format: %s", bid.ImpID)
171+
}
172+
}

0 commit comments

Comments
 (0)