Skip to content
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

Rename synacormedia adapter to imds to reflect ownership change #2508

Merged
merged 5 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions adapters/synacormedia/synacormedia.go → adapters/imds/imds.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package synacormedia
package imds

import (
"encoding/json"
Expand All @@ -14,7 +14,7 @@ import (
"github.com/prebid/prebid-server/openrtb_ext"
)

type SynacorMediaAdapter struct {
type adapter struct {
EndpointTemplate *template.Template
}

Expand All @@ -27,20 +27,20 @@ type ReqExt struct {
SeatId string `json:"seatId"`
}

// Builder builds a new instance of the SynacorMedia adapter for the given bidder with the given config.
// Builder builds a new instance of the Imds 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 := &SynacorMediaAdapter{
bidder := &adapter{
EndpointTemplate: template,
}
return bidder, nil
}

func (a *SynacorMediaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
var errs []error
var bidRequests []*adapters.RequestData

Expand All @@ -53,11 +53,11 @@ func (a *SynacorMediaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo
return bidRequests, errs
}

func (a *SynacorMediaAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) {
func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) {
var errs []error
var validImps []openrtb2.Imp
var re *ReqExt
var firstExtImp *openrtb_ext.ExtImpSynacormedia = nil
var firstExtImp *openrtb_ext.ExtImpImds = nil

for _, imp := range request.Imp {
validExtImpObj, err := getExtImpObj(&imp) // getExtImpObj returns {seatId:"", tagId:""}
Expand Down Expand Up @@ -126,30 +126,30 @@ func (a *SynacorMediaAdapter) makeRequest(request *openrtb2.BidRequest) (*adapte
}

// Builds enpoint url based on adapter-specific pub settings from imp.ext
func (adapter *SynacorMediaAdapter) buildEndpointURL(params *openrtb_ext.ExtImpSynacormedia) (string, error) {
func (adapter *adapter) buildEndpointURL(params *openrtb_ext.ExtImpImds) (string, error) {
return macros.ResolveMacros(adapter.EndpointTemplate, macros.EndpointTemplateParams{Host: params.SeatId})
}

func getExtImpObj(imp *openrtb2.Imp) (*openrtb_ext.ExtImpSynacormedia, error) {
func getExtImpObj(imp *openrtb2.Imp) (*openrtb_ext.ExtImpImds, error) {
var bidderExt adapters.ExtImpBidder
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return nil, &errortypes.BadInput{
Message: err.Error(),
}
}

var synacormediaExt openrtb_ext.ExtImpSynacormedia
if err := json.Unmarshal(bidderExt.Bidder, &synacormediaExt); err != nil {
var imdsExt openrtb_ext.ExtImpImds
if err := json.Unmarshal(bidderExt.Bidder, &imdsExt); err != nil {
return nil, &errortypes.BadInput{
Message: err.Error(),
}
}

return &synacormediaExt, nil
return &imdsExt, nil
}

// MakeBids make the bids for the bid response.
func (a *SynacorMediaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
const errorMessage string = "Unexpected status code: %d. Run with request.debug = 1 for more info"
switch {
case response.StatusCode == http.StatusNoContent:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package synacormedia
package imds

import (
"testing"
Expand All @@ -10,18 +10,18 @@ import (
)

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderSynacormedia, config.Adapter{
bidder, buildErr := Builder(openrtb_ext.BidderImds, config.Adapter{
Endpoint: "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}

adapterstest.RunJSONBidderTest(t, "synacormediatest", bidder)
adapterstest.RunJSONBidderTest(t, "imdstest", bidder)
}

func TestEndpointTemplateMalformed(t *testing.T) {
_, buildErr := Builder(openrtb_ext.BidderSynacormedia, config.Adapter{
_, buildErr := Builder(openrtb_ext.BidderImds, config.Adapter{
Endpoint: "{{Malformed}}"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})

assert.Error(t, buildErr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@
}
}
],
"seat": "synacormedia"
"seat": "imds"
}
],
"ext": {
"responsetimemillis": {
"synacormedia": 339
"imds": 339
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
}
}
],
"seat": "synacormedia"
"seat": "imds"
}
],
"ext": {
"responsetimemillis": {
"synacormedia": 339
"imds": 339
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

"expectedMakeRequestsErrors": [
{
"value": "json: cannot unmarshal number into Go struct field ExtImpSynacormedia.seatId of type string",
"value": "json: cannot unmarshal number into Go struct field ExtImpImds.seatId of type string",
"comparison": "literal"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@
}
}
],
"seat": "synacormedia"
"seat": "imds"
}
],
"ext": {
"responsetimemillis": {
"synacormedia": 339
"imds": 339
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package synacormedia
package imds

import (
"encoding/json"
Expand All @@ -7,33 +7,33 @@ import (
"github.com/prebid/prebid-server/openrtb_ext"
)

// This file actually intends to test static/bidder-params/synacormedia.json
// This file actually intends to test static/bidder-params/imds.json
//
// These also validate the format of the external API: request.imp[i].ext.prebid.bidder.synacormedia
// These also validate the format of the external API: request.imp[i].ext.prebid.bidder.imds

// TestValidParams makes sure that the synacormedia schema accepts all imp.ext fields which we intend to support.
// TestValidParams makes sure that the imds schema accepts all imp.ext fields which we intend to support.
func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json-schemas. %v", err)
}

for _, validParam := range validParams {
if err := validator.Validate(openrtb_ext.BidderSynacormedia, json.RawMessage(validParam)); err != nil {
t.Errorf("Schema rejected synacormedia params: %s", validParam)
if err := validator.Validate(openrtb_ext.BidderImds, json.RawMessage(validParam)); err != nil {
t.Errorf("Schema rejected imds params: %s", validParam)
}
}
}

// TestInvalidParams makes sure that the synacormedia schema rejects all the imp.ext fields we don't support.
// TestInvalidParams makes sure that the imds schema rejects all the imp.ext fields we don't support.
func TestInvalidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json-schemas. %v", err)
}

for _, invalidParam := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderSynacormedia, json.RawMessage(invalidParam)); err == nil {
if err := validator.Validate(openrtb_ext.BidderImds, json.RawMessage(invalidParam)); err == nil {
t.Errorf("Schema allowed unexpected params: %s", invalidParam)
}
}
Expand Down
5 changes: 3 additions & 2 deletions exchange/adapter_builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import (
"github.com/prebid/prebid-server/adapters/grid"
"github.com/prebid/prebid-server/adapters/gumgum"
"github.com/prebid/prebid-server/adapters/huaweiads"
"github.com/prebid/prebid-server/adapters/imds"
"github.com/prebid/prebid-server/adapters/impactify"
"github.com/prebid/prebid-server/adapters/improvedigital"
"github.com/prebid/prebid-server/adapters/infytv"
Expand Down Expand Up @@ -134,7 +135,6 @@ import (
"github.com/prebid/prebid-server/adapters/sspBC"
"github.com/prebid/prebid-server/adapters/stroeerCore"
"github.com/prebid/prebid-server/adapters/suntContent"
"github.com/prebid/prebid-server/adapters/synacormedia"
"github.com/prebid/prebid-server/adapters/taboola"
"github.com/prebid/prebid-server/adapters/tappx"
"github.com/prebid/prebid-server/adapters/telaria"
Expand Down Expand Up @@ -240,6 +240,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder {
openrtb_ext.BidderGroupm: pubmatic.Builder,
openrtb_ext.BidderGumGum: gumgum.Builder,
openrtb_ext.BidderHuaweiAds: huaweiads.Builder,
openrtb_ext.BidderImds: imds.Builder,
openrtb_ext.BidderImpactify: impactify.Builder,
openrtb_ext.BidderImprovedigital: improvedigital.Builder,
openrtb_ext.BidderInfyTV: infytv.Builder,
Expand Down Expand Up @@ -303,7 +304,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder {
openrtb_ext.BidderStreamkey: adtelligent.Builder,
openrtb_ext.BidderSuntContent: suntContent.Builder,
openrtb_ext.BidderStroeerCore: stroeerCore.Builder,
openrtb_ext.BidderSynacormedia: synacormedia.Builder,
openrtb_ext.BidderSynacormedia: imds.Builder,
openrtb_ext.BidderTaboola: taboola.Builder,
openrtb_ext.BidderTappx: tappx.Builder,
openrtb_ext.BidderTelaria: telaria.Builder,
Expand Down
2 changes: 2 additions & 0 deletions openrtb_ext/bidders.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const (
BidderGroupm BidderName = "groupm"
BidderGumGum BidderName = "gumgum"
BidderHuaweiAds BidderName = "huaweiads"
BidderImds BidderName = "imds"
BidderImpactify BidderName = "impactify"
BidderImprovedigital BidderName = "improvedigital"
BidderInfyTV BidderName = "infytv"
Expand Down Expand Up @@ -329,6 +330,7 @@ func CoreBidderNames() []BidderName {
BidderGroupm,
BidderGumGum,
BidderHuaweiAds,
BidderImds,
BidderImpactify,
BidderImprovedigital,
BidderInfyTV,
Expand Down
7 changes: 7 additions & 0 deletions openrtb_ext/imp_imds.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package openrtb_ext

// ExtImpImds defines the contract for bidrequest.imp[i].ext.prebid.bidder.imds
type ExtImpImds struct {
SeatId string `json:"seatId"`
TagId string `json:"tagId"`
}
7 changes: 0 additions & 7 deletions openrtb_ext/imp_synacormedia.go

This file was deleted.

20 changes: 20 additions & 0 deletions static/bidder-info/imds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
endpoint: "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}"
maintainer:
email: "[email protected]"
capabilities:
app:
mediaTypes:
- banner
- video
site:
mediaTypes:
- banner
- video
userSync:
ecammit marked this conversation as resolved.
Show resolved Hide resolved
supportCors: true
iframe:
url: "https://ad-cdn.technoratimedia.com/html/usersync.html?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb={{.RedirectURL}}"
userMacro: "[USER_ID]"
redirect:
url: "https://sync.technoratimedia.com/services?srv=cs&gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb={{.RedirectURL}}"
userMacro: "[USER_ID]"
10 changes: 8 additions & 2 deletions static/bidder-info/synacormedia.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# DEPRECATED: Use imds bidder instead
endpoint: "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}"
maintainer:
email: "[email protected]"
Expand All @@ -11,6 +12,11 @@ capabilities:
- banner
- video
userSync:
key: "imds"
supportCors: true
iframe:
url: "https://ad-cdn.technoratimedia.com/html/usersync.html?cb={{.RedirectURL}}"
userMacro: "[USER_ID]"
url: "https://ad-cdn.technoratimedia.com/html/usersync.html?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb={{.RedirectURL}}"
userMacro: "[USER_ID]"
redirect:
url: "https://sync.technoratimedia.com/services?srv=cs&gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb={{.RedirectURL}}"
userMacro: "[USER_ID]"
19 changes: 19 additions & 0 deletions static/bidder-params/imds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "iMedia Digital Services (IMDS) Adapter Params",
"description": "A schema which validates params accepted by the iMedia Digital Services (IMDS) adapter",

"type": "object",
"properties": {
"seatId": {
"type": "string",
"description": "The seat id."
},
"tagId": {
"type": "string",
"description": "The tag id."
}
},

"required": ["seatId"]
}
2 changes: 1 addition & 1 deletion static/bidder-params/synacormedia.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Synacormedia Adapter Params",
"description": "A schema which validates params accepted by the Synacormedia adapter",
"description": "DEPRECATED: Use imds bidder instead. A schema which validates params accepted by the Synacormedia adapter",

"type": "object",
"properties": {
Expand Down