Skip to content

Commit

Permalink
Update datablocks adapter (#2838)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmayor authored Sep 4, 2023
1 parent 72afff2 commit 47f840d
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 105 deletions.
12 changes: 3 additions & 9 deletions adapters/datablocks/datablocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (a *DatablocksAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *
"Accept": {"application/json"},
}

// Pull the host and source ID info from the bidder params.
// Pull the source ID info from the bidder params.
reqImps, err := splitImpressions(request.Imp)

if err != nil {
Expand All @@ -45,7 +45,7 @@ func (a *DatablocksAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *
continue
}

urlParams := macros.EndpointTemplateParams{Host: reqExt.Host, SourceId: strconv.Itoa(reqExt.SourceId)}
urlParams := macros.EndpointTemplateParams{SourceId: strconv.Itoa(reqExt.SourceId)}
url, err := macros.ResolveMacros(a.EndpointTemplate, urlParams)

if err != nil {
Expand Down Expand Up @@ -137,7 +137,7 @@ func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpDatablocks, error) {
var datablocksExt openrtb_ext.ExtImpDatablocks
if err := json.Unmarshal(bidderExt.Bidder, &datablocksExt); err != nil {
return nil, &errortypes.BadInput{
Message: fmt.Sprintf("Cannot Resolve host or sourceId: %s", err.Error()),
Message: fmt.Sprintf("Cannot Resolve sourceId: %s", err.Error()),
}
}

Expand All @@ -147,12 +147,6 @@ func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpDatablocks, error) {
}
}

if len(datablocksExt.Host) < 1 {
return nil, &errortypes.BadInput{
Message: "Invalid/Missing Host",
}
}

return &datablocksExt, nil
}

Expand Down
2 changes: 1 addition & 1 deletion adapters/datablocks/datablocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderDatablocks, config.Adapter{
Endpoint: "http://{{.Host}}/openrtb2?sid={{.SourceId}}"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
Endpoint: "http://pbserver.dblks.net/openrtb2?sid={{.SourceId}}"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
Expand Down
10 changes: 5 additions & 5 deletions adapters/datablocks/datablockstest/exemplary/multi-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand All @@ -34,7 +34,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand All @@ -54,7 +54,7 @@
{
"expectedRequest":
{
"uri": "http://search.nutella.datablocks.net/openrtb2?sid=906295",
"uri": "http://pbserver.dblks.net/openrtb2?sid=906295",
"body":
{
"id": "some-request-id",
Expand All @@ -73,7 +73,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand All @@ -91,7 +91,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand Down
6 changes: 3 additions & 3 deletions adapters/datablocks/datablockstest/exemplary/native.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand All @@ -38,7 +38,7 @@
{
"expectedRequest":
{
"uri": "http://search.nutella.datablocks.net/openrtb2?sid=906295",
"uri": "http://pbserver.dblks.net/openrtb2?sid=906295",
"body":
{
"id": "some-request-id",
Expand All @@ -54,7 +54,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand All @@ -41,7 +41,7 @@
{
"expectedRequest":
{
"uri": "http://search.nutella.datablocks.net/openrtb2?sid=906295",
"uri": "http://pbserver.dblks.net/openrtb2?sid=906295",
"body":
{
"id": "some-request-id",
Expand All @@ -64,7 +64,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand All @@ -39,7 +39,7 @@
{
"expectedRequest":
{
"uri": "http://search.nutella.datablocks.net/openrtb2?sid=906295",
"uri": "http://pbserver.dblks.net/openrtb2?sid=906295",
"body":
{
"id": "some-request-id",
Expand All @@ -59,7 +59,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 906295
}
}
Expand Down
33 changes: 0 additions & 33 deletions adapters/datablocks/datablockstest/supplemental/bad-host.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 123
}
}
Expand All @@ -37,7 +37,7 @@
{
"expectedRequest":
{
"uri": "http://search.nutella.datablocks.net/openrtb2?sid=123",
"uri": "http://pbserver.dblks.net/openrtb2?sid=123",
"body":
{
"id": "some-request-id",
Expand All @@ -56,7 +56,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 123
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 123
}
}
Expand All @@ -37,7 +37,7 @@
{
"expectedRequest":
{
"uri": "http://search.nutella.datablocks.net/openrtb2?sid=123",
"uri": "http://pbserver.dblks.net/openrtb2?sid=123",
"body":
{
"id": "some-request-id",
Expand All @@ -56,7 +56,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 123
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 0
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 123
}
}
Expand All @@ -37,7 +37,7 @@
{
"expectedRequest":
{
"uri": "http://search.nutella.datablocks.net/openrtb2?sid=123",
"uri": "http://pbserver.dblks.net/openrtb2?sid=123",
"body":
{
"id": "some-request-id",
Expand All @@ -56,7 +56,7 @@
{
"bidder":
{
"host": "search.nutella.datablocks.net",
"host": "pbserver.dblks.net",
"sourceId": 123
}
}
Expand Down
3 changes: 1 addition & 2 deletions openrtb_ext/imp_datablocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ package openrtb_ext

// ExtImpDatablocks defines the contract for bidrequest.imp[i].ext.prebid.bidder.datablocks
type ExtImpDatablocks struct {
SourceId int `json:"sourceId"`
Host string `json:"host"`
SourceId int `json:"sourceId"`
}
2 changes: 1 addition & 1 deletion static/bidder-info/datablocks.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
endpoint: "http://{{.Host}}/openrtb2?sid={{.SourceId}}"
endpoint: "http://pbserver.dblks.net/openrtb2?sid={{.SourceId}}"
maintainer:
email: "[email protected]"
capabilities:
Expand Down
6 changes: 1 addition & 5 deletions static/bidder-params/datablocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
"type": "integer",
"minimum": 1,
"description": "Website Source Id"
},
"host": {
"type": "string",
"description": "Network Host to request from"
}
},
"required": ["host", "sourceId"]
"required": ["sourceId"]
}

0 comments on commit 47f840d

Please sign in to comment.