Skip to content

Commit

Permalink
fix:Reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mediasquare-alexandre committed Feb 3, 2025
1 parent 01c1674 commit 71d2d6d
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 416 deletions.
21 changes: 14 additions & 7 deletions adapters/mediasquare/mediasquare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("<MakeRequests> request", nil, true))
errs = append(errs, errorWriter("<MakeRequests> request", nil, true))
return nil, errs
}

Expand All @@ -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("<MakeRequests> imp[ext]", err, len(imp.Ext) == 0))
errs = append(errs, errorWriter("<MakeRequests> imp[ext]", err, len(imp.Ext) == 0))
continue
}
if err := jsonutil.Unmarshal(bidderExt.Bidder, &msqExt); err != nil {
errs = append(errs, errorWritter("<MakeRequests> imp-bidder[ext]", err, len(bidderExt.Bidder) == 0))
errs = append(errs, errorWriter("<MakeRequests> 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)
}
}
Expand All @@ -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("<makeRequest> msqParams", nil, true)
err = errorWriter("<makeRequest> msqParams", nil, true)
return
}
if requestJsonBytes, err = jsonutil.Marshal(msqParams); err == nil {
Expand All @@ -86,7 +86,7 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest, msqParams *msqParame
ImpIDs: openrtb_ext.GetImpIDs(request.Imp),
}
} else {
err = errorWritter("<makeRequest> jsonutil.Marshal", err, false)
err = errorWriter("<makeRequest> jsonutil.Marshal", err, false)
}

return
Expand All @@ -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("<MakeBids> Unexprected status code: %d. Bad server response: %s.",
Message: fmt.Sprintf("<MakeBids> 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("<MakeBids> Unexpected status code: %d. No responses found into body content.",
http.StatusNoContent)},
}
return bidderResponse, errs
}
bidderResponse = adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))
msqResp.getContent(bidderResponse)

Expand Down
4 changes: 2 additions & 2 deletions adapters/mediasquare/mediasquare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func TestMakeRequests(t *testing.T) {

// MakeRequests : case request is empty.
resp, errs := bidder.MakeRequests(nil, nil)
expectingErrors := []error{errorWritter("<MakeRequests> request", nil, true)}
expectingErrors := []error{errorWriter("<MakeRequests> 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("<MakeRequests> request", nil, true)}
expectingErrors = []error{errorWriter("<MakeRequests> 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)
}
121 changes: 32 additions & 89 deletions adapters/mediasquare/mediasquaretest/exemplary/multi-format.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"ext": {
"bidder": {
"owner": "test",
"owner": "msq_test",
"code": "publishername_atf_desktop_rg_pave"
}
}
Expand All @@ -30,7 +30,7 @@
},
"ext": {
"bidder": {
"owner": "test",
"owner": "msq_test",
"code": "publishername_atf_desktop_rg_pave"
}
}
Expand All @@ -43,6 +43,7 @@
"banner": null,
"video": null,
"native": {
"request": "request-test",
"ext": {
"title": { "required": true, "len": 80 },
"body": { "required": true },
Expand Down Expand Up @@ -73,7 +74,7 @@
},
"ext": {
"bidder": {
"owner": "test",
"owner": "msq_test",
"code": "publishername_atf_desktop_rg_pave"
}
}
Expand All @@ -100,7 +101,7 @@
},
"ext": {
"bidder": {
"owner": "test",
"owner": "msq_test",
"code": "publishername_atf_desktop_rg_video"
}
}
Expand Down Expand Up @@ -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": {
Expand All @@ -168,17 +167,15 @@
"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": [
[300, 250],
[300, 600],
[120, 600]
]
},
"video": null,
"native": null
}
},
"floor": {
"120x600": {
Expand All @@ -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 },
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
},
Expand All @@ -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
},
Expand All @@ -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": {
Expand All @@ -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": {
Expand Down
Loading

0 comments on commit 71d2d6d

Please sign in to comment.