Skip to content
Open
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
31 changes: 17 additions & 14 deletions adapters/stroeerCore/stroeercore.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ type bidResponse struct {
Ad string `json:"ad"`
CrID string `json:"crid"`
Mtype string `json:"mtype"`
DSA json.RawMessage `json:"dsa"`
ADomain []string `json:"adomain,omitempty"`
}

type bidExt struct {
DSA json.RawMessage `json:"dsa,omitempty"`
Ext json.RawMessage `json:"ext,omitempty"`
// Deprecated: The dsa will move to the bid response's ext.
DSA json.RawMessage `json:"dsa"`
}

func (b *bidResponse) resolveMediaType() (mt openrtb2.MarkupType, bt openrtb_ext.BidType, err error) {
Expand Down Expand Up @@ -88,15 +86,7 @@ func (a *adapter) MakeBids(bidRequest *openrtb2.BidRequest, requestData *adapter
CrID: bid.CrID,
MType: markupType,
ADomain: bid.ADomain,
}

if bid.DSA != nil {
dsaJson, err := json.Marshal(bidExt{bid.DSA})
if err != nil {
errors = append(errors, err)
} else {
openRtbBid.Ext = dsaJson
}
Ext: getBidExt(bid),
}

bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{
Expand All @@ -108,6 +98,19 @@ func (a *adapter) MakeBids(bidRequest *openrtb2.BidRequest, requestData *adapter
return bidderResponse, errors
}

func getBidExt(bid bidResponse) json.RawMessage {
if bid.DSA == nil {
return bid.Ext
}
extMap := map[string]json.RawMessage{}
if bid.Ext != nil {
_ = jsonutil.Unmarshal(bid.Ext, &extMap)
}
extMap["dsa"] = bid.DSA
ext, _ := json.Marshal(extMap)
return ext
}

func (a *adapter) MakeRequests(bidRequest *openrtb2.BidRequest, extraRequestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
var errors []error

Expand Down
207 changes: 207 additions & 0 deletions adapters/stroeerCore/stroeercoretest/exemplary/bid-ext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
{
"mockBidRequest": {
"id": "auction-id",
"cur": [
"EUR"
],
"imp": [
{
"id": "1",
"banner": {
"format": [
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"sid": "123456"
}
}
}
],
"device": {
"ip": "123.123.123.123"
},
"site": {
"domain": "www.publisher.com",
"page": "http://www.publisher.com/some/path"
},
"user": {
"buyeruid": "test-buyer-user-id"
},
"regs": {
"ext": {
"dsa": {
"dsarequired": 3,
"pubrender": 0,
"datatopub": 2,
"transparency": [
{
"domain": "example-platform.com",
"dsaparams": [
1
]
},
{
"domain": "example-ssp.com",
"dsaparams": [
1,
2
]
}
]
}
}
}
},
"httpCalls": [
{
"expectedRequest": {
"headers": {
"Accept": [
"application/json"
],
"Content-Type": [
"application/json;charset=utf-8"
]
},
"uri": "http://localhost/s2sdsh",
"body": {
"id": "auction-id",
"cur": [
"EUR"
],
"imp": [
{
"id": "1",
"tagid": "123456",
"banner": {
"format": [
{
"w": 300,
"h": 600
}
]
},
"ext": {
"bidder": {
"sid": "123456"
}
}
}
],
"device": {
"ip": "123.123.123.123"
},
"site": {
"domain": "www.publisher.com",
"page": "http://www.publisher.com/some/path"
},
"user": {
"buyeruid": "test-buyer-user-id"
},
"regs": {
"ext": {
"dsa": {
"dsarequired": 3,
"pubrender": 0,
"datatopub": 2,
"transparency": [
{
"domain": "example-platform.com",
"dsaparams": [
1
]
},
{
"domain": "example-ssp.com",
"dsaparams": [
1,
2
]
}
]
}
}
}
},
"impIDs":["1"]
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-request-id",
"bids": [
{
"id": "1829273982920-01",
"bidId": "1",
"cpm": 2,
"width": 300,
"height": 600,
"ad": "advert",
"crid": "wasd",
"mtype": "banner",
"ext": {
"other": "thing",
"dsa": {
"behalf": "Advertiser A",
"paid": "Advertiser B",
"transparency": [
{
"domain": "example-domain.com",
"dsaparams": [
1,
2
]
}
],
"adrender": 1
}
}
}
]
}
}
}
],
"expectedBidResponses": [
{
"currency": "EUR",
"bids": [
{
"bid": {
"id": "1829273982920-01",
"impid": "1",
"price": 2,
"adm": "advert",
"w": 300,
"h": 600,
"crid": "wasd",
"mtype": 1,
"ext": {
"other": "thing",
"dsa": {
"behalf": "Advertiser A",
"paid": "Advertiser B",
"transparency": [
{
"domain": "example-domain.com",
"dsaparams": [
1,
2
]
}
],
"adrender": 1
}
}
},
"type": "banner"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
}
],
"adrender": 1
},
"ext": {
"something": "else"
}
}
]
Expand Down Expand Up @@ -192,7 +195,8 @@
}
],
"adrender": 1
}
},
"something": "else"
}
},
"type": "banner"
Expand Down
Loading