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

Update OpenRTB Library #1733

Merged
merged 14 commits into from
Mar 26, 2021
20 changes: 10 additions & 10 deletions adapters/33across/33across.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"net/http"

"github.com/mxmCherry/openrtb"
"github.com/mxmCherry/openrtb/v14/openrtb2"
SyntaxNode marked this conversation as resolved.
Show resolved Hide resolved
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
Expand Down Expand Up @@ -51,7 +51,7 @@ type bidTtxExt struct {
}

// MakeRequests create the object for TTX Reqeust.
func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
func (a *TtxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
var errs []error
var adapterRequests []*adapters.RequestData

Expand All @@ -77,14 +77,14 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters
return adapterRequests, errs
}

func (a *TtxAdapter) makeRequest(request openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) {
func (a *TtxAdapter) makeRequest(request openrtb2.BidRequest, imp openrtb2.Imp) (*adapters.RequestData, error) {
impCopy, err := makeImps(imp)

if err != nil {
return nil, err
}

request.Imp = []openrtb.Imp{*impCopy}
request.Imp = []openrtb2.Imp{*impCopy}

// Last Step
reqJSON, err := json.Marshal(request)
Expand All @@ -103,7 +103,7 @@ func (a *TtxAdapter) makeRequest(request openrtb.BidRequest, imp openrtb.Imp) (*
}, nil
}

func makeImps(imp openrtb.Imp) (*openrtb.Imp, error) {
func makeImps(imp openrtb2.Imp) (*openrtb2.Imp, error) {
if imp.Banner == nil && imp.Video == nil {
return nil, &errortypes.BadInput{
Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", imp.ID),
Expand Down Expand Up @@ -158,7 +158,7 @@ func makeImps(imp openrtb.Imp) (*openrtb.Imp, error) {
return &imp, nil
}

func makeReqExt(request *openrtb.BidRequest) ([]byte, error) {
func makeReqExt(request *openrtb2.BidRequest) ([]byte, error) {
var reqExt reqExt

if len(request.Ext) > 0 {
Expand All @@ -181,7 +181,7 @@ func makeReqExt(request *openrtb.BidRequest) ([]byte, error) {
}

// MakeBids make the bids for the bid response.
func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
func (a *TtxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if response.StatusCode == http.StatusNoContent {
return nil, nil
}
Expand All @@ -198,7 +198,7 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReque
}}
}

var bidResp openrtb.BidResponse
var bidResp openrtb2.BidResponse

if err := json.Unmarshal(response.Body, &bidResp); err != nil {
return nil, []error{err}
Expand Down Expand Up @@ -227,7 +227,7 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReque

}

func validateVideoParams(video *openrtb.Video, prod string) (*openrtb.Video, error) {
func validateVideoParams(video *openrtb2.Video, prod string) (*openrtb2.Video, error) {
videoCopy := video
if videoCopy.W == 0 ||
videoCopy.H == 0 ||
Expand All @@ -248,7 +248,7 @@ func validateVideoParams(video *openrtb.Video, prod string) (*openrtb.Video, err
videoCopy.Placement = 1

if videoCopy.StartDelay == nil {
videoCopy.StartDelay = openrtb.StartDelay.Ptr(0)
videoCopy.StartDelay = openrtb2.StartDelay.Ptr(0)
}
}

Expand Down
14 changes: 7 additions & 7 deletions adapters/acuityads/acuityads.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"text/template"

"github.com/mxmCherry/openrtb"
"github.com/mxmCherry/openrtb/v14/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
Expand All @@ -31,7 +31,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters
return bidder, nil
}

func getHeaders(request *openrtb.BidRequest) http.Header {
func getHeaders(request *openrtb2.BidRequest) http.Header {
headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
Expand All @@ -55,7 +55,7 @@ func getHeaders(request *openrtb.BidRequest) http.Header {
}

func (a *AcuityAdsAdapter) MakeRequests(
openRTBRequest *openrtb.BidRequest,
openRTBRequest *openrtb2.BidRequest,
reqInfo *adapters.ExtraRequestInfo,
) (
requestsToBidder []*adapters.RequestData,
Expand Down Expand Up @@ -87,7 +87,7 @@ func (a *AcuityAdsAdapter) MakeRequests(
}}, nil
}

func (a *AcuityAdsAdapter) getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtAcuityAds, error) {
func (a *AcuityAdsAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtAcuityAds, error) {
var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return nil, &errortypes.BadInput{
Expand Down Expand Up @@ -136,7 +136,7 @@ func (a *AcuityAdsAdapter) checkResponseStatusCodes(response *adapters.ResponseD
}

func (a *AcuityAdsAdapter) MakeBids(
openRTBRequest *openrtb.BidRequest,
openRTBRequest *openrtb2.BidRequest,
requestToBidder *adapters.RequestData,
bidderRawResponse *adapters.ResponseData,
) (
Expand All @@ -153,7 +153,7 @@ func (a *AcuityAdsAdapter) MakeBids(
}

responseBody := bidderRawResponse.Body
var bidResp openrtb.BidResponse
var bidResp openrtb2.BidResponse
if err := json.Unmarshal(responseBody, &bidResp); err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: "Bad Server Response",
Expand All @@ -178,7 +178,7 @@ func (a *AcuityAdsAdapter) MakeBids(
return bidResponse, nil
}

func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType {
func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType {
mediaType := openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == impId {
Expand Down
10 changes: 5 additions & 5 deletions adapters/adapterstest/adapter_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (

"net/http"

"github.com/mxmCherry/openrtb"
"github.com/mxmCherry/openrtb/v14/openrtb2"
)

// OrtbMockService Represents a scaffolded OpenRTB service.
type OrtbMockService struct {
Server *httptest.Server
LastBidRequest *openrtb.BidRequest
LastBidRequest *openrtb2.BidRequest
LastHttpRequest *http.Request
}

Expand All @@ -30,8 +30,8 @@ func BidOnTags(tags string) map[string]bool {
}

// SampleBid Produces a sample bid based on params given.
func SampleBid(width *uint64, height *uint64, impId string, index int) openrtb.Bid {
return openrtb.Bid{
func SampleBid(width *int64, height *int64, impId string, index int) openrtb2.Bid {
return openrtb2.Bid{
ID: "Bid-123",
ImpID: fmt.Sprintf("div-adunit-%d", index),
Price: 2.1,
Expand Down Expand Up @@ -64,7 +64,7 @@ func VerifyBoolValue(value bool, expected bool, t *testing.T) {
}

// VerifyBannerSize helper function to assert banner size
func VerifyBannerSize(banner *openrtb.Banner, expectedWidth int, expectedHeight int, t *testing.T) {
func VerifyBannerSize(banner *openrtb2.Banner, expectedWidth int, expectedHeight int, t *testing.T) {
VerifyIntValue(int(*(banner.W)), expectedWidth, t)
VerifyIntValue(int(*(banner.H)), expectedHeight, t)
}
6 changes: 3 additions & 3 deletions adapters/adapterstest/test_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"testing"

"github.com/mxmCherry/openrtb"
"github.com/mxmCherry/openrtb/v14/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/yudai/gojsondiff"
"github.com/yudai/gojsondiff/formatter"
Expand Down Expand Up @@ -128,7 +128,7 @@ func runSpec(t *testing.T, filename string, spec *testSpec, bidder adapters.Bidd
}

type testSpec struct {
BidRequest openrtb.BidRequest `json:"mockBidRequest"`
BidRequest openrtb2.BidRequest `json:"mockBidRequest"`
HttpCalls []httpCall `json:"httpCalls"`
BidResponses []expectedBidResponse `json:"expectedBidResponses"`
MakeRequestErrors []testSpecExpectedError `json:"expectedMakeRequestsErrors"`
Expand Down Expand Up @@ -281,7 +281,7 @@ func diffBids(t *testing.T, description string, actual *adapters.TypedBid, expec
}

// diffOrtbBids compares the actual Bid made by the adapter to the expectation from the JSON file.
func diffOrtbBids(t *testing.T, description string, actual *openrtb.Bid, expected json.RawMessage) {
func diffOrtbBids(t *testing.T, description string, actual *openrtb2.Bid, expected json.RawMessage) {
if actual == nil {
t.Errorf("Bidders cannot return nil Bids. %s was nil.", description)
return
Expand Down
31 changes: 15 additions & 16 deletions adapters/adform/adform.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import (
"strconv"
"strings"

"github.com/buger/jsonparser"
"github.com/mxmCherry/openrtb/v14/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"
"github.com/prebid/prebid-server/pbs"

"github.com/buger/jsonparser"
"github.com/mxmCherry/openrtb"
"golang.org/x/net/context/ctxhttp"
)

Expand Down Expand Up @@ -235,8 +234,8 @@ func toPBSBidSlice(adformBids []*adformBid, r *adformRequest) pbs.PBSBidSlice {
BidderCode: r.bidderCode,
Price: bid.Price,
Adm: adm,
Width: bid.Width,
Height: bid.Height,
Width: int64(bid.Width),
Height: int64(bid.Height),
DealId: bid.DealId,
Creative_id: bid.CreativeId,
CreativeMediaType: string(bidType),
Expand Down Expand Up @@ -374,7 +373,7 @@ func NewAdformLegacyAdapter(httpConfig *adapters.HTTPAdapterConfig, endpointURL
}
}

func (a *AdformAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
func (a *AdformAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
adformRequest, errors := openRtbToAdformRequest(request)
if len(adformRequest.adUnits) == 0 {
return nil, errors
Expand All @@ -392,7 +391,7 @@ func (a *AdformAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt
return requests, errors
}

func openRtbToAdformRequest(request *openrtb.BidRequest) (*adformRequest, []error) {
func openRtbToAdformRequest(request *openrtb2.BidRequest) (*adformRequest, []error) {
adUnits := make([]*adformAdUnit, 0, len(request.Imp))
errors := make([]error, 0, len(request.Imp))
secure := false
Expand Down Expand Up @@ -529,35 +528,35 @@ func encodeEids(eids []openrtb_ext.ExtUserEid) string {
return encodedEids
}

func getIPSafely(device *openrtb.Device) string {
func getIPSafely(device *openrtb2.Device) string {
if device == nil {
return ""
}
return device.IP
}

func getIFASafely(device *openrtb.Device) string {
func getIFASafely(device *openrtb2.Device) string {
if device == nil {
return ""
}
return device.IFA
}

func getUASafely(device *openrtb.Device) string {
func getUASafely(device *openrtb2.Device) string {
if device == nil {
return ""
}
return device.UA
}

func getBuyerUIDSafely(user *openrtb.User) string {
func getBuyerUIDSafely(user *openrtb2.User) string {
if user == nil {
return ""
}
return user.BuyerUID
}

func (a *AdformAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
func (a *AdformAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if response.StatusCode == http.StatusNoContent {
return nil, nil
}
Expand All @@ -584,7 +583,7 @@ func (a *AdformAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe
return bidResponse, nil
}

func toOpenRtbBidResponse(adformBids []*adformBid, r *openrtb.BidRequest) *adapters.BidderResponse {
func toOpenRtbBidResponse(adformBids []*adformBid, r *openrtb2.BidRequest) *adapters.BidderResponse {
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adformBids))
currency := bidResponse.Currency

Expand All @@ -598,13 +597,13 @@ func toOpenRtbBidResponse(adformBids []*adformBid, r *openrtb.BidRequest) *adapt
continue
}

openRtbBid := openrtb.Bid{
openRtbBid := openrtb2.Bid{
ID: r.Imp[i].ID,
ImpID: r.Imp[i].ID,
Price: bid.Price,
AdM: adm,
W: bid.Width,
H: bid.Height,
W: int64(bid.Width),
H: int64(bid.Height),
DealID: bid.DealId,
CrID: bid.CreativeId,
}
Expand Down
Loading