diff --git a/adapters/ortbbidder/ortbbidder.go b/adapters/ortbbidder/ortbbidder.go index 0955bd03b88..44520a70f4a 100644 --- a/adapters/ortbbidder/ortbbidder.go +++ b/adapters/ortbbidder/ortbbidder.go @@ -11,17 +11,17 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) -// oRTBAdapter implements adapters.Bidder interface -type oRTBAdapter struct { - oRTBAdapterInfo +// adapter implements adapters.Bidder interface +type adapter struct { + adapterInfo } const ( RequestModeSingle string = "single" ) -// oRTBAdapterInfo contains oRTB bidder specific info required in MakeRequests/MakeBids functions -type oRTBAdapterInfo struct { +// adapterInfo contains oRTB bidder specific info required in MakeRequests/MakeBids functions +type adapterInfo struct { config.Adapter requestMode string } @@ -30,7 +30,7 @@ type ExtraAdapterInfo struct { } // prepareRequestData generates the RequestData by marshalling the request and returns it -func (o oRTBAdapterInfo) prepareRequestData(request *openrtb2.BidRequest) (*adapters.RequestData, error) { +func (o adapterInfo) prepareRequestData(request *openrtb2.BidRequest) (*adapters.RequestData, error) { if request == nil { return nil, fmt.Errorf("found nil request") } @@ -54,17 +54,17 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co return nil, fmt.Errorf("Failed to parse extra_info for bidder:[%s] err:[%s]", bidderName, err.Error()) } } - return &oRTBAdapter{ - oRTBAdapterInfo: oRTBAdapterInfo{config, extraAdapterInfo.RequestMode}, + return &adapter{ + adapterInfo: adapterInfo{config, extraAdapterInfo.RequestMode}, }, nil } // MakeRequests prepares oRTB bidder-specific request information using which prebid server make call(s) to bidder. -func (o *oRTBAdapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (o *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if request == nil || requestInfo == nil { return nil, []error{fmt.Errorf("Found either nil request or nil requestInfo")} } - adapterInfo := o.oRTBAdapterInfo + adapterInfo := o.adapterInfo // bidder request supports single impression in single HTTP call. if adapterInfo.requestMode == RequestModeSingle { requestData := make([]*adapters.RequestData, 0, len(request.Imp)) @@ -88,7 +88,7 @@ func (o *oRTBAdapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *ad } // MakeBids prepares bidderResponse from the oRTB bidder server's http.Response -func (o *oRTBAdapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (o *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData == nil || adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } diff --git a/adapters/ortbbidder/ortbbidder_test.go b/adapters/ortbbidder/ortbbidder_test.go index 8957bfb074e..383843add4d 100644 --- a/adapters/ortbbidder/ortbbidder_test.go +++ b/adapters/ortbbidder/ortbbidder_test.go @@ -19,7 +19,7 @@ func TestMakeRequests(t *testing.T) { type args struct { request *openrtb2.BidRequest requestInfo *adapters.ExtraRequestInfo - adapterInfo oRTBAdapterInfo + adapterInfo adapterInfo } type want struct { requestData []*adapters.RequestData @@ -57,7 +57,7 @@ func TestMakeRequests(t *testing.T) { requestInfo: &adapters.ExtraRequestInfo{ BidderCoreName: openrtb_ext.BidderName("ortb_test_multi_requestmode"), }, - adapterInfo: oRTBAdapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, ""}, + adapterInfo: adapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, ""}, }, want: want{ requestData: []*adapters.RequestData{ @@ -82,7 +82,7 @@ func TestMakeRequests(t *testing.T) { requestInfo: &adapters.ExtraRequestInfo{ BidderCoreName: openrtb_ext.BidderName("ortb_test_single_requestmode"), }, - adapterInfo: oRTBAdapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, "single"}, + adapterInfo: adapterInfo{config.Adapter{Endpoint: "http://test_bidder.com"}, "single"}, }, want: want{ requestData: []*adapters.RequestData{ @@ -102,7 +102,7 @@ func TestMakeRequests(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - adapter := &oRTBAdapter{oRTBAdapterInfo: tt.args.adapterInfo} + adapter := &adapter{adapterInfo: tt.args.adapterInfo} requestData, errors := adapter.MakeRequests(tt.args.request, tt.args.requestInfo) assert.Equalf(t, tt.want.requestData, requestData, "mismatched requestData") assert.Equalf(t, tt.want.errors, errors, "mismatched errors") @@ -205,7 +205,7 @@ func TestMakeBids(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - adapter := &oRTBAdapter{} + adapter := &adapter{} response, errs := adapter.MakeBids(tt.args.request, tt.args.requestData, tt.args.responseData) assert.Equalf(t, tt.want.response, response, "mismatched response") assert.Equalf(t, tt.want.errors, errs, "mismatched errors") @@ -404,7 +404,7 @@ func Test_oRTBAdapterInfo_prepareRequestData(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - o := oRTBAdapterInfo{ + o := adapterInfo{ Adapter: tt.fields.Adapter, requestMode: tt.fields.requestMode, } @@ -454,8 +454,8 @@ func TestBuilder(t *testing.T) { server: config.Server{}, }, want: want{ - bidder: &oRTBAdapter{ - oRTBAdapterInfo: oRTBAdapterInfo{ + bidder: &adapter{ + adapterInfo: adapterInfo{ requestMode: "single", Adapter: config.Adapter{ ExtraAdapterInfo: `{"requestMode":"single"}`, @@ -475,8 +475,8 @@ func TestBuilder(t *testing.T) { server: config.Server{}, }, want: want{ - bidder: &oRTBAdapter{ - oRTBAdapterInfo: oRTBAdapterInfo{ + bidder: &adapter{ + adapterInfo: adapterInfo{ Adapter: config.Adapter{ ExtraAdapterInfo: ``, },