Skip to content

Commit fe211a9

Browse files
authored
Remove /auction Endpoint (prebid#2033)
1 parent 8c19d5d commit fe211a9

87 files changed

Lines changed: 107 additions & 10648 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.

adapters/adform/adform.go

Lines changed: 3 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,27 @@ package adform
22

33
import (
44
"bytes"
5-
"context"
65
"encoding/base64"
76
"encoding/json"
87
"errors"
98
"fmt"
10-
"io/ioutil"
119
"net/http"
1210
"net/url"
1311
"strconv"
1412
"strings"
1513

16-
"github.com/buger/jsonparser"
17-
"github.com/mxmCherry/openrtb/v15/openrtb2"
1814
"github.com/prebid/prebid-server/adapters"
1915
"github.com/prebid/prebid-server/config"
2016
"github.com/prebid/prebid-server/errortypes"
2117
"github.com/prebid/prebid-server/openrtb_ext"
22-
"github.com/prebid/prebid-server/pbs"
23-
"golang.org/x/net/context/ctxhttp"
18+
19+
"github.com/buger/jsonparser"
20+
"github.com/mxmCherry/openrtb/v15/openrtb2"
2421
)
2522

2623
const version = "0.1.3"
2724

2825
type AdformAdapter struct {
29-
http *adapters.HTTPAdapter
3026
URL *url.URL
3127
version string
3228
}
@@ -100,155 +96,6 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters
10096
return bidder, nil
10197
}
10298

