Skip to content

Commit

Permalink
remove mediaType determination based on impression Id.
Browse files Browse the repository at this point in the history
  • Loading branch information
product-trustedstack committed Apr 18, 2024
1 parent 40c8bb8 commit 3ddde18
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 600 deletions.
27 changes: 4 additions & 23 deletions adapters/trustedstack/trustedstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,12 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co

func getMediaTypeForImp(bid *openrtb2.Bid, imps []openrtb2.Imp) (openrtb_ext.BidType, error) {
mediaType, err := getBidMediaTypeFromMtype(bid)
if err == nil {
return mediaType, nil
}

for _, imp := range imps {
if imp.ID == bid.ImpID {
switch {
case imp.Banner != nil && imp.Video == nil && imp.Audio == nil && imp.Native == nil:
mediaType = openrtb_ext.BidTypeBanner
case imp.Banner == nil && imp.Video != nil && imp.Audio == nil && imp.Native == nil:
mediaType = openrtb_ext.BidTypeVideo
case imp.Banner == nil && imp.Video == nil && imp.Audio != nil && imp.Native == nil:
mediaType = openrtb_ext.BidTypeAudio
case imp.Banner == nil && imp.Video == nil && imp.Audio == nil && imp.Native != nil:
mediaType = openrtb_ext.BidTypeNative
}
if err != nil {
return "", &errortypes.BadInput{
Message: err.Error(),
}
}

if mediaType != "" {
return mediaType, nil
}
return "", &errortypes.BadInput{
Message: fmt.Sprintf("Failed to find impression \"%s\"", bid.ImpID),
}
return mediaType, nil
}

func getBidMediaTypeFromMtype(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"h": 50,
"w": 320
"w": 320,
"mtype": 1
}
]
}
Expand All @@ -123,7 +124,8 @@
"adm": "some-test-ad",
"crid": "test-crid",
"w": 320,
"h": 50
"h": 50,
"mtype": 1
},
"type": "banner"
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"impid": "1",
"price": 2.50,
"adm": "some-test-ad",
"crid": "test-crid"
"crid": "test-crid",
"mtype": 3
}
]
}
Expand All @@ -79,7 +80,8 @@
"impid": "1",
"price": 2.50,
"adm": "some-test-ad",
"crid": "test-crid"
"crid": "test-crid",
"mtype": 3
},
"type": "audio"
}
Expand Down

This file was deleted.

Loading

0 comments on commit 3ddde18

Please sign in to comment.