Skip to content

Commit

Permalink
Revert "RTBHouse: native support (#3212)" (#3271)
Browse files Browse the repository at this point in the history
This reverts commit 2540dd8.
  • Loading branch information
bsardo authored Oct 30, 2023
1 parent 3834c22 commit 72463be
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 1,481 deletions.
65 changes: 5 additions & 60 deletions adapters/rtbhouse/rtbhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package rtbhouse

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

"github.com/buger/jsonparser"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/v2/adapters"
"github.com/prebid/prebid-server/v2/config"
Expand Down Expand Up @@ -51,12 +49,9 @@ func (adapter *RTBHouseAdapter) MakeRequests(
if err != nil {
return nil, []error{err}
}
if rtbhouseExt.BidFloor > 0 {
if rtbhouseExt.BidFloor > 0 && len(reqCopy.Cur) > 0 {
bidFloorCur = reqCopy.Cur[0]
bidFloor = rtbhouseExt.BidFloor
bidFloorCur = BidderCurrency
if len(reqCopy.Cur) > 0 {
bidFloorCur = reqCopy.Cur[0]
}
}
}

Expand Down Expand Up @@ -161,63 +156,13 @@ func (adapter *RTBHouseAdapter) MakeBids(
for _, seatBid := range openRTBBidderResponse.SeatBid {
for _, bid := range seatBid.Bid {
bid := bid // pin! -> https://github.com/kyoh86/scopelint#whats-this
bidType, err := getMediaTypeForBid(bid)
if err != nil {
errs = append(errs, err)
continue
} else {
typedBid = &adapters.TypedBid{
Bid: &bid,
BidType: bidType,
}

// for native bid responses fix Adm field
if typedBid.BidType == openrtb_ext.BidTypeNative {
bid.AdM, err = getNativeAdm(bid.AdM)
if err != nil {
errs = append(errs, err)
continue
}
}

bidderResponse.Bids = append(bidderResponse.Bids, typedBid)
}
typedBid = &adapters.TypedBid{Bid: &bid, BidType: "banner"}
bidderResponse.Bids = append(bidderResponse.Bids, typedBid)
}
}

bidderResponse.Currency = BidderCurrency

return bidderResponse, errs

}

func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", fmt.Errorf("unrecognized bid type in response from rtbhouse for bid %s", bid.ImpID)
}
}

func getNativeAdm(adm string) (string, error) {
nativeAdm := make(map[string]interface{})
err := json.Unmarshal([]byte(adm), &nativeAdm)
if err != nil {
return adm, errors.New("unable to unmarshal native adm")
}

// move bid.adm.native to bid.adm
if _, ok := nativeAdm["native"]; ok {
//using jsonparser to avoid marshaling, encode escape, etc.
value, dataType, _, err := jsonparser.Get([]byte(adm), string(openrtb_ext.BidTypeNative))
if err != nil || dataType != jsonparser.Object {
return adm, errors.New("unable to get native adm")
}
adm = string(value)
}
return bidderResponse, nil

return adm, nil
}

This file was deleted.

133 changes: 0 additions & 133 deletions adapters/rtbhouse/rtbhousetest/exemplary/bidfloor-as-bidder-param.json

This file was deleted.

Loading

0 comments on commit 72463be

Please sign in to comment.