From 19d4dae5d00076cf0b3db269bfe160a93d85dbfa Mon Sep 17 00:00:00 2001 From: Maksym Pavliv <73064267+PyjamaWarrior@users.noreply.github.com> Date: Fri, 4 Aug 2023 08:57:14 +0300 Subject: [PATCH] Axis adapter: updated url (#3002) Co-authored-by: Maksym Pavliv --- adapters/axis/axis.go | 31 +++---------------- adapters/axis/axis_test.go | 2 +- .../axistest/exemplary/simple-banner.json | 2 +- .../axistest/exemplary/simple-native.json | 2 +- .../axis/axistest/exemplary/simple-video.json | 2 +- .../axistest/exemplary/simple-web-banner.json | 2 +- .../axistest/supplemental/bad_media_type.json | 2 +- .../axistest/supplemental/bad_response.json | 2 +- .../axistest/supplemental/status-204.json | 2 +- .../axistest/supplemental/status-not-200.json | 2 +- static/bidder-info/axis.yaml | 2 +- 11 files changed, 15 insertions(+), 36 deletions(-) diff --git a/adapters/axis/axis.go b/adapters/axis/axis.go index b9901c6cc51..f03a572e625 100644 --- a/adapters/axis/axis.go +++ b/adapters/axis/axis.go @@ -4,18 +4,16 @@ import ( "encoding/json" "fmt" "net/http" - "text/template" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" - "github.com/prebid/prebid-server/macros" "github.com/prebid/prebid-server/openrtb_ext" ) type adapter struct { - endpoint *template.Template + endpoint string } type reqBodyExt struct { @@ -23,13 +21,8 @@ type reqBodyExt struct { } 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, + endpoint: config.Endpoint, } return bidder, nil @@ -49,11 +42,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E continue } - url, err := a.buildEndpointURL(&bidderExt) - if err != nil { - return nil, []error{err} - } - extJson, err := json.Marshal(bidderExt) if err != nil { return nil, []error{err} @@ -61,7 +49,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E request.Imp[0].Ext = extJson - adapterReq, err := buildRequest(request, url) + adapterReq, err := a.buildRequest(request) if err != nil { return nil, []error{err} } @@ -74,16 +62,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E return adapterRequests, nil } -func (a *adapter) buildEndpointURL(bidderExt *reqBodyExt) (string, error) { - endpointParams := macros.EndpointTemplateParams{ - AccountID: bidderExt.AxisBidderExt.Integration, - SourceId: bidderExt.AxisBidderExt.Token, - } - - return macros.ResolveMacros(a.endpoint, endpointParams) -} - -func buildRequest(request *openrtb2.BidRequest, url string) (*adapters.RequestData, error) { +func (a *adapter) buildRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { reqJSON, err := json.Marshal(request) if err != nil { return nil, err @@ -95,7 +74,7 @@ func buildRequest(request *openrtb2.BidRequest, url string) (*adapters.RequestDa return &adapters.RequestData{ Method: "POST", - Uri: url, + Uri: a.endpoint, Body: reqJSON, Headers: headers, }, nil diff --git a/adapters/axis/axis_test.go b/adapters/axis/axis_test.go index 141631570a1..56cb7f0b6e8 100644 --- a/adapters/axis/axis_test.go +++ b/adapters/axis/axis_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderAxis, config.Adapter{ - Endpoint: "http://prebid.axis-marketplace.com/{{.AccountID}}?token={{.SourceId}}"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + Endpoint: "http://prebid.axis-marketplace.com/pbserver"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) diff --git a/adapters/axis/axistest/exemplary/simple-banner.json b/adapters/axis/axistest/exemplary/simple-banner.json index cd68d4322d2..2c276c49b6d 100644 --- a/adapters/axis/axistest/exemplary/simple-banner.json +++ b/adapters/axis/axistest/exemplary/simple-banner.json @@ -37,7 +37,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/axis/axistest/exemplary/simple-native.json b/adapters/axis/axistest/exemplary/simple-native.json index 60f8621aa97..ce337ec64a2 100644 --- a/adapters/axis/axistest/exemplary/simple-native.json +++ b/adapters/axis/axistest/exemplary/simple-native.json @@ -29,7 +29,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/axis/axistest/exemplary/simple-video.json b/adapters/axis/axistest/exemplary/simple-video.json index 78c90cc3fde..291a4f42762 100644 --- a/adapters/axis/axistest/exemplary/simple-video.json +++ b/adapters/axis/axistest/exemplary/simple-video.json @@ -36,7 +36,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "device": { diff --git a/adapters/axis/axistest/exemplary/simple-web-banner.json b/adapters/axis/axistest/exemplary/simple-web-banner.json index a6e325dc56c..06ba5bc5d54 100644 --- a/adapters/axis/axistest/exemplary/simple-web-banner.json +++ b/adapters/axis/axistest/exemplary/simple-web-banner.json @@ -37,7 +37,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/axis/axistest/supplemental/bad_media_type.json b/adapters/axis/axistest/supplemental/bad_media_type.json index eb2abc86408..bf26adc5418 100644 --- a/adapters/axis/axistest/supplemental/bad_media_type.json +++ b/adapters/axis/axistest/supplemental/bad_media_type.json @@ -23,7 +23,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/axis/axistest/supplemental/bad_response.json b/adapters/axis/axistest/supplemental/bad_response.json index 4467c2a5832..ae1ad6a6a52 100644 --- a/adapters/axis/axistest/supplemental/bad_response.json +++ b/adapters/axis/axistest/supplemental/bad_response.json @@ -35,7 +35,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/axis/axistest/supplemental/status-204.json b/adapters/axis/axistest/supplemental/status-204.json index 0f778c44700..db8cdf2a748 100644 --- a/adapters/axis/axistest/supplemental/status-204.json +++ b/adapters/axis/axistest/supplemental/status-204.json @@ -35,7 +35,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "imp": [ diff --git a/adapters/axis/axistest/supplemental/status-not-200.json b/adapters/axis/axistest/supplemental/status-not-200.json index 5b4888fb916..2d27dcfc674 100644 --- a/adapters/axis/axistest/supplemental/status-not-200.json +++ b/adapters/axis/axistest/supplemental/status-not-200.json @@ -35,7 +35,7 @@ }, "httpCalls": [{ "expectedRequest": { - "uri": "http://prebid.axis-marketplace.com/000000?token=000000", + "uri": "http://prebid.axis-marketplace.com/pbserver", "body": { "id": "test-request-id", "imp": [ diff --git a/static/bidder-info/axis.yaml b/static/bidder-info/axis.yaml index 494091a16df..fe04b6015fb 100644 --- a/static/bidder-info/axis.yaml +++ b/static/bidder-info/axis.yaml @@ -1,4 +1,4 @@ -endpoint: "http://prebid.axis-marketplace.com/{{.AccountID}}?token={{.SourceId}}" +endpoint: "http://prebid.axis-marketplace.com/pbserver" maintainer: email: "help@axis-marketplace.com" capabilities: