-
Notifications
You must be signed in to change notification settings - Fork 861
New Adapter: ElementalTv #4639
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
base: master
Are you sure you want to change the base?
New Adapter: ElementalTv #4639
Changes from 2 commits
494f8c1
fb8f6b1
3cf30b8
b59b75d
5998af2
4f18562
9ae372e
8089b80
e309265
4e5037a
26a6fec
720ecfb
23928f5
2774221
a0f30a9
e0c0fcd
7280fab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package adoppler | ||
| package elementaltv | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
|
|
@@ -17,12 +17,10 @@ import ( | |
| "github.com/prebid/prebid-server/v3/util/jsonutil" | ||
| ) | ||
|
|
||
| const DefaultClient = "app" | ||
|
|
||
| var bidHeaders http.Header = map[string][]string{ | ||
| "Accept": {"application/json"}, | ||
| "Content-Type": {"application/json;charset=utf-8"}, | ||
| "X-OpenRTB-Version": {"2.5"}, | ||
| "X-OpenRTB-Version": {"2.6"}, | ||
| } | ||
|
|
||
| type adsVideoExt struct { | ||
|
|
@@ -33,24 +31,24 @@ type adsImpExt struct { | |
| Video *adsVideoExt `json:"video"` | ||
| } | ||
|
|
||
| type AdopplerAdapter struct { | ||
| type adapter struct { | ||
| endpoint *template.Template | ||
| } | ||
|
|
||
| // Builder builds a new instance of the Adoppler adapter for the given bidder with the given config. | ||
| // Builder builds a new instance of the ElementalTv adapter for the given bidder with the given config. | ||
| 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 := &AdopplerAdapter{ | ||
| bidder := &adapter{ | ||
| endpoint: template, | ||
| } | ||
| return bidder, nil | ||
| } | ||
|
|
||
| func (ads *AdopplerAdapter) MakeRequests( | ||
| func (ads *adapter) MakeRequests( | ||
| req *openrtb2.BidRequest, | ||
| info *adapters.ExtraRequestInfo, | ||
| ) ( | ||
|
|
@@ -100,7 +98,7 @@ func (ads *AdopplerAdapter) MakeRequests( | |
| return datas, errs | ||
| } | ||
|
|
||
| func (ads *AdopplerAdapter) MakeBids( | ||
| func (ads *adapter) MakeBids( | ||
| intReq *openrtb2.BidRequest, | ||
| extReq *adapters.RequestData, | ||
| resp *adapters.ResponseData, | ||
|
|
@@ -193,33 +191,27 @@ func (ads *AdopplerAdapter) MakeBids( | |
| return adsResp, nil | ||
| } | ||
|
|
||
| func (ads *AdopplerAdapter) bidUri(ext *openrtb_ext.ExtImpAdoppler) (string, error) { | ||
| func (ads *adapter) bidUri(ext *openrtb_ext.ExtImpElementalTv) (string, error) { | ||
| params := macros.EndpointTemplateParams{} | ||
| params.AdUnit = url.PathEscape(ext.AdUnit) | ||
| if ext.Client == "" { | ||
| params.AccountID = DefaultClient | ||
| } else { | ||
| params.AccountID = url.PathEscape(ext.Client) | ||
| } | ||
|
|
||
| return macros.ResolveMacros(ads.endpoint, params) | ||
| } | ||
|
|
||
| func unmarshalExt(ext json.RawMessage) (*openrtb_ext.ExtImpAdoppler, error) { | ||
| func unmarshalExt(ext json.RawMessage) (*openrtb_ext.ExtImpElementalTv, error) { | ||
| var bext adapters.ExtImpBidder | ||
| err := jsonutil.Unmarshal(ext, &bext) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| var adsExt openrtb_ext.ExtImpAdoppler | ||
| var adsExt openrtb_ext.ExtImpElementalTv | ||
| err = jsonutil.Unmarshal(bext.Bidder, &adsExt) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if adsExt.AdUnit == "" { | ||
| return nil, errors.New("$.imp.ext.adoppler.adunit required") | ||
| return nil, errors.New("$.imp.ext.bidder.adunit required") | ||
|
||
| } | ||
|
|
||
| return &adsExt, nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package elementaltv | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is missing params_test.go, You can refer other adapters for reference.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/prebid/prebid-server/v3/adapters/adapterstest" | ||
| "github.com/prebid/prebid-server/v3/config" | ||
| "github.com/prebid/prebid-server/v3/openrtb_ext" | ||
| ) | ||
|
|
||
| func TestJsonSamples(t *testing.T) { | ||
| bidder, buildErr := Builder(openrtb_ext.BidderElementalTv, config.Adapter{ | ||
| Endpoint: "https://pbs.elementaltv.io/processHeaderBid/{{.AdUnit}}"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) | ||
|
|
||
| if buildErr != nil { | ||
| t.Fatalf("Builder returned unexpected error %v", buildErr) | ||
| } | ||
|
|
||
| adapterstest.RunJSONBidderTest(t, "elementaltvtest", bidder) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.