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

New Adapter: ResetDigital #3766

Open
wants to merge 174 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
70de190
New Adapter: ResetDigital
bruno-siira Feb 5, 2024
dd48470
Fix to have the a bid forced on testing
bruno-siira Feb 7, 2024
32551fc
Merge branch 'prebid:master' into master
bruno-siira Feb 7, 2024
125124b
Merge branch 'prebid:master' into master
bruno-siira Feb 9, 2024
5c56e12
Test changes
bruno-siira Feb 9, 2024
fe4ff39
Merge branch 'prebid:master' into master
bruno-siira Feb 13, 2024
664614f
Merge branch 'master' of https://github.com/bruno-siira/prebid-server
bruno-siira Feb 13, 2024
0b44384
Merge branch 'prebid:master' into master
bruno-siira Feb 21, 2024
0775c72
Merge branch 'master' of https://github.com/bruno-siira/prebid-server
bruno-siira Feb 26, 2024
20fa856
Add file
bruno-siira Feb 28, 2024
33f4603
Added schema for adapter
bruno-siira Feb 28, 2024
e468217
Merge branch 'prebid:master' into master
bruno-siira Mar 17, 2024
b8ca566
Unused builder removed
bruno-siira Mar 18, 2024
2de7781
Fix to lack of builder
bruno-siira Mar 24, 2024
eb067f7
Change of data on export
bruno-siira Mar 26, 2024
86206d7
no need to include `required` if its empty
bruno-siira Apr 14, 2024
3fc5455
Resolving https://github.com/prebid/prebid-server/pull/3452
BrunoJacinto May 14, 2024
3762676
Merge branch 'prebid:master' into master
bruno-siira Jun 20, 2024
8500d56
New Adapter : MediaGo (#3705)
SylviaF Jun 24, 2024
817afeb
Gitignore changes (#3752)
Enigo Jun 24, 2024
fe55575
OwnAdx: Add cookie sync (#3713)
ownAdx-prebid Jun 25, 2024
9f2caf9
add support for setting seat (bidderCode) override + demand source in…
nickjacob Jun 25, 2024
3295c41
AppNexus: Forward GPID (#3767)
SyntaxNode Jun 26, 2024
2a8483b
IX: save/restore global var in test (#3638)
dmitris Jun 26, 2024
07f3ee2
Nobid: Add iframe sync support (#3732)
redaguermas Jun 27, 2024
057e25d
New Adapter: Сointraffic (#3647)
sergeykcointraffic Jun 28, 2024
09a3dd4
New Adapter: Vidazoo (#3698)
saar120 Jul 1, 2024
8784615
InMobi: include iframe & native for M-Web (#3682)
SiddhantAgrawal Jul 1, 2024
80a90dd
OpenWeb: Adapter Refactor + New Endpoint (#3670)
IgorKulemzin Jul 1, 2024
a907ecb
PulsePoint: Marking cp/ct params to be either String or Int (#3677)
anand-venkatraman Jul 1, 2024
670e1d4
Bizzclick: rename bizzclick to blasto (#3688)
BizzClick Jul 1, 2024
989c565
New Adapter: ResetDigital #3766
bruno-siira Jul 3, 2024
99431ad
New Adapter: Admatic (#3654)
bakicam Jul 3, 2024
39905ed
Fix naming
bruno-siira Jul 5, 2024
4482bc9
Fix naming of Var
bruno-siira Jul 5, 2024
d426e8a
Fix PR New Adapter: ResetDigital #3766
bruno-siira Jul 9, 2024
ac2fc01
Fix New Adapter: ResetDigital #3766
bruno-siira Jul 9, 2024
52a6794
Fix multiple comments
bruno-siira Jul 16, 2024
a1b4451
Criteo: Add support for native (#3709)
MarinaZhuravlevaCriteo Jul 18, 2024
5fefeaa
Smaato: Add DSA support tests (#3749)
tetianaatsmaato Jul 18, 2024
9626103
New tests
bruno-siira Jul 18, 2024
0a3271d
New Adapter: Displayio (#3691)
xdevel Jul 22, 2024
da658e7
CPMStar: add gvlVendorID (#3779)
JoshuaMGoldstein Jul 22, 2024
0f5a1fe
Adprime: add userSync (#3770)
Adprime Jul 22, 2024
f087eea
OpenX: accept incoming string fields to support Prebid.js 9 (#3668)
laurb9 Jul 24, 2024
115f773
New Adapter: bigoad (#3711)
BIGOAds Jul 24, 2024
d1596c8
Smaato: Change server response type (#3734)
Enigo Jul 24, 2024
536821f
Triplelift Native: Mapping tag_code (#3745)
patrickloughrey Jul 24, 2024
dea6cf7
Fix http.StatusBadRequest and non http.StatusOK codes should not be e…
bruno-siira Jul 24, 2024
382f793
ConenctAd Adapter Update (#3715)
rtuschkany Jul 25, 2024
83bce5a
PBS Go: 2024 Doc updates including endpoint and ortb support version …
AaronColbyPrice Jul 25, 2024
55094fe
Fix: Triplelift Native add site.publisher nil check (#3824)
bsardo Jul 29, 2024
466ff83
Smaato: Add DOOH support (#3751)
Enigo Jul 29, 2024
ed3e4a1
Gracefully shutdown analytics module/runner (#3335)
zhongshixi Jul 29, 2024
843a81c
Criteo: Add support for paapi (#3759)
vraybaud Jul 30, 2024
7c92e10
New Adapter: QT (#3696)
qt-io Aug 1, 2024
8b13ebc
consumable adapter - use configured endpoint instead of hardcoded val…
edandavi Aug 5, 2024
c50e264
OpenX: return cat/dur for video bids (#3834)
laurb9 Aug 6, 2024
c3d8379
Adtelligent: ext aid type (#3676)
dkornet-ad Aug 6, 2024
efc1e8b
New Adapter: TheTradeDesk (#3738)
andre-gielow-ttd Aug 6, 2024
e8e2848
SmartHub: add alias FelixAds (#3837)
SmartHubSolutions Aug 6, 2024
804334a
New Adapter: MetaX (#3712)
metax-kehan Aug 6, 2024
dabc386
Playdigo: Add user sync (#3797)
Yanivplaydigo Aug 7, 2024
cba6221
SmartHub: add alias VimayX (#3760)
SmartHubSolutions Aug 8, 2024
211f13a
New Adapter: Filmzie (#3758)
imedvedko Aug 8, 2024
ce331a7
Fix: Aliases Of Bidders With UserSync Supports Declared Only (#3850)
SyntaxNode Aug 8, 2024
4f177ca
New Adapter: MeloZen (#3784)
benben2001 Aug 12, 2024
2a19924
taboola-support-app-in-prebid-server (#3795)
ahmadlob Aug 12, 2024
4d64623
OwnAdx: Bidder param and URL updates (#3813)
ownAdx-prebid Aug 12, 2024
0e9b234
Use format=prebid on adserver requests. (#3846)
antosarho Aug 13, 2024
2606e75
New Module: 51Degrees (#3650)
jwrosewell Aug 16, 2024
5cfe0ae
Not running tests at this momment
bruno-siira Aug 16, 2024
e4bd6d3
ADTS-455 remove video validations (#3842)
gg-natalia Aug 18, 2024
6be7244
Update Vidazoo bidder info for GPP support (#3869)
saar120 Aug 21, 2024
e8509e6
declare support for ORTB 2.6 (#3872)
bretg Aug 21, 2024
d161712
new adapter (#3833)
Pubrise Aug 21, 2024
a556e2d
Fix currency conversion bug. (#3867)
CTMBNara Aug 21, 2024
59a5b07
freewheel-adapter: support 2.6 (#3873)
mwang-sticky Aug 21, 2024
54f8759
Update mobilefuse.yaml to indicate support for OpenRTB 2.6 and GPP (#…
dtbarne Aug 21, 2024
bd85ba4
specifies ortb 2.6 support (#3) (#3876)
nickllerandi Aug 22, 2024
84a8162
PulsePoint: ortb 2.6 version and gpp support (#3874)
anand-venkatraman Aug 22, 2024
8d7117d
Revert "New Module: 51Degrees (#3650)" (#3888)
bsardo Aug 27, 2024
ece8152
Update with help of Xandr Team
bruno-siira Aug 29, 2024
baa553c
Simplify Tests
bruno-siira Aug 29, 2024
4ea0e33
New Adapter: Copper6SSP (#3755)
Copper6SSP Aug 30, 2024
2e2b49f
New Adapter: Escalax (#3798)
escalax Aug 30, 2024
e825553
New Adapter: Oraki (#3839)
BenOraki Aug 30, 2024
f7caea5
OpenX: indicate support for OpenRTB 2.6 (#3879)
bwschmidt Aug 30, 2024
8237f7f
Refactor Bid Splitter Privacy Functions (#3645)
SyntaxNode Sep 3, 2024
ec6a45d
Agma: Allow app.bundle to be used as selector for apps (#3780)
steffenmllr Sep 4, 2024
ecc90bb
PR of functioning version
bruno-siira Sep 10, 2024
6a011ed
Update github.com/rs/cors to v1.11.0 (#3884)
ccorbo Sep 11, 2024
b920cca
Playdigo: Add tcfeu support (#3890)
Yanivplaydigo Sep 11, 2024
e0a21d0
QT: Add tcfeu support (#3892)
qt-io Sep 11, 2024
6cbedf0
Smartx: Declare OpenRTB 2.6 support (#3896)
schubert-sc Sep 11, 2024
7613ff5
Update adapter json test framework to validate BidVideo (#3835)
laurb9 Sep 12, 2024
c02ee8c
Update exchange json tests with correct hb_pb_cat_dur (#3836)
laurb9 Sep 12, 2024
ffdd75f
New Adapter: AdTonos (#3853)
rkaw92 Sep 12, 2024
3e24be7
New Adapter: TGM (#3848)
apykhteyev Sep 13, 2024
640b97c
LemmaDigital: change endpoint (#3862)
lm-ved Sep 16, 2024
3c4527e
Adnuntius: Return DSA in bid response (#3777)
mikael-lundin Sep 18, 2024
905b3a5
Log non bid reasons in bidder framework (#2891)
ShriprasadM Sep 19, 2024
93368cc
ConnectAd: String/int fix (#3925)
rtuschkany Sep 19, 2024
11b6546
Rubicon: Pass PBS host info to XAPI (#3903)
And1sS Sep 23, 2024
4462fce
51degrees module (#3893)
justadreamer Sep 25, 2024
8b1b96e
Add docs build readme (#3930)
bsardo Sep 25, 2024
c42fe53
InMobi: mtype support (#3921)
bkaneyama Sep 25, 2024
53f51a6
GPC: Set extension based on header (#3895)
przemkaczmarek Sep 25, 2024
6c154e0
New Adapter: Streamlyn (#3900)
apykhteyev Sep 25, 2024
0d54a8d
Added Video and removed unwanted data
bruno-siira Sep 29, 2024
f27bcef
New Adapter: Bidmatic (#3731)
dkornet-ad Oct 3, 2024
8689e0d
Sonobi: native and currency conversion support (#3889)
bansawbanchee Oct 7, 2024
d54c3ed
New Adapter: Missena (#3761)
ysfbsf Oct 8, 2024
64584f6
Refactor: Remove getAuctionBidderRequests (#3957)
bsardo Oct 8, 2024
87d4412
Refactor: Move privacy init up (#3958)
bsardo Oct 9, 2024
9bb9b3d
Unruly: Indicate Support for OpenRTB 2.6 (#3984)
bhainesnexxen Oct 15, 2024
c37951a
update yieldmo.yaml to indicate support for ortb 2.6 (#3968)
ym-winston Oct 15, 2024
5fcbbbf
Triplelift: Adding flag for 2.6 support (#3966)
patrickloughrey Oct 15, 2024
cbe9876
enable gzip (#3946)
ikagotso Oct 15, 2024
b56923c
RTB House: Resolve AUCTION_PRICE macro (#3901)
piotrj-rtbh Oct 15, 2024
8134328
Displayio: Make imp.bidfloor optional (#3959)
xdevel Oct 16, 2024
451bc44
BlueSea: Add site capability (#3910)
blueseasx Oct 16, 2024
bcf6491
GumGum: Declare ORTB 2.6 support (#3985)
sindhuja-sridharan Oct 17, 2024
18f6798
Bump Go version to 1.22 in dev containers config (#3983)
sebhtml Oct 22, 2024
03a4abd
Sample: Fix prebid js loading bug on sample html page (#3792)
And1sS Oct 22, 2024
660dba7
created mock test
ogbonnaEmmanuel Oct 25, 2024
a23380f
ImproveDigital: Remove placementKey & addtlconsent parsing (#3728)
ishihanvcs Oct 29, 2024
ddf897c
Update Cookie Sync Chooser Debug Message to match Java (#3558)
AlexBVolcy Oct 29, 2024
1419761
Rename Blacklisted Apps to Blocked Apps (#3620)
SyntaxNode Oct 29, 2024
db2a872
ORTB 2.6: Full support with down convert for 2.5 adapters (#4019)
bsardo Oct 29, 2024
df58baf
Cookie Sync: Use max when limit is 0 (#4022)
bsardo Oct 30, 2024
3907f1a
Remove Default Request Hardcoded Aliases (#4020)
SyntaxNode Oct 30, 2024
5b11f59
Adapters: Update to use jsonutil unmarshal (#4021)
bsardo Oct 30, 2024
5f70f11
delete fake_test.json
ogbonnaEmmanuel Oct 31, 2024
6e150f3
Increment Package Version To v3 (#4029)
SyntaxNode Oct 31, 2024
613317a
Merge pull request #1 from ogbonnaEmmanuel/master
dirk-rd Oct 31, 2024
a083c03
Adding support for audio media type and a corresponding simple-audio.…
dirk-rd Nov 3, 2024
a788661
GumGum: Override the default currency (#3928)
MartinGumGum Nov 4, 2024
bc7caaf
Fix slice append syntax.
dirk-rd Nov 4, 2024
4569e97
Removed zero check for bid response and moved HTTP headers into separ…
dirk-rd Nov 4, 2024
0bc2aeb
Adding test case for missing currency to improve test coverage percen…
dirk-rd Nov 4, 2024
d212d91
Merge pull request #2 from bruno-siira/add-audio
bruno-siira Nov 4, 2024
3403544
PgamSSP: Add currency converter (#3907)
PGAMSSP Nov 4, 2024
cff2442
New Adapter: ResetDigital
bruno-siira Feb 5, 2024
44bee69
Fix to have the a bid forced on testing
bruno-siira Feb 7, 2024
96fde76
Test changes
bruno-siira Feb 9, 2024
6e08b5d
Add file
bruno-siira Feb 28, 2024
ec4005d
Added schema for adapter
bruno-siira Feb 28, 2024
fd3ec0d
Unused builder removed
bruno-siira Mar 18, 2024
8bca6ad
Fix to lack of builder
bruno-siira Mar 24, 2024
278be3f
Change of data on export
bruno-siira Mar 26, 2024
56a77a0
no need to include `required` if its empty
bruno-siira Apr 14, 2024
f0e2574
Resolving https://github.com/prebid/prebid-server/pull/3452
BrunoJacinto May 14, 2024
0e365ce
New Adapter: ResetDigital #3766
bruno-siira Jul 3, 2024
f2d3afc
Fix naming
bruno-siira Jul 5, 2024
d6e24d0
Fix naming of Var
bruno-siira Jul 5, 2024
eceef87
Fix PR New Adapter: ResetDigital #3766
bruno-siira Jul 9, 2024
e86d017
Fix New Adapter: ResetDigital #3766
bruno-siira Jul 9, 2024
baa974f
Fix multiple comments
bruno-siira Jul 16, 2024
73c3fe0
New tests
bruno-siira Jul 18, 2024
246010f
Fix http.StatusBadRequest and non http.StatusOK codes should not be e…
bruno-siira Jul 24, 2024
cff5817
Not running tests at this momment
bruno-siira Aug 16, 2024
5ab5517
Update with help of Xandr Team
bruno-siira Aug 29, 2024
d3df8f2
Simplify Tests
bruno-siira Aug 29, 2024
c1795b8
PR of functioning version
bruno-siira Sep 10, 2024
1665bc9
Added Video and removed unwanted data
bruno-siira Sep 29, 2024
0f6f5b1
created mock test
ogbonnaEmmanuel Oct 25, 2024
27863db
delete fake_test.json
ogbonnaEmmanuel Oct 31, 2024
f0da5d7
Adding support for audio media type and a corresponding simple-audio.…
dirk-rd Nov 3, 2024
6c745fb
Fix slice append syntax.
dirk-rd Nov 4, 2024
56b03f1
Removed zero check for bid response and moved HTTP headers into separ…
dirk-rd Nov 4, 2024
21eecdd
Adding test case for missing currency to improve test coverage percen…
dirk-rd Nov 4, 2024
dcd9dad
COmmit
bruno-siira Nov 4, 2024
2584c6b
Changing the version to V3
bruno-siira Nov 4, 2024
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
307 changes: 307 additions & 0 deletions adapters/resetdigital/resetdigital.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
package resetdigital

import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"text/template"

"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/adapters"
"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/openrtb_ext"
)

// MaximumBids is the maximum number of bids that can be returned by this adapter.
const maxBids = 1

Copy link
Contributor

Choose a reason for hiding this comment

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

maxBids is unused. can remove this var

type adapter struct {
endpoint *template.Template
endpointUri string
}

type resetDigitalRequest struct {
Site resetDigitalSite `json:"site"`
Imps []resetDigitalImp `json:"imps"`
}
type resetDigitalSite struct {
Domain string `json:"domain"`
Referrer string `json:"referrer"`
}
type resetDigitalImp struct {
ForceBid bool `json:"force_bid"`
ZoneID resetDigitalImpZone `json:"zone_id"`
BidID string `json:"bid_id"`
ImpID string `json:"imp_id"`
Ext resetDigitalImpExt `json:"ext"`
MediaTypes resetDigitalMediaTypes `json:"media_types"`
}
type resetDigitalImpZone struct {
PlacementID string `json:"placementId"`
}
type resetDigitalImpExt struct {
Gpid string `json:"gpid"`
}
type resetDigitalMediaTypes struct {
Banner resetDigitalMediaType `json:"banner"`
Video resetDigitalMediaType `json:"video"`
}
type resetDigitalMediaType struct {
Sizes [][]int64 `json:"sizes"`
}

type resetDigitalBidResponse struct {
Bids []resetDigitalBid `json:"bids"`
}
type resetDigitalBid struct {
BidID string `json:"bid_id"`
ImpID string `json:"imp_id"`
CPM float64 `json:"cpm"`
CID string `json:"cid,omitempty"`
CrID string `json:"crid,omitempty"`
AdID string `json:"adid"`
W string `json:"w,omitempty"`
H string `json:"h,omitempty"`
Seat string `json:"seat"`
HTML string `json:"html"`
}

func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) {
template, err := template.New("endpointTemplate").Parse(config.Endpoint)
if err != nil {
return nil, fmt.Errorf("unable to parse endpoint url template: %v", err)
}
bidder := &adapter{
endpoint: template,
}
return bidder, nil
}

func getHeaders(request *openrtb2.BidRequest) http.Header {
headers := http.Header{}

if request != nil && request.Device != nil && request.Site != nil {
addNonEmptyHeaders(&headers, map[string]string{
"Referer": request.Site.Page,
"Accept-Language": request.Device.Language,
"User-Agent": request.Device.UA,
"X-Forwarded-For": request.Device.IP,
"X-Real-Ip": request.Device.IP,
"Content-Type": "application/json;charset=utf-8",
"Accept": "application/json",
})
}
return headers
}

func addNonEmptyHeaders(headers *http.Header, headerValues map[string]string) {
for key, value := range headerValues {
if len(value) > 0 {
headers.Add(key, value)
}
}
}

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

for _, imp := range requestData.Imp {
bidType, err := getBidType(imp)
if err != nil {
errors = append(errors, err)
continue
Comment on lines +120 to +121
Copy link
Contributor

Choose a reason for hiding this comment

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

code path is not covered. should add json tests to improve coverage

}

splittedRequestData, err := processDataFromRequest(requestData, imp, bidType)
if err != nil {
errors = append(errors, err)
continue
Comment on lines +126 to +127
Copy link
Contributor

Choose a reason for hiding this comment

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

code path is not covered. should add json tests to improve coverage

}

requestBody, err := json.Marshal(splittedRequestData)
if err != nil {
errors = append(errors, err)
continue
}

requests = append(requests, &adapters.RequestData{
Method: "POST",
Uri: a.endpointUri,
Body: requestBody,
Headers: getHeaders(requestData),
ImpIDs: []string{imp.ID},
})
}

return requests, errors
}

func processDataFromRequest(requestData *openrtb2.BidRequest, imp openrtb2.Imp, bidType openrtb_ext.BidType) (resetDigitalRequest, error) {
var reqData resetDigitalRequest

if requestData.Site != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to handle App data?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed offline. We do not need to handle app data.

reqData.Site.Domain = requestData.Site.Domain
reqData.Site.Referrer = requestData.Site.Page
}

reqData.Imps = append(reqData.Imps, resetDigitalImp{
BidID: requestData.ID,
ImpID: imp.ID,
})

if bidType == openrtb_ext.BidTypeBanner && imp.Banner != nil {
tempH := *imp.Banner.H
tempW := *imp.Banner.W

if tempH > 0 && tempW > 0 {
reqData.Imps[0].MediaTypes.Banner.Sizes = append(
reqData.Imps[0].MediaTypes.Banner.Sizes,
[]int64{tempH, tempW},
)
}
}
if bidType == openrtb_ext.BidTypeVideo && imp.Video != nil {
tempH := *imp.Video.H
tempW := *imp.Video.W

if tempH > 0 && tempW > 0 {
reqData.Imps[0].MediaTypes.Video.Sizes = append(
reqData.Imps[0].MediaTypes.Video.Sizes,
[]int64{tempH, tempW},
)
}
}

var bidderExt adapters.ExtImpBidder
var resetDigitalExt openrtb_ext.ImpExtResetDigital

if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return resetDigitalRequest{}, err
}
if err := json.Unmarshal(bidderExt.Bidder, &resetDigitalExt); err != nil {
return resetDigitalRequest{}, err
}
reqData.Imps[0].ZoneID.PlacementID = resetDigitalExt.PlacementID

return reqData, nil
}

func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
if adapters.IsResponseStatusCodeNoContent(responseData) {
return nil, nil
}

if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil {
return nil, []error{err}
}

var response resetDigitalBidResponse
if err := json.Unmarshal(responseData.Body, &response); err != nil {
return nil, []error{err}
}

bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))

requestImps := make(map[string]openrtb2.Imp)
for _, imp := range request.Imp {
requestImps[imp.ID] = imp
}

for i := range response.Bids {
resetDigitalBid := &response.Bids[i]

bid := getBidFromResponse(resetDigitalBid)
if bid == nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

code path is not covered. should add json tests to improve coverage

}

bidType, err := GetMediaTypeForImp(requestImps, bid.ImpID)
if err != nil {
return nil, []error{err}
Copy link
Contributor

Choose a reason for hiding this comment

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

code path is not covered. should add json tests to improve coverage

Copy link
Collaborator

@bsardo bsardo Sep 16, 2024

Choose a reason for hiding this comment

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

Does it make more sense to append the error and continue processing the rest of the bids?
If so, this should be:

if err != nil {
    errs = append(errs, err)
    continue
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed offline. Reset Digital to append the error and continue.

}

b := &adapters.TypedBid{
Bid: bid,
BidType: bidType,
Seat: openrtb_ext.BidderName(resetDigitalBid.Seat),
}
bidResponse.Bids = append(bidResponse.Bids, b)
}

if len(request.Cur) == 0 {
bidResponse.Currency = "USD"
}

return bidResponse, nil
}

func getBidFromResponse(bidResponse *resetDigitalBid) *openrtb2.Bid {
if bidResponse.CPM == 0 {
return nil
}

bid := &openrtb2.Bid{
ID: bidResponse.BidID,
Price: bidResponse.CPM,
ImpID: bidResponse.ImpID,
CID: bidResponse.CID,
CrID: bidResponse.CrID,
AdM: bidResponse.HTML,
}

if i, err := strconv.ParseInt(bidResponse.W, 10, 64); err == nil && i > 0 {
bid.W = i
}
if i, err := strconv.ParseInt(bidResponse.H, 10, 64); err == nil && i > 0 {
bid.H = i
}

return bid
}

func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) {
if imp.Banner != nil {

Choose a reason for hiding this comment

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

Consider this as a suggestion. The current implementation follows an anti-pattern, assumes that if there is a multi-format request, the media type defaults to openrtb_ext.BidTypeBanner, nil. Prebid server expects the media type to be explicitly set in the adapter response. Therefore, we strongly recommend implementing a pattern where the adapter server sets the MType field in the response to accurately determine the media type for the impression.

Copy link
Author

Choose a reason for hiding this comment

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

Implemented as suggested

Copy link
Contributor

Choose a reason for hiding this comment

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

Implemented as suggested

could you point out or link where MType changes are implemented?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, it was addressed on the point that we support only single format bids, so we could assume the anti pattern. Anyway, it would be more advisable to change to the normal pattern?

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, it would be more advisable to change to the normal pattern?

Prebid team recommends using MType field. But if it's not doable then current change suffices single format bid. @bruno-siira should mention in Bidder docs that adapter expects only single format bids in the incoming request

Copy link
Author

Choose a reason for hiding this comment

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

When we're talking about the Bidder Docs what is this file exacly @onkarvhanumante

Copy link
Contributor

Choose a reason for hiding this comment

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

return openrtb_ext.BidTypeBanner, nil
} else if imp.Video != nil {
bruno-siira marked this conversation as resolved.
Show resolved Hide resolved
return openrtb_ext.BidTypeVideo, nil
} else if imp.Audio != nil {
bruno-siira marked this conversation as resolved.
Show resolved Hide resolved
return openrtb_ext.BidTypeAudio, nil
}

return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID)
Comment on lines +302 to +307
Copy link
Contributor

Choose a reason for hiding this comment

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

code path is not covered. should add json tests to improve coverage

}

func getBidTypes(imp openrtb2.Imp) ([]openrtb_ext.BidType, error) {
var bidTypes []openrtb_ext.BidType

if imp.Banner != nil {
bidTypes = append(bidTypes, openrtb_ext.BidTypeBanner)
}
if imp.Video != nil {
bidTypes = append(bidTypes, openrtb_ext.BidTypeVideo)
}
if imp.Audio != nil {
bidTypes = append(bidTypes, openrtb_ext.BidTypeAudio)
}
if len(bidTypes) == 0 {
return nil, fmt.Errorf("failed to find matching imp for bid %s", imp.ID)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

#3766 (comment) this comment mentions like multi format bids are not supported. But getBidTypes collects all multiple format available for bid.

Copy link
Contributor

Choose a reason for hiding this comment

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

code path is not covered. should add json tests to improve coverage


return bidTypes, nil
}

func GetMediaTypeForImp(reqImps map[string]openrtb2.Imp, bidImpID string) (openrtb_ext.BidType, error) {
mediaType := openrtb_ext.BidTypeBanner

if reqImp, ok := reqImps[bidImpID]; ok {
if reqImp.Banner == nil && reqImp.Video != nil {
mediaType = openrtb_ext.BidTypeVideo
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're also declaring support for audio in your yaml file. Shouldn't you also handle media type audio here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed offline. Audio will be added.

return mediaType, nil
}
return "", fmt.Errorf("unknown media type for bid imp ID %s", bidImpID)
}
21 changes: 21 additions & 0 deletions adapters/resetdigital/resetdigital_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package resetdigital

import (
"testing"

"github.com/prebid/prebid-server/v2/adapters/adapterstest"
"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/openrtb_ext"
)

func TestJsonSamples(t *testing.T) {

bidder, buildErr := Builder(openrtb_ext.BidderResetDigital, config.Adapter{
Endpoint: "https://test.com"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}

adapterstest.RunJSONBidderTest(t, "resetdigitaltest", bidder)
}
Loading
Loading