Skip to content

Commit

Permalink
Stroeercore: support DSA (#3495)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwatson committed Feb 22, 2024
1 parent 5900d36 commit 33b466e
Show file tree
Hide file tree
Showing 2 changed files with 225 additions and 9 deletions.
32 changes: 23 additions & 9 deletions adapters/stroeerCore/stroeercore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ type response struct {
}

type bidResponse struct {
ID string `json:"id"`
BidID string `json:"bidId"`
CPM float64 `json:"cpm"`
Width int64 `json:"width"`
Height int64 `json:"height"`
Ad string `json:"ad"`
CrID string `json:"crid"`
Mtype string `json:"mtype"`
ID string `json:"id"`
BidID string `json:"bidId"`
CPM float64 `json:"cpm"`
Width int64 `json:"width"`
Height int64 `json:"height"`
Ad string `json:"ad"`
CrID string `json:"crid"`
Mtype string `json:"mtype"`
DSA json.RawMessage `json:"dsa"`
}

func (b bidResponse) resolveMediaType() (mt openrtb2.MarkupType, bt openrtb_ext.BidType, err error) {
type bidExt struct {
DSA json.RawMessage `json:"dsa,omitempty"`
}

func (b *bidResponse) resolveMediaType() (mt openrtb2.MarkupType, bt openrtb_ext.BidType, err error) {
switch b.Mtype {
case "banner":
return openrtb2.MarkupBanner, openrtb_ext.BidTypeBanner, nil
Expand Down Expand Up @@ -82,6 +87,15 @@ func (a *adapter) MakeBids(bidRequest *openrtb2.BidRequest, requestData *adapter
MType: markupType,
}

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

bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{
Bid: &openRtbBid,
BidType: bidType,
Expand Down
202 changes: 202 additions & 0 deletions adapters/stroeerCore/stroeercoretest/exemplary/dsa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
{
"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
]
}
]
}
}
}
}
},
"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",
"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": {
"dsa": {
"behalf": "Advertiser A",
"paid": "Advertiser B",
"transparency": [
{
"domain": "example-domain.com",
"dsaparams": [
1,
2
]
}
],
"adrender": 1
}
}
},
"type": "banner"
}
]
}
]
}

0 comments on commit 33b466e

Please sign in to comment.