103-
// used for cookies and such
104-
func (a *AdformAdapter) Name() string {
105-
return "adform"
106-
}
107-
108-
func (a *AdformAdapter) SkipNoCookies() bool {
109-
return false
110-
}
111-
112-
func (a *AdformAdapter) Call(ctx context.Context, request *pbs.PBSRequest, bidder *pbs.PBSBidder) (pbs.PBSBidSlice, error) {
113-
adformRequest, err := pbsRequestToAdformRequest(a, request, bidder)
114-
if err != nil {
115-
return nil, err
116-
}
117-
118-
uri := adformRequest.buildAdformUrl(a)
119-
120-
debug := &pbs.BidderDebug{RequestURI: uri}
121-
if request.IsDebug {
122-
bidder.Debug = append(bidder.Debug, debug)
123-
}
124-
125-
httpRequest, err := http.NewRequest("GET", uri, nil)
126-
if err != nil {
127-
return nil, err
128-
}
129-
130-
httpRequest.Header = adformRequest.buildAdformHeaders(a)
131-
132-
response, err := ctxhttp.Do(ctx, a.http.Client, httpRequest)
133-
if err != nil {
134-
return nil, err
135-
}
136-
137-
debug.StatusCode = response.StatusCode
138-
139-
if response.StatusCode == 204 {
140-
return nil, nil
141-
}
142-
143-
defer response.Body.Close()
144-
body, err := ioutil.ReadAll(response.Body)
145-
if err != nil {
146-
return nil, err
147-
}
148-
responseBody := string(body)
149-
150-
if response.StatusCode == http.StatusBadRequest {
151-
return nil, &errortypes.BadInput{
152-
Message: fmt.Sprintf("HTTP status %d; body: %s", response.StatusCode, responseBody),
153-
}
154-
}
155-
156-
if response.StatusCode != 200 {
157-
return nil, &errortypes.BadServerResponse{
158-
Message: fmt.Sprintf("HTTP status %d; body: %s", response.StatusCode, responseBody),
159-
}
160-
}
161-
162-
if request.IsDebug {
163-
debug.ResponseBody = responseBody
164-
}
165-
166-
adformBids, err := parseAdformBids(body)
167-
if err != nil {
168-
return nil, err
169-
}
170-
171-
bids := toPBSBidSlice(adformBids, adformRequest)
172-
173-
return bids, nil
174-
}
175-
176-
func pbsRequestToAdformRequest(a *AdformAdapter, request *pbs.PBSRequest, bidder *pbs.PBSBidder) (*adformRequest, error) {
177-
adUnits := make([]*adformAdUnit, 0, len(bidder.AdUnits))
178-
for _, adUnit := range bidder.AdUnits {
179-
var adformAdUnit adformAdUnit
180-
if err := json.Unmarshal(adUnit.Params, &adformAdUnit); err != nil {
181-
return nil, err
182-
}
183-
mid, err := adformAdUnit.MasterTagId.Int64()
184-
if err != nil {
185-
return nil, &errortypes.BadInput{
186-
Message: err.Error(),
187-
}
188-
}
189-
if mid <= 0 {
190-
return nil, &errortypes.BadInput{
191-
Message: fmt.Sprintf("master tag(placement) id is invalid=%s", adformAdUnit.MasterTagId),
192-
}
193-
}
194-
adformAdUnit.bidId = adUnit.BidID
195-
adformAdUnit.adUnitCode = adUnit.Code
196-
adUnits = append(adUnits, &adformAdUnit)
197-
}
198-
199-
userId, _, _ := request.Cookie.GetUID(a.Name())
200-
201-
gdprApplies := request.ParseGDPR()
202-
if gdprApplies != "0" && gdprApplies != "1" {
203-
gdprApplies = ""
204-
}
205-
consent := request.ParseConsent()
206-
207-
return &adformRequest{
208-
adUnits: adUnits,
209-
ip: request.Device.IP,
210-
advertisingId: request.Device.IFA,
211-
userAgent: request.Device.UA,
212-
bidderCode: bidder.BidderCode,
213-
isSecure: request.Secure == 1,
214-
referer: request.Url,
215-
userId: userId,
216-
tid: request.Tid,
217-
gdprApplies: gdprApplies,
218-
consent: consent,
219-
currency: defaultCurrency,
220-
}, nil
221-
}
222-
223-
func toPBSBidSlice(adformBids []*adformBid, r *adformRequest) pbs.PBSBidSlice {
224-
bids := make(pbs.PBSBidSlice, 0)
225-
226-
for i, bid := range adformBids {
227-
adm, bidType := getAdAndType(bid)
228-
if adm == "" {
229-
continue
230-
}
231-
pbsBid := pbs.PBSBid{
232-
BidID: r.adUnits[i].bidId,
233-
AdUnitCode: r.adUnits[i].adUnitCode,
234-
BidderCode: r.bidderCode,
235-
Price: bid.Price,
236-
Adm: adm,
237-
Width: int64(bid.Width),
238-
Height: int64(bid.Height),
239-
DealId: bid.DealId,
240-
Creative_id: bid.CreativeId,
241-
CreativeMediaType: string(bidType),
242-
}
243-
244-
bids = append(bids, &pbsBid)
245-
}
246-
247-
return bids
248-
}
249-
250-
// COMMON
251-
25299
func (r *adformRequest) buildAdformUrl(a *AdformAdapter) string {
253100
parameters := url.Values{}
254101

@@ -359,20 +206,6 @@ func parseAdformBids(response []byte) ([]*adformBid, error) {
359206

360207
// BIDDER Interface
361208

362-
func NewAdformLegacyAdapter(httpConfig *adapters.HTTPAdapterConfig, endpointURL string) *AdformAdapter {
363-
var uriObj *url.URL
364-
uriObj, err := url.Parse(endpointURL)
365-
if err != nil {
366-
panic(fmt.Sprintf("Incorrect Adform request url %s, check the configuration, please.", endpointURL))
367-
}
368-
369-
return &AdformAdapter{
370-
http: adapters.NewHTTPAdapter(httpConfig),
371-
URL: uriObj,
372-
version: version,
373-
}
374-
}
375-
376209
func (a *AdformAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
377210
adformRequest, errors := openRtbToAdformRequest(request)
378211
if len(adformRequest.adUnits) == 0 {

0 commit comments

Comments
 (0)