Skip to content

Commit cd6f915

Browse files
author
QuentinGallard
committed
SmileWanted endpoint now supports dynamic zoneId and integrates prebid server technology
1 parent 03b2e67 commit cd6f915

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

adapters/smilewanted/smilewanted.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,33 @@ type adapter struct {
1717
URI string
1818
}
1919

20+
// ExtImpSmilewanted defines the contract for bidrequest.imp[i].ext.prebid.bidder.smilewanted
21+
type ExtImpSmilewanted struct {
22+
ZoneId string `json:"zoneId"`
23+
}
24+
2025
func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
26+
var errs []error
27+
28+
// Extract zoneId from the first impression if available
29+
var zoneId string
30+
if len(request.Imp) > 0 {
31+
// Parse imp.ext
32+
var bidderExt adapters.ExtImpBidder
33+
if err := jsonutil.Unmarshal(request.Imp[0].Ext, &bidderExt); err == nil {
34+
// Parse bidderExt.Bidder to get zoneId
35+
var smilewantedExt ExtImpSmilewanted
36+
if err := jsonutil.Unmarshal(bidderExt.Bidder, &smilewantedExt); err == nil {
37+
zoneId = smilewantedExt.ZoneId
38+
}
39+
}
40+
}
41+
42+
// Build the endpoint URL with zoneId
43+
endpoint := a.URI
44+
if zoneId != "" {
45+
endpoint = a.URI + zoneId
46+
}
2147

2248
request.AT = 1 //Defaulting to first price auction for all prebid requests
2349

@@ -36,11 +62,11 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E
3662

3763
return []*adapters.RequestData{{
3864
Method: "POST",
39-
Uri: a.URI,
65+
Uri: endpoint,
4066
Body: reqJSON,
4167
Headers: headers,
4268
ImpIDs: openrtb_ext.GetImpIDs(request.Imp),
43-
}}, []error{}
69+
}}, errs
4470
}
4571

4672
func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {

adapters/smilewanted/smilewanted_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func TestJsonSamples(t *testing.T) {
1212
bidder, buildErr := Builder(openrtb_ext.BidderSmileWanted, config.Adapter{
13-
Endpoint: "http://example.com"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
13+
Endpoint: "http://example.com/go/"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
1414

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

adapters/smilewanted/smilewantedtest/exemplary/simple-banner.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"mockBidRequest": {
33
"id": "test-request-id",
4+
"at": 1,
45
"imp": [
56
{
67
"id": "test-imp-id",
7-
"at" : 1,
88
"banner": {
99
"format": [
1010
{
@@ -25,10 +25,10 @@
2525
"httpCalls": [
2626
{
2727
"expectedRequest": {
28-
"uri": "http://example.com",
28+
"uri": "http://example.com/go/zone_code_test_display",
2929
"body": {
3030
"id": "test-request-id",
31-
"at" : 1,
31+
"at": 1,
3232
"imp": [
3333
{
3434
"id": "test-imp-id",

adapters/smilewanted/smilewantedtest/exemplary/simple-video.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"mockBidRequest": {
33
"id": "test-request-id",
4+
"at": 1,
45
"imp": [
56
{
67
"id": "test-imp-id",
@@ -22,7 +23,7 @@
2223
"httpCalls": [
2324
{
2425
"expectedRequest": {
25-
"uri": "http://example.com",
26+
"uri": "http://example.com/go/zone_code_test_video",
2627
"body": {
2728
"id": "test-request-id",
2829
"at": 1,

static/bidder-info/smilewanted.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
endpoint: "https://prebid-server.smilewanted.com"
1+
endpoint: "https://prebid-server.smilewanted.com/go/"
22
maintainer:
33
email: "tech@smilewanted.com"
44
gvlVendorID: 639

0 commit comments

Comments
 (0)