From 71d2d6dd0356b490c17d292edd166ed943505733 Mon Sep 17 00:00:00 2001 From: mediasquare-alexandre Date: Mon, 3 Feb 2025 15:35:54 +0100 Subject: [PATCH] fix:Reviews --- adapters/mediasquare/mediasquare.go | 21 ++- adapters/mediasquare/mediasquare_test.go | 4 +- .../exemplary/multi-format.json | 121 ++++----------- .../exemplary/simple-banner.json | 20 +-- .../exemplary/simple-native.json | 82 +--------- .../exemplary/simple-video.json | 30 ++-- .../supplemental/no-valid-imp-ext.json | 45 +----- .../supplemental/no-valid-response.json | 2 +- .../supplemental/status-400.json | 24 +-- .../supplemental/status-not-200.json | 24 +-- adapters/mediasquare/parsers.go | 8 +- adapters/mediasquare/structs.go | 140 ++++-------------- adapters/mediasquare/utils.go | 23 +-- static/bidder-info/mediasquare.yaml | 2 +- 14 files changed, 130 insertions(+), 416 deletions(-) diff --git a/adapters/mediasquare/mediasquare.go b/adapters/mediasquare/mediasquare.go index 0c88557caa6..c23164c254a 100644 --- a/adapters/mediasquare/mediasquare.go +++ b/adapters/mediasquare/mediasquare.go @@ -28,7 +28,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E errs []error ) if request == nil || request.Imp == nil { - errs = append(errs, errorWritter(" request", nil, true)) + errs = append(errs, errorWriter(" request", nil, true)) return nil, errs } @@ -46,17 +46,17 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E ) if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { - errs = append(errs, errorWritter(" imp[ext]", err, len(imp.Ext) == 0)) + errs = append(errs, errorWriter(" imp[ext]", err, len(imp.Ext) == 0)) continue } if err := jsonutil.Unmarshal(bidderExt.Bidder, &msqExt); err != nil { - errs = append(errs, errorWritter(" imp-bidder[ext]", err, len(bidderExt.Bidder) == 0)) + errs = append(errs, errorWriter(" imp-bidder[ext]", err, len(bidderExt.Bidder) == 0)) continue } currentCode.Owner = msqExt.Owner currentCode.Code = msqExt.Code - if ok := currentCode.setContent(imp); ok { + if currentCode.setContent(imp) { msqParams.Codes = append(msqParams.Codes, currentCode) } } @@ -73,7 +73,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E func (a *adapter) makeRequest(request *openrtb2.BidRequest, msqParams *msqParameters) (requestData *adapters.RequestData, err error) { var requestJsonBytes []byte if msqParams == nil { - err = errorWritter(" msqParams", nil, true) + err = errorWriter(" msqParams", nil, true) return } if requestJsonBytes, err = jsonutil.Marshal(msqParams); err == nil { @@ -86,7 +86,7 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest, msqParams *msqParame ImpIDs: openrtb_ext.GetImpIDs(request.Imp), } } else { - err = errorWritter(" jsonutil.Marshal", err, false) + err = errorWriter(" jsonutil.Marshal", err, false) } return @@ -112,11 +112,18 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R var msqResp msqResponse if err := jsonutil.Unmarshal(response.Body, &msqResp); err != nil { errs = []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf(" Unexprected status code: %d. Bad server response: %s.", + Message: fmt.Sprintf(" Unexpected status code: %d. Bad server response: %s.", http.StatusNotAcceptable, err.Error())}, } return bidderResponse, errs } + if len(msqResp.Responses) == 0 { + errs = []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf(" Unexpected status code: %d. No responses found into body content.", + http.StatusNoContent)}, + } + return bidderResponse, errs + } bidderResponse = adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) msqResp.getContent(bidderResponse) diff --git a/adapters/mediasquare/mediasquare_test.go b/adapters/mediasquare/mediasquare_test.go index 3b8b8d46661..091f13ba190 100644 --- a/adapters/mediasquare/mediasquare_test.go +++ b/adapters/mediasquare/mediasquare_test.go @@ -31,14 +31,14 @@ func TestMakeRequests(t *testing.T) { // MakeRequests : case request is empty. resp, errs := bidder.MakeRequests(nil, nil) - expectingErrors := []error{errorWritter(" request", nil, true)} + expectingErrors := []error{errorWriter(" request", nil, true)} assert.Equal(t, []*adapters.RequestData(nil), resp, "resp, was supposed to be empty result.") assert.Equal(t, expectingErrors, errs, "errs, was supposed to be :", expectingErrors) // MakeRequests : case request.Imp is empty. bidResquest := openrtb2.BidRequest{ID: "id-test", Imp: nil} resp, errs = bidder.MakeRequests(&bidResquest, nil) - expectingErrors = []error{errorWritter(" request", nil, true)} + expectingErrors = []error{errorWriter(" request", nil, true)} assert.Equal(t, []*adapters.RequestData(nil), resp, "resp, was supposed to be empty result.") assert.Equal(t, expectingErrors, errs, "errs, was supposed to be :", expectingErrors) } diff --git a/adapters/mediasquare/mediasquaretest/exemplary/multi-format.json b/adapters/mediasquare/mediasquaretest/exemplary/multi-format.json index 52b244342eb..335da6ab6cc 100644 --- a/adapters/mediasquare/mediasquaretest/exemplary/multi-format.json +++ b/adapters/mediasquare/mediasquaretest/exemplary/multi-format.json @@ -12,7 +12,7 @@ }, "ext": { "bidder": { - "owner": "test", + "owner": "msq_test", "code": "publishername_atf_desktop_rg_pave" } } @@ -30,7 +30,7 @@ }, "ext": { "bidder": { - "owner": "test", + "owner": "msq_test", "code": "publishername_atf_desktop_rg_pave" } } @@ -43,6 +43,7 @@ "banner": null, "video": null, "native": { + "request": "request-test", "ext": { "title": { "required": true, "len": 80 }, "body": { "required": true }, @@ -73,7 +74,7 @@ }, "ext": { "bidder": { - "owner": "test", + "owner": "msq_test", "code": "publishername_atf_desktop_rg_pave" } } @@ -100,7 +101,7 @@ }, "ext": { "bidder": { - "owner": "test", + "owner": "msq_test", "code": "publishername_atf_desktop_rg_video" } } @@ -148,13 +149,11 @@ "auctionid": "70e5672c-515b-406e-967c-fcc2b04de04f", "bidid": "2c35e25e-e7d3-41bf-b810-06a449f456b9", "code": "publishername_atf_desktop_rg_pave", - "owner": "test", + "owner": "msq_test", "mediatypes": { "banner": { "sizes": [[970, 250]] - }, - "video": null, - "native": null + } }, "floor": { "970x250": { @@ -168,7 +167,7 @@ "auctionid": "70e5672c-515b-406e-967c-fcc2b04de04f", "bidid": "2059a3e6-71a3-43ea-8290-b5ceb13d35a8", "code": "publishername_atf_desktop_rg_pave", - "owner": "test", + "owner": "msq_test", "mediatypes": { "banner": { "sizes": [ @@ -176,9 +175,7 @@ [300, 600], [120, 600] ] - }, - "video": null, - "native": null + } }, "floor": { "120x600": { @@ -196,93 +193,39 @@ } }, { - "owner": "test", + "owner": "msq_test", "code": "publishername_atf_desktop_rg_pave", "adunit": "msq_tag_200123_native", "auctionid": "70e5672c-515b-406e-967c-fcc2b04de04f", "bidid": "2c35e25e-e7d3-41bf-b810-06a449f456c9", "mediatypes": { - "video": null, - "banner": null, - "native": { - "address": null, - "title": { "required": true, "len": 80 }, - "body": { "required": true }, - "body2": null, - "type": "native", - "cta": null, - "displayUrl": null, - "downloads": null, - "icon": { - "required": false, - "aspect_ratio": { - "min_width": 50, - "min_height": 50, - "ratio_width": 2, - "ratio_height": 3 - } - }, - "image": { - "required": false, - "aspect_ratio": { - "min_width": 300, - "min_height": 200, - "ratio_width": 2, - "ratio_height": 3 - } - }, - "likes": null, - "phone": null, - "price": null, - "privacyIcon": null, - "privacyLink": null, - "rating": null, - "saleprice": null, - "sizes": [ - [970, 250], - [728, 90] - ], - "sponsoredBy": null, - "clickUrl": { "required": true } - } + "native_request": "request-test" }, "floor": { - "*": { "floor": 1, "currency": "USD" }, - "970x250": { "floor": 1, "currency": "USD" }, - "728x90": { "floor": 1, "currency": "USD" } + "*": { "floor": 1, "currency": "USD" } } }, { - "owner": "test", + "owner": "msq_test", "code": "publishername_atf_desktop_rg_video", "adunit": "msq_tag_200123_native", "auctionid": "70e5672c-515b-406e-967c-fcc2b04de04f", "bidid": "2c35e25e-e7d3-41bf-b810-06a449f456d9", "mediatypes": { "video": { + "ext": { + "context": "context-test", + "linearity": 0, + "playersize": [[800, 600]] + }, "mimes": ["video/mp4"], - "minbitrate": null, - "maxbitrate": null, "minduration": 10, "maxduration": 23, "placement": 1, - "linearity": 0, "w": 800, "h": 600, - "playbackmethod": null, - "playersize": [[800, 600]], - "api": null, - "boxingallower": null, - "context": "context-test", - "delivery": null, - "plcmt": 1, - "protocols": null, - "skip": null, - "skipafter": null, - "startdelay": null - }, - "banner": null, - "native": null + "plcmt": 1 + } }, "floor": { "*": { "floor": 1 }, @@ -339,12 +282,12 @@ { "ad": "\u003c!-- This is an example --\u003e", "bid_id": "2c35e25e-e7d3-41bf-b810-06a449f456b9", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_pave", "cpm": 2, "increment": 2, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "width": 250, "net_revenue": true, "transaction_id": "2c35e25e-e7d3-41bf-b810-06a449f456b9", @@ -355,12 +298,12 @@ { "ad": "\u003c!-- This is an example --\u003e", "bid_id": "2059a3e6-71a3-43ea-8290-b5ceb13d35a8", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_pave", "cpm": 0.02, "increment": 0.02, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "width": 250, "net_revenue": true, "transaction_id": "2059a3e6-71a3-43ea-8290-b5ceb13d35a8", @@ -370,12 +313,12 @@ }, { "bid_id": "2c35e25e-e7d3-41bf-b810-06a449f456c9", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_pave", "cpm": 2, "increment": 2, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "net_revenue": true, "transaction_id": "2c35e25e-e7d3-41bf-b810-06a449f456c9", "ttl": 20000, @@ -388,12 +331,12 @@ }, { "bid_id": "2c35e25e-e7d3-41bf-b810-06a449f456d9", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_video", "cpm": 2, "increment": 2, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "net_revenue": true, "transaction_id": "2c35e25e-e7d3-41bf-b810-06a449f456d9", "ttl": 20000, @@ -438,7 +381,7 @@ "price": 2, "adm": "\u003c!-- This is an example --\u003e", "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "w": 250, "mtype": 1 }, @@ -455,7 +398,7 @@ "price": 0.02, "adm": "\u003c!-- This is an example --\u003e", "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "w": 250, "mtype": 1 }, @@ -471,7 +414,7 @@ "impid": "2c35e25e-e7d3-41bf-b810-06a449f456c9", "price": 2, "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "mtype": 4 }, "BidMeta": { @@ -486,7 +429,7 @@ "impid": "2c35e25e-e7d3-41bf-b810-06a449f456d9", "price": 2, "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "mtype": 2 }, "BidMeta": { diff --git a/adapters/mediasquare/mediasquaretest/exemplary/simple-banner.json b/adapters/mediasquare/mediasquaretest/exemplary/simple-banner.json index 4f8030b3ffe..8769b37df15 100644 --- a/adapters/mediasquare/mediasquaretest/exemplary/simple-banner.json +++ b/adapters/mediasquare/mediasquaretest/exemplary/simple-banner.json @@ -82,9 +82,7 @@ "mediatypes": { "banner": { "sizes": [[970, 250]] - }, - "video": null, - "native": null + } }, "floor": { "970x250": { @@ -106,9 +104,7 @@ [300, 600], [120, 600] ] - }, - "video": null, - "native": null + } }, "floor": { "120x600": { @@ -173,12 +169,12 @@ { "ad": "\u003c!-- This is an example --\u003e", "bid_id": "2c35e25e-e7d3-41bf-b810-06a449f456b9", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_pave", "cpm": 2, "increment": 2, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "width": 250, "net_revenue": true, "transaction_id": "2c35e25e-e7d3-41bf-b810-06a449f456b9", @@ -190,12 +186,12 @@ { "ad": "\u003c!-- This is an example --\u003e", "bid_id": "2059a3e6-71a3-43ea-8290-b5ceb13d35a8", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_pave", "cpm": 0.02, "increment": 0.02, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "width": 250, "net_revenue": true, "transaction_id": "2059a3e6-71a3-43ea-8290-b5ceb13d35a8", @@ -229,7 +225,7 @@ "price": 2, "adm": "\u003c!-- This is an example --\u003e", "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "w": 250, "mtype": 1 }, @@ -246,7 +242,7 @@ "price": 0.02, "adm": "\u003c!-- This is an example --\u003e", "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "w": 250, "mtype": 1 }, diff --git a/adapters/mediasquare/mediasquaretest/exemplary/simple-native.json b/adapters/mediasquare/mediasquaretest/exemplary/simple-native.json index 611fb7f96bf..9a9e842b344 100644 --- a/adapters/mediasquare/mediasquaretest/exemplary/simple-native.json +++ b/adapters/mediasquare/mediasquaretest/exemplary/simple-native.json @@ -10,33 +10,7 @@ "banner": null, "video": null, "native": { - "ext": { - "title": { "required": true, "len": 80 }, - "body": { "required": true }, - "icon": { - "required": false, - "aspect_ratio": { - "min_width": 50, - "min_height": 50, - "ratio_width": 2, - "ratio_height": 3 - } - }, - "image": { - "required": false, - "aspect_ratio": { - "min_width": 300, - "min_height": 200, - "ratio_width": 2, - "ratio_height": 3 - } - }, - "clickUrl": { "required": true }, - "sizes": [ - [970, 250], - [728, 90] - ] - } + "request": "request-test" }, "ext": { "bidder": { @@ -90,54 +64,10 @@ "auctionid": "70e5672c-515b-406e-967c-fcc2b04de04f", "bidid": "2c35e25e-e7d3-41bf-b810-06a449f456b9", "mediatypes": { - "video": null, - "banner": null, - "native": { - "address": null, - "title": { "required": true, "len": 80 }, - "body": { "required": true }, - "body2": null, - "type": "native", - "cta": null, - "displayUrl": null, - "downloads": null, - "icon": { - "required": false, - "aspect_ratio": { - "min_width": 50, - "min_height": 50, - "ratio_width": 2, - "ratio_height": 3 - } - }, - "image": { - "required": false, - "aspect_ratio": { - "min_width": 300, - "min_height": 200, - "ratio_width": 2, - "ratio_height": 3 - } - }, - "likes": null, - "phone": null, - "price": null, - "privacyIcon": null, - "privacyLink": null, - "rating": null, - "saleprice": null, - "sizes": [ - [970, 250], - [728, 90] - ], - "sponsoredBy": null, - "clickUrl": { "required": true } - } + "native_request": "request-test" }, "floor": { - "*": { "floor": 1, "currency": "USD" }, - "970x250": { "floor": 1, "currency": "USD" }, - "728x90": { "floor": 1, "currency": "USD" } + "*": { "floor": 1, "currency": "USD" } } } ], @@ -184,12 +114,12 @@ "responses": [ { "bid_id": "4e2d4580c1da1", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_pave", "cpm": 1, "increment": 1, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "net_revenue": true, "transaction_id": "4e2d4580c1da1", "ttl": 20000, @@ -216,7 +146,7 @@ "impid": "4e2d4580c1da1", "price": 1, "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "mtype": 4 }, "bidmeta": { diff --git a/adapters/mediasquare/mediasquaretest/exemplary/simple-video.json b/adapters/mediasquare/mediasquaretest/exemplary/simple-video.json index 15a249764af..13de7f873b5 100644 --- a/adapters/mediasquare/mediasquaretest/exemplary/simple-video.json +++ b/adapters/mediasquare/mediasquaretest/exemplary/simple-video.json @@ -7,7 +7,7 @@ "bidfloor": 1, "tagid": "msq_tag_200123_native", "banner": null, - "native": null, + "native_request": null, "video": { "mimes": ["video/mp4"], "minduration": 10, @@ -76,28 +76,18 @@ "mediatypes": { "video": { "mimes": ["video/mp4"], - "minbitrate": null, - "maxbitrate": null, "minduration": 10, "maxduration": 23, "placement": 1, - "linearity": 0, "w": 800, "h": 600, - "playbackmethod": null, - "playersize": [[800, 600]], - "api": null, - "boxingallower": null, - "context": "context-test", - "delivery": null, "plcmt": 1, - "protocols": null, - "skip": null, - "skipafter": null, - "startdelay": null - }, - "banner": null, - "native": null + "ext": { + "context": "context-test", + "linearity": 0, + "playersize": [[800, 600]] + } + } }, "floor": { "*": { "floor": 1 }, @@ -148,12 +138,12 @@ "responses": [ { "bid_id": "4e2d4580c1da1", - "bidder": "fakeBidder", + "bidder": "msq_test", "code": "test/publishername_atf_desktop_rg_pave", "cpm": 1, "increment": 1, "currency": "USD", - "creative_id": "fakeBidder|fakeCreative", + "creative_id": "msq_test|fakeCreative", "net_revenue": true, "transaction_id": "4e2d4580c1da1", "ttl": 20000, @@ -184,7 +174,7 @@ "impid": "4e2d4580c1da1", "price": 1, "adomain": ["mediasquare.fr"], - "crid": "fakeBidder|fakeCreative", + "crid": "msq_test|fakeCreative", "mtype": 2, "ext": { "dsa": { "behalf": "dsa-test-behalf", "paid": "dsa-test-paid" } diff --git a/adapters/mediasquare/mediasquaretest/supplemental/no-valid-imp-ext.json b/adapters/mediasquare/mediasquaretest/supplemental/no-valid-imp-ext.json index f550121b3ab..6fae03fd4e2 100644 --- a/adapters/mediasquare/mediasquaretest/supplemental/no-valid-imp-ext.json +++ b/adapters/mediasquare/mediasquaretest/supplemental/no-valid-imp-ext.json @@ -16,7 +16,7 @@ "native": { "request": "" }, "ext": { "bidder": { - "owner": "test", + "owner": "msq_test", "code": "publishername_atf_desktop_rg_pave" } } @@ -48,42 +48,7 @@ "expectedRequest": { "uri": "https://pbs-front.mediasquare.fr/msq_prebid", "body": { - "codes": [ - { - "adunit": "", - "auctionid": "id-ok", - "bidid": "42", - "code": "publishername_atf_desktop_rg_pave", - "owner": "test", - "mediatypes": { - "banner": null, - "video": null, - "native": { - "title": null, - "icon": null, - "image": null, - "clickUrl": null, - "displayUrl": null, - "privacyLink": null, - "privacyIcon": null, - "cta": null, - "rating": null, - "downloads": null, - "likes": null, - "price": null, - "saleprice": null, - "address": null, - "phone": null, - "body": null, - "body2": null, - "sponsoredBy": null, - "sizes": null, - "type": "native" - } - }, - "floor": { "*": {} } - } - ], + "codes": null, "gdpr": { "consent_required": false, "consent_string": "" }, "type": "pbs", "dsa": "", @@ -119,10 +84,10 @@ } } ], - "expectedBidResponses": [ + "expectedMakeBidsErrors": [ { - "currency": "USD", - "bids": [] + "value": " Unexpected status code: 204. No responses found into body content.", + "comparison": "literal" } ] } diff --git a/adapters/mediasquare/mediasquaretest/supplemental/no-valid-response.json b/adapters/mediasquare/mediasquaretest/supplemental/no-valid-response.json index 3273618bd9b..5e987db6155 100644 --- a/adapters/mediasquare/mediasquaretest/supplemental/no-valid-response.json +++ b/adapters/mediasquare/mediasquaretest/supplemental/no-valid-response.json @@ -81,7 +81,7 @@ ], "expectedMakeBidsErrors": [ { - "value": " Unexprected status code: 406. Bad server response: cannot unmarshal mediasquare.msqResponse.Responses: decode slice: expect [ or n, but found \".", + "value": " Unexpected status code: 406. Bad server response: cannot unmarshal mediasquare.msqResponse.Responses: decode slice: expect [ or n, but found \".", "comparison": "literal" } ] diff --git a/adapters/mediasquare/mediasquaretest/supplemental/status-400.json b/adapters/mediasquare/mediasquaretest/supplemental/status-400.json index fca42ab512f..05e4413a97d 100644 --- a/adapters/mediasquare/mediasquaretest/supplemental/status-400.json +++ b/adapters/mediasquare/mediasquaretest/supplemental/status-400.json @@ -77,29 +77,19 @@ "bidid": "2c35e25e-e7d3-41bf-b810-06a449f456b9", "mediatypes": { "video": { + "ext": { + "linearity": 0, + "playersize": [[800, 600]], + "context": "context-test" + }, "mimes": ["video/mp4"], - "minbitrate": null, - "maxbitrate": null, "minduration": 10, "maxduration": 23, "placement": 1, - "linearity": 0, "w": 800, "h": 600, - "playbackmethod": null, - "playersize": [[800, 600]], - "api": null, - "boxingallower": null, - "context": "context-test", - "delivery": null, - "plcmt": 1, - "protocols": null, - "skip": null, - "skipafter": null, - "startdelay": null - }, - "banner": null, - "native": null + "plcmt": 1 + } }, "floor": { "*": { "floor": 1 }, diff --git a/adapters/mediasquare/mediasquaretest/supplemental/status-not-200.json b/adapters/mediasquare/mediasquaretest/supplemental/status-not-200.json index b24da988fde..4168a7adeaa 100644 --- a/adapters/mediasquare/mediasquaretest/supplemental/status-not-200.json +++ b/adapters/mediasquare/mediasquaretest/supplemental/status-not-200.json @@ -77,29 +77,19 @@ "bidid": "2c35e25e-e7d3-41bf-b810-06a449f456b9", "mediatypes": { "video": { + "ext": { + "linearity": 0, + "context": "context-test", + "playersize": [[800, 600]] + }, "mimes": ["video/mp4"], - "minbitrate": null, - "maxbitrate": null, "minduration": 10, "maxduration": 23, "placement": 1, - "linearity": 0, "w": 800, "h": 600, - "playbackmethod": null, - "playersize": [[800, 600]], - "api": null, - "boxingallower": null, - "context": "context-test", - "delivery": null, - "plcmt": 1, - "protocols": null, - "skip": null, - "skipafter": null, - "startdelay": null - }, - "banner": null, - "native": null + "plcmt": 1 + } }, "floor": { "*": { "floor": 1 }, diff --git a/adapters/mediasquare/parsers.go b/adapters/mediasquare/parsers.go index dd01b73efa8..f2ef4ab675d 100644 --- a/adapters/mediasquare/parsers.go +++ b/adapters/mediasquare/parsers.go @@ -16,11 +16,11 @@ type parserDSA struct { func (parser *parserDSA) setContent(extJsonBytes []byte) error { if len(extJsonBytes) > 0 { if err := jsonutil.Unmarshal(extJsonBytes, parser); err != nil { - return errorWritter(" extJsonBytes", err, false) + return errorWriter(" extJsonBytes", err, false) } return nil } - return errorWritter(" extJsonBytes", nil, true) + return errorWriter(" extJsonBytes", nil, true) } // getValue: Returns the DSA value as a string, defaultly returns empty-string. @@ -45,11 +45,11 @@ type parserGDPR struct { func (parser *parserGDPR) setContent(extJsonBytes []byte) error { if len(extJsonBytes) > 0 { if err := jsonutil.Unmarshal(extJsonBytes, parser); err != nil { - return errorWritter(" extJsonBytes", err, false) + return errorWriter(" extJsonBytes", err, false) } return nil } - return errorWritter(" extJsonBytes", nil, true) + return errorWriter(" extJsonBytes", nil, true) } // value: Returns the consent or GDPR-string depending of the parserGDPR content, defaulty return empty-string. diff --git a/adapters/mediasquare/structs.go b/adapters/mediasquare/structs.go index 93af4d0bb5f..3758e31380f 100644 --- a/adapters/mediasquare/structs.go +++ b/adapters/mediasquare/structs.go @@ -5,7 +5,7 @@ import ( "github.com/prebid/openrtb/v20/openrtb2" "github.com/prebid/prebid-server/v3/adapters" - "github.com/prebid/prebid-server/v3/util/jsonutil" + "github.com/prebid/prebid-server/v3/util/ptrutil" ) // msqResponse: Bid-Response sent by mediasquare. @@ -20,15 +20,12 @@ type msqResponse struct { // msqParameters: Bid-Request sent to mediasquare. type msqParameters struct { - Codes []msqParametersCodes `json:"codes"` - Gdpr struct { - ConsentRequired bool `json:"consent_required"` - ConsentString string `json:"consent_string"` - } `json:"gdpr"` - Type string `json:"type"` - DSA interface{} `json:"dsa,omitempty"` - Support msqSupport `json:"tech"` - Test bool `json:"test"` + Codes []msqParametersCodes `json:"codes"` + Gdpr msqParametersGdpr `json:"gdpr"` + Type string `json:"type"` + DSA interface{} `json:"dsa,omitempty"` + Support msqSupport `json:"tech"` + Test bool `json:"test"` } type msqResponseBidsVideo struct { @@ -100,82 +97,20 @@ type msqParametersCodes struct { Floor map[string]msqFloor `json:"floor,omitempty"` } +type msqParametersGdpr struct { + ConsentRequired bool `json:"consent_required"` + ConsentString string `json:"consent_string"` +} + type msqFloor struct { Price float64 `json:"floor,omitempty"` Currency string `json:"currency,omitempty"` } -type mediaTypeNativeBasis struct { - Required bool `json:"required,omitempty"` - Len *int `json:"len,omitempty"` -} - -type mediaTypeNativeImage struct { - Required bool `json:"required"` - Sizes []*int `json:"sizes,omitempty"` - Aspect_ratio *struct { - Min_width *int `json:"min_width,omitempty"` - Min_height *int `json:"min_height,omitempty"` - Ratio_width *int `json:"ratio_width,omitempty"` - Ratio_height *int `json:"ratio_height,omitempty"` - } `json:"aspect_ratio,omitempty"` -} - -type mediaTypeNativeTitle struct { - Required bool `json:"required,omitempty"` - Len int `json:"len,omitempty"` -} - -type mediaTypeNative struct { - Title *mediaTypeNativeTitle `json:"title"` - Icon *mediaTypeNativeImage `json:"icon"` - Image *mediaTypeNativeImage `json:"image"` - Clickurl *mediaTypeNativeBasis `json:"clickUrl"` - Displayurl *mediaTypeNativeBasis `json:"displayUrl"` - Privacylink *mediaTypeNativeBasis `json:"privacyLink"` - Privacyicon *mediaTypeNativeBasis `json:"privacyIcon"` - Cta *mediaTypeNativeBasis `json:"cta"` - Rating *mediaTypeNativeBasis `json:"rating"` - Downloads *mediaTypeNativeBasis `json:"downloads"` - Likes *mediaTypeNativeBasis `json:"likes"` - Price *mediaTypeNativeBasis `json:"price"` - Saleprice *mediaTypeNativeBasis `json:"saleprice"` - Address *mediaTypeNativeBasis `json:"address"` - Phone *mediaTypeNativeBasis `json:"phone"` - Body *mediaTypeNativeBasis `json:"body"` - Body2 *mediaTypeNativeBasis `json:"body2"` - Sponsoredby *mediaTypeNativeBasis `json:"sponsoredBy"` - Sizes [][]int `json:"sizes"` - Type string `json:"type"` -} - -type mediaTypeVideo struct { - Mimes []string `json:"mimes"` - Minduration *int `json:"minduration"` - Maxduration *int `json:"maxduration"` - Protocols []*int `json:"protocols"` - Startdelay *int `json:"startdelay"` - Placement *int `json:"placement"` - Skip *int `json:"skip"` - Skipafter *int `json:"skipafter"` - Minbitrate *int `json:"minbitrate"` - Maxbitrate *int `json:"maxbitrate"` - Delivery []*int `json:"delivery"` - Playbackmethod []*int `json:"playbackmethod"` - Api []*int `json:"api"` - Linearity *int `json:"linearity"` - W *int `json:"w"` - H *int `json:"h"` - Boxingallowed *int `json:"boxingallower"` - PlayerSize [][]int `json:"playersize"` - Context string `json:"context"` - Plcmt *int `json:"plcmt,omitempty"` -} - type mediaTypes struct { - Banner *mediaTypeBanner `json:"banner"` - Video *mediaTypeVideo `json:"video"` - Native *mediaTypeNative `json:"native"` + Banner *mediaTypeBanner `json:"banner,omitempty"` + Video *openrtb2.Video `json:"video,omitempty"` + NativeRequest *string `json:"native_request,omitempty"` } type mediaTypeBanner struct { @@ -188,10 +123,7 @@ func initMsqParams(request *openrtb2.BidRequest) (msqParams msqParameters) { Device: request.Device, App: request.App, } - msqParams.Gdpr = struct { - ConsentRequired bool `json:"consent_required"` - ConsentString string `json:"consent_string"` - }{ + msqParams.Gdpr = msqParametersGdpr{ ConsentRequired: (parserGDPR{}).getValue("consent_requirement", request) == "true", ConsentString: (parserGDPR{}).getValue("consent_string", request), } @@ -201,7 +133,7 @@ func initMsqParams(request *openrtb2.BidRequest) (msqParams msqParameters) { } // setContent: Loads currentImp into msqParams (*msqParametersCodes), -// returns (errs []error, ok bool) where `ok` express if mandatory content had been loaded. +// returns (ok bool) where `ok` express if mandatory content had been loaded. func (msqParams *msqParametersCodes) setContent(currentImp openrtb2.Imp) (ok bool) { var ( currentMapFloors = make(map[string]msqFloor, 0) @@ -213,37 +145,29 @@ func (msqParams *msqParametersCodes) setContent(currentImp openrtb2.Imp) (ok boo if currentImp.Video != nil { ok = true - var video mediaTypeVideo - currentVideoBytes, _ := jsonutil.Marshal(currentImp.Video) - jsonutil.Unmarshal(currentVideoBytes, &video) - jsonutil.Unmarshal(currentImp.Video.Ext, &video) - - msqParams.Mediatypes.Video = &video - if msqParams.Mediatypes.Video != nil { - if currentImp.Video.W != nil && currentImp.Video.H != nil { - currentMapFloors[fmt.Sprintf("%dx%d", *(currentImp.Video.W), *(currentImp.Video.H))] = currentFloor - } + msqParams.Mediatypes.Video = currentImp.Video + if currentImp.Video.W != nil && currentImp.Video.H != nil { + currentMapFloors[fmt.Sprintf("%dx%d", *(currentImp.Video.W), *(currentImp.Video.H))] = currentFloor } currentMapFloors["*"] = currentFloor } if currentImp.Banner != nil { - ok = true - var banner mediaTypeBanner - jsonutil.Unmarshal(currentImp.Banner.Ext, &banner) - - msqParams.Mediatypes.Banner = &banner switch { case len(currentImp.Banner.Format) > 0: + ok = true + msqParams.Mediatypes.Banner = new(mediaTypeBanner) for _, bannerFormat := range currentImp.Banner.Format { currentMapFloors[fmt.Sprintf("%dx%d", bannerFormat.W, bannerFormat.H)] = currentFloor msqParams.Mediatypes.Banner.Sizes = append(msqParams.Mediatypes.Banner.Sizes, - []*int{intToPtrInt(int(bannerFormat.W)), intToPtrInt(int(bannerFormat.H))}) + []*int{ptrutil.ToPtr(int(bannerFormat.W)), ptrutil.ToPtr(int(bannerFormat.H))}) } case currentImp.Banner.W != nil && currentImp.Banner.H != nil: + ok = true + msqParams.Mediatypes.Banner = new(mediaTypeBanner) currentMapFloors[fmt.Sprintf("%dx%d", *(currentImp.Banner.W), *(currentImp.Banner.H))] = currentFloor msqParams.Mediatypes.Banner.Sizes = append(msqParams.Mediatypes.Banner.Sizes, - []*int{intToPtrInt(int(*currentImp.Banner.W)), intToPtrInt(int(*currentImp.Banner.H))}) + []*int{ptrutil.ToPtr(int(*currentImp.Banner.W)), ptrutil.ToPtr(int(*currentImp.Banner.H))}) } if msqParams.Mediatypes.Banner != nil { @@ -255,17 +179,9 @@ func (msqParams *msqParametersCodes) setContent(currentImp openrtb2.Imp) (ok boo } } - if currentImp.Native != nil { + if currentImp.Native != nil && len(currentImp.Native.Request) > 0 { ok = true - var native = mediaTypeNative{Type: "native"} - jsonutil.Unmarshal(currentImp.Native.Ext, &native) - - msqParams.Mediatypes.Native = &native - for _, nativeSizes := range msqParams.Mediatypes.Native.Sizes { - if len(nativeSizes) == 2 { - currentMapFloors[fmt.Sprintf("%dx%d", nativeSizes[0], nativeSizes[1])] = currentFloor - } - } + msqParams.Mediatypes.NativeRequest = ptrutil.ToPtr(currentImp.Native.Request) currentMapFloors["*"] = currentFloor } diff --git a/adapters/mediasquare/utils.go b/adapters/mediasquare/utils.go index 65704369138..50ee7285a7f 100644 --- a/adapters/mediasquare/utils.go +++ b/adapters/mediasquare/utils.go @@ -14,22 +14,15 @@ var headerList = map[string][]string{ "Accept": {"application/json"}, } -var mediaTypeList = map[openrtb_ext.BidType]openrtb2.MarkupType{ - "banner": openrtb2.MarkupBanner, - "video": openrtb2.MarkupVideo, - "audio": openrtb2.MarkupAudio, - "native": openrtb2.MarkupNative, -} - // mType: Returns the openrtb2.MarkupType from an msqResponseBids. func (msqBids *msqResponseBids) mType() openrtb2.MarkupType { switch { case msqBids.Video != nil: - return mediaTypeList["video"] + return openrtb2.MarkupVideo case msqBids.Native != nil: - return mediaTypeList["native"] + return openrtb2.MarkupNative default: - return mediaTypeList["banner"] + return openrtb2.MarkupBanner } } @@ -93,14 +86,8 @@ func ptrInt8ToBool(i *int8) bool { return false } -// intToPtrInt: Returns a ptr_int(*int) for which *ptr_int = i. -func intToPtrInt(i int) *int { - val := int(i) - return &val -} - -// errorWritter: Returns a Custom error message. -func errorWritter(referer string, err error, isEmpty bool) error { +// errorWriter: Returns a Custom error message. +func errorWriter(referer string, err error, isEmpty bool) error { if isEmpty { return fmt.Errorf("%s: is empty.", referer) } diff --git a/static/bidder-info/mediasquare.yaml b/static/bidder-info/mediasquare.yaml index 6056cc30a8d..b6d21f4c9f2 100644 --- a/static/bidder-info/mediasquare.yaml +++ b/static/bidder-info/mediasquare.yaml @@ -3,7 +3,7 @@ endpointCompression: gzip gvlVendorID: 791 modifyingVastXmlAllowed: true maintainer: - email: "alexandre.harribey@mediasquare.fr" + email: "tech@mediasquare.fr" capabilities: app: mediaTypes: