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

Stroeercore: Support DSA #3495

Merged
merged 1 commit into from
Feb 22, 2024
Merged
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
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure if you would like to continue if there is json Marshal error here? If not, then you need to continue in your for loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm sure. The idea is to keep the bid and let upstream decide what to do with it.

} 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"
}
]
}
]
}
Loading