Skip to content

Commit

Permalink
add some supplemental
Browse files Browse the repository at this point in the history
  • Loading branch information
sambaiz committed Apr 24, 2020
1 parent 421e681 commit e0ae3af
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
8 changes: 6 additions & 2 deletions adapters/aja/aja.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type AJAAdapter struct {

func (a *AJAAdapter) MakeRequests(bidReq *openrtb.BidRequest, extraInfo *adapters.ExtraRequestInfo) (adapterReqs []*adapters.RequestData, errs []error) {
// split imps by tagid
tagIDs := []string{}
impsByTagID := map[string][]openrtb.Imp{}
for _, imp := range bidReq.Imp {
extAJA, err := parseExtAJA(imp)
Expand All @@ -25,12 +26,15 @@ func (a *AJAAdapter) MakeRequests(bidReq *openrtb.BidRequest, extraInfo *adapter
}
imp.TagID = extAJA.AdSpotID
imp.Ext = nil
if _, ok := impsByTagID[imp.TagID]; !ok {
tagIDs = append(tagIDs, imp.TagID)
}
impsByTagID[imp.TagID] = append(impsByTagID[imp.TagID], imp)
}

req := *bidReq
for _, imps := range impsByTagID {
req.Imp = imps
for _, tagID := range tagIDs {
req.Imp = impsByTagID[tagID]
body, err := json.Marshal(req)
if err != nil {
errs = append(errs, err)
Expand Down
36 changes: 36 additions & 0 deletions adapters/aja/ajatest/supplemental/invalid-ext-bidder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"mockBidRequest": {
"id": "test-req-id",
"imp": [
{
"id": "test-imp-id",
"video": {
"mimes": ["video/mp4"],
"w": 640,
"h": 480
},
"ext": {
"bidder": {
"asi": 111
}
}
}
],
"user": {
"buyeruid": "test-uid"
},
"tmax": 500
},

"httpCalls": [],

"expectedBidResponses": [],

"expectedMakeRequestsErrors": [
{
"value": "Failed to unmarshal ext.bidder impID: test-imp-id err: json: cannot unmarshal number into Go struct field ExtImpAJA.asi of type string",
"comparison": "literal"
}

]
}
34 changes: 34 additions & 0 deletions adapters/aja/ajatest/supplemental/invalid-ext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"mockBidRequest": {
"id": "test-req-id",
"imp": [
{
"id": "test-imp-id",
"video": {
"mimes": ["video/mp4"],
"w": 640,
"h": 480
},
"ext": {
"bidder": 111
}
}
],
"user": {
"buyeruid": "test-uid"
},
"tmax": 500
},

"httpCalls": [],

"expectedBidResponses": [],

"expectedMakeRequestsErrors": [
{
"value": "Failed to unmarshal ext.bidder impID: test-imp-id err: json: cannot unmarshal number into Go value of type openrtb_ext.ExtImpAJA",
"comparison": "literal"
}

]
}

0 comments on commit e0ae3af

Please sign in to comment.