Skip to content
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
8 changes: 4 additions & 4 deletions adapters/thetradedesk/thetradedesk.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/prebid/openrtb/v20/openrtb2"
)

//const PREBID_INTEGRATION_TYPE = "1"

type adapter struct {
bidderEndpointTemplate string
defaultEndpoint string
Expand Down Expand Up @@ -87,13 +85,12 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E

bidderEndpoint, err := a.buildEndpointURL(supplySourceId)
if err != nil {
return nil, []error{errors.New("Failed to build endpoint URL")}
return nil, []error{err}
}

headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
//headers.Add("x-integration-type", PREBID_INTEGRATION_TYPE) this will be parsed and added conditionally later
return []*adapters.RequestData{{
Method: "POST",
Uri: bidderEndpoint,
Expand All @@ -105,6 +102,9 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E

func (a *adapter) buildEndpointURL(supplySourceId string) (string, error) {
if supplySourceId == "" {
if a.defaultEndpoint == "" {
Comment thread
andre-gielow-ttd marked this conversation as resolved.
return "", errors.New("Either supplySourceId or a default endpoint must be provided")
Comment thread
andre-gielow-ttd marked this conversation as resolved.
}
return a.defaultEndpoint, nil
}

Expand Down
6 changes: 5 additions & 1 deletion adapters/thetradedesk/thetradedesk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package thetradedesk

import (
"encoding/json"
"errors"
"github.com/prebid/prebid-server/v3/adapters/adapterstest"
"net/http"
"testing"
Expand Down Expand Up @@ -425,7 +426,7 @@ func TestTheTradeDeskAdapter_BuildEndpoint(t *testing.T) {
supplySourceId: "",
defaultEndpoint: "",
expectedEndpoint: "",
wantErr: nil,
wantErr: []error{errors.New("Either supplySourceId or a default endpoint must be provided")},
},
}

Expand All @@ -442,6 +443,9 @@ func TestTheTradeDeskAdapter_BuildEndpoint(t *testing.T) {
finalEndpoint, err := a.buildEndpointURL(tt.supplySourceId)
if tt.wantErr != nil {
assert.NotNil(t, err)
assert.Equal(t, tt.wantErr[0].Error(), err.Error())
} else {
assert.Nil(t, err)
}
assert.Equal(t, tt.expectedEndpoint, finalEndpoint)
})
Expand Down
Loading