Skip to content

Commit

Permalink
enhance endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
monicaroxanabota committed Feb 14, 2025
1 parent fe354b5 commit f0663dd
Show file tree
Hide file tree
Showing 5 changed files with 729 additions and 1 deletion.
32 changes: 31 additions & 1 deletion adapters/connatix/connatix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"

"github.com/buger/jsonparser"
Expand Down Expand Up @@ -155,9 +156,38 @@ func splitRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, uri string
return nil, errs
}

endpoint, err := url.Parse(uri)
if err != nil {
errs = append(errs, err)
fmt.Println("cnx_errors: ", errs)
return nil, errs
}

if request.User != nil {
userID := strings.TrimSpace(request.User.BuyerUID)

if len(userID) > 0 {
queryParams := url.Values{}

if strings.HasPrefix(userID, "1-") {
queryParams.Add("dc", "us-east-2")
}

if strings.HasPrefix(userID, "2-") {
queryParams.Add("dc", "us-west-2")
}

if strings.HasPrefix(userID, "3-") {
queryParams.Add("dc", "eu-west-1")
}

endpoint.RawQuery = queryParams.Encode()
}
}

resArr = append(resArr, &adapters.RequestData{
Method: "POST",
Uri: uri,
Uri: endpoint.String(),
Body: reqJSON,
Headers: headers,
ImpIDs: openrtb_ext.GetImpIDs(request.Imp),
Expand Down
176 changes: 176 additions & 0 deletions adapters/connatix/connatixtest/supplemental/bid-request-eu-user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"mockBidRequest": {
"id": "some-request-id",
"device": {
"ua": "test-user-agent",
"ip": "123.123.123.123",
"language": "en",
"dnt": 0
},
"tmax": 500,
"user": {
"buyeruid": "3-some-user"
},
"app": {
"publisher": {
"id": "123456789"
},
"cat": [
"IAB22-1"
],
"bundle": "com.app.awesome",
"name": "Awesome App",
"domain": "awesomeapp.com",
"id": "123456789",
"ext": {
"prebid": {
"source": "test",
"version": "1.0.0"
}
}
},
"imp": [
{
"id": "some-imp-id",
"tagid": "some-tag-id",
"banner": {
"format":[
{
"w": 320,
"h": 50
}
]
},
"ext": {
"bidder": {
"placementId": "some-placement-id",
"viewabilityPercentage": 0.6
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://example.com?dc=eu-west-1",
"body": {
"id": "some-request-id",
"device": {
"ua": "test-user-agent",
"ip": "123.123.123.123",
"language": "en",
"dnt": 0
},
"imp": [
{
"id": "some-imp-id",
"tagid": "some-tag-id",
"banner": {
"w": 320,
"h": 50,
"format": [
{
"w": 320,
"h": 50
}
]
},
"displaymanagerver": "test-1.0.0",
"ext": {
"connatix": {
"placementId": "some-placement-id",
"viewabilityPercentage": 0.6
}
}
}
],
"app": {
"id": "123456789",
"name": "Awesome App",
"bundle": "com.app.awesome",
"domain": "awesomeapp.com",
"cat": [
"IAB22-1"
],
"publisher": {
"id": "123456789"
},
"ext": {
"prebid": {
"source": "test",
"version": "1.0.0"
}
}
},
"user": {
"buyeruid": "3-some-user"
},
"tmax": 500
},
"impIDs": [
"some-imp-id"
]
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-response-id",
"seatbid": [
{
"bid": [
{
"id": "some-bid-id",
"impid": "some-imp-id",
"price": 0.52,
"adm": "some-test-ad",
"adomain": [
"test.com"
],
"crid": "112233",
"w": 320,
"h": 50,
"ext": {
"connatix": {
"mediaType": "banner"
}
}
}
],
"seat": "connatix",
"group": 0
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "some-bid-id",
"impid": "some-imp-id",
"price": 0.52,
"adm": "some-test-ad",
"crid": "112233",
"adomain": [
"test.com"
],
"w": 320,
"h": 50,
"ext": {
"connatix": {
"mediaType": "banner"
}
}
},
"type": "banner"
}
]
}
]
}
170 changes: 170 additions & 0 deletions adapters/connatix/connatixtest/supplemental/bid-request-no-user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
{
"mockBidRequest": {
"id": "some-request-id",
"device": {
"ua": "test-user-agent",
"ip": "123.123.123.123",
"language": "en",
"dnt": 0
},
"tmax": 500,
"app": {
"publisher": {
"id": "123456789"
},
"cat": [
"IAB22-1"
],
"bundle": "com.app.awesome",
"name": "Awesome App",
"domain": "awesomeapp.com",
"id": "123456789",
"ext": {
"prebid": {
"source": "test",
"version": "1.0.0"
}
}
},
"imp": [
{
"id": "some-imp-id",
"tagid": "some-tag-id",
"banner": {
"format":[
{
"w": 320,
"h": 50
}
]
},
"ext": {
"bidder": {
"placementId": "some-placement-id",
"viewabilityPercentage": 0.6
}
}
}
]
},
"httpCalls": [
{
"expectedRequest": {
"uri": "http://example.com",
"body": {
"id": "some-request-id",
"device": {
"ua": "test-user-agent",
"ip": "123.123.123.123",
"language": "en",
"dnt": 0
},
"imp": [
{
"id": "some-imp-id",
"tagid": "some-tag-id",
"banner": {
"w": 320,
"h": 50,
"format": [
{
"w": 320,
"h": 50
}
]
},
"displaymanagerver": "test-1.0.0",
"ext": {
"connatix": {
"placementId": "some-placement-id",
"viewabilityPercentage": 0.6
}
}
}
],
"app": {
"id": "123456789",
"name": "Awesome App",
"bundle": "com.app.awesome",
"domain": "awesomeapp.com",
"cat": [
"IAB22-1"
],
"publisher": {
"id": "123456789"
},
"ext": {
"prebid": {
"source": "test",
"version": "1.0.0"
}
}
},
"tmax": 500
},
"impIDs": [
"some-imp-id"
]
},
"mockResponse": {
"status": 200,
"body": {
"id": "test-response-id",
"seatbid": [
{
"bid": [
{
"id": "some-bid-id",
"impid": "some-imp-id",
"price": 0.52,
"adm": "some-test-ad",
"adomain": [
"test.com"
],
"crid": "112233",
"w": 320,
"h": 50,
"ext": {
"connatix": {
"mediaType": "banner"
}
}
}
],
"seat": "connatix",
"group": 0
}
],
"cur": "USD"
}
}
}
],
"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "some-bid-id",
"impid": "some-imp-id",
"price": 0.52,
"adm": "some-test-ad",
"crid": "112233",
"adomain": [
"test.com"
],
"w": 320,
"h": 50,
"ext": {
"connatix": {
"mediaType": "banner"
}
}
},
"type": "banner"
}
]
}
]
}
Loading

0 comments on commit f0663dd

Please sign in to comment.