From cfcb9c47a5ed507fbbfc7f71d56c1b46c144f9b6 Mon Sep 17 00:00:00 2001 From: PGAMSSP Date: Fri, 18 Aug 2023 09:59:41 +0300 Subject: [PATCH 1/7] new adapter PGAMSSP --- adapters/pgamssp/params_test.go | 47 ++++++ adapters/pgamssp/pgamssp.go | 154 ++++++++++++++++++ adapters/pgamssp/pgamssp_test.go | 20 +++ .../pgamssptest/exemplary/endpointId.json | 133 +++++++++++++++ .../pgamssptest/exemplary/simple-banner.json | 133 +++++++++++++++ .../pgamssptest/exemplary/simple-native.json | 117 +++++++++++++ .../pgamssptest/exemplary/simple-video.json | 128 +++++++++++++++ .../exemplary/simple-web-banner.json | 133 +++++++++++++++ .../supplemental/bad_media_type.json | 86 ++++++++++ .../supplemental/bad_response.json | 84 ++++++++++ .../pgamssptest/supplemental/status-204.json | 79 +++++++++ .../supplemental/status-not-200.json | 84 ++++++++++ exchange/adapter_builders.go | 2 + openrtb_ext/bidders.go | 2 + openrtb_ext/imp_pgamssp.go | 6 + static/bidder-info/pgamssp.yaml | 19 +++ static/bidder-params/pgamssp.json | 23 +++ 17 files changed, 1250 insertions(+) create mode 100644 adapters/pgamssp/params_test.go create mode 100644 adapters/pgamssp/pgamssp.go create mode 100644 adapters/pgamssp/pgamssp_test.go create mode 100644 adapters/pgamssp/pgamssptest/exemplary/endpointId.json create mode 100644 adapters/pgamssp/pgamssptest/exemplary/simple-banner.json create mode 100644 adapters/pgamssp/pgamssptest/exemplary/simple-native.json create mode 100644 adapters/pgamssp/pgamssptest/exemplary/simple-video.json create mode 100644 adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json create mode 100644 adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json create mode 100644 adapters/pgamssp/pgamssptest/supplemental/bad_response.json create mode 100644 adapters/pgamssp/pgamssptest/supplemental/status-204.json create mode 100644 adapters/pgamssp/pgamssptest/supplemental/status-not-200.json create mode 100644 openrtb_ext/imp_pgamssp.go create mode 100644 static/bidder-info/pgamssp.yaml create mode 100644 static/bidder-params/pgamssp.json diff --git a/adapters/pgamssp/params_test.go b/adapters/pgamssp/params_test.go new file mode 100644 index 00000000000..3e603237535 --- /dev/null +++ b/adapters/pgamssp/params_test.go @@ -0,0 +1,47 @@ +package pgamssp + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range validParams { + if err := validator.Validate(openrtb_ext.BidderPGAMSsp, json.RawMessage(p)); err != nil { + t.Errorf("Schema rejected valid params: %s", p) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderPGAMSsp, json.RawMessage(p)); err == nil { + t.Errorf("Schema allowed invalid params: %s", p) + } + } +} + +var validParams = []string{ + `{"placementId": "test"}`, + `{"placementId": "1"}`, + `{"endpointId": "test"}`, + `{"endpointId": "1"}`, +} + +var invalidParams = []string{ + `{"placementId": 42}`, + `{"endpointId": 42}`, + `{"placementId": "1", "endpointId": "1"}`, +} diff --git a/adapters/pgamssp/pgamssp.go b/adapters/pgamssp/pgamssp.go new file mode 100644 index 00000000000..e4176542da6 --- /dev/null +++ b/adapters/pgamssp/pgamssp.go @@ -0,0 +1,154 @@ +package pgamssp + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/prebid/openrtb/v19/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" +) + +type adapter struct { + endpoint string +} + +type reqBodyExt struct { + PGAMSspBidderExt reqBodyExtBidder `json:"bidder"` +} + +type reqBodyExtBidder struct { + Type string `json:"type"` + PlacementID string `json:"placementId,omitempty"` + EndpointID string `json:"endpointId,omitempty"` +} + +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var err error + var adapterRequests []*adapters.RequestData + + reqCopy := *request + for _, imp := range request.Imp { + reqCopy.Imp = []openrtb2.Imp{imp} + + var bidderExt adapters.ExtImpBidder + var pgamExt openrtb_ext.ImpExtPgamSsp + + if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { + return nil, []error{err} + } + if err = json.Unmarshal(bidderExt.Bidder, &pgamExt); err != nil { + return nil, []error{err} + } + + temp := reqBodyExt{PGAMSspBidderExt: reqBodyExtBidder{}} + + if pgamExt.PlacementID != "" { + temp.PGAMSspBidderExt.PlacementID = pgamExt.PlacementID + temp.PGAMSspBidderExt.Type = "publisher" + } else if pgamExt.EndpointID != "" { + temp.PGAMSspBidderExt.EndpointID = pgamExt.EndpointID + temp.PGAMSspBidderExt.Type = "network" + } + + finalyImpExt, err := json.Marshal(temp) + if err != nil { + return nil, []error{err} + } + + reqCopy.Imp[0].Ext = finalyImpExt + + adapterReq, err := a.makeRequest(&reqCopy) + if err != nil { + return nil, []error{err} + } + + if adapterReq != nil { + adapterRequests = append(adapterRequests, adapterReq) + } + } + return adapterRequests, nil +} + +func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { + reqJSON, err := json.Marshal(request) + if err != nil { + return nil, err + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + return &adapters.RequestData{ + Method: "POST", + Uri: a.endpoint, + Body: reqJSON, + Headers: headers, + }, err +} + +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if responseData.StatusCode == http.StatusNoContent { + return nil, nil + } + + if responseData.StatusCode != http.StatusOK { + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), + } + return nil, []error{err} + } + + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur + for _, seatBid := range response.SeatBid { + for i := range seatBid.Bid { + bidType, err := getMediaTypeForImp(seatBid.Bid[i].ImpID, request.Imp) + if err != nil { + return nil, []error{err} + } + + b := &adapters.TypedBid{ + Bid: &seatBid.Bid[i], + BidType: bidType, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + return bidResponse, nil +} + +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { + for _, imp := range imps { + if imp.ID == impID { + if imp.Banner != nil { + return openrtb_ext.BidTypeBanner, nil + } + if imp.Video != nil { + return openrtb_ext.BidTypeVideo, nil + } + if imp.Native != nil { + return openrtb_ext.BidTypeNative, nil + } + } + } + + return "", &errortypes.BadInput{ + Message: fmt.Sprintf("Failed to find impression \"%s\"", impID), + } +} diff --git a/adapters/pgamssp/pgamssp_test.go b/adapters/pgamssp/pgamssp_test.go new file mode 100644 index 00000000000..596b813c888 --- /dev/null +++ b/adapters/pgamssp/pgamssp_test.go @@ -0,0 +1,20 @@ +package pgamssp + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderPGAMSsp, config.Adapter{ + Endpoint: "http://test.com/pserver"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "pgamssptest", bidder) +} diff --git a/adapters/pgamssp/pgamssptest/exemplary/endpointId.json b/adapters/pgamssp/pgamssptest/exemplary/endpointId.json new file mode 100644 index 00000000000..efd5084f484 --- /dev/null +++ b/adapters/pgamssp/pgamssptest/exemplary/endpointId.json @@ -0,0 +1,133 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "endpointId": "test" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "endpointId": "test", + "type": "network" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "pgamssp" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-banner.json b/adapters/pgamssp/pgamssptest/exemplary/simple-banner.json new file mode 100644 index 00000000000..816c0c43cc0 --- /dev/null +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-banner.json @@ -0,0 +1,133 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "pgamssp" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-native.json b/adapters/pgamssp/pgamssptest/exemplary/simple-native.json new file mode 100644 index 00000000000..74501451776 --- /dev/null +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-native.json @@ -0,0 +1,117 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "native": { + "request": "{\"ver\":\"1.1\",\"layout\":1,\"adunit\":2,\"plcmtcnt\":6,\"plcmttype\":4,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"wmin\":492,\"hmin\":328,\"type\":3,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":4,\"required\":0,\"data\":{\"type\":6}},{\"id\":5,\"required\":0,\"data\":{\"type\":7}},{\"id\":6,\"required\":0,\"data\":{\"type\":1,\"len\":20}}]}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "native": { + "request": "{\"ver\":\"1.1\",\"layout\":1,\"adunit\":2,\"plcmtcnt\":6,\"plcmttype\":4,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"wmin\":492,\"hmin\":328,\"type\":3,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":4,\"required\":0,\"data\":{\"type\":6}},{\"id\":5,\"required\":0,\"data\":{\"type\":7}},{\"id\":6,\"required\":0,\"data\":{\"type\":1,\"len\":20}}]}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "native" + } + } + } + ], + "seat": "pgamssp" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "native" + } + } + }, + "type": "native" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-video.json b/adapters/pgamssp/pgamssptest/exemplary/simple-video.json new file mode 100644 index 00000000000..f949713069f --- /dev/null +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-video.json @@ -0,0 +1,128 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ua": "iPad" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + } + ], + "seat": "pgamssp" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json b/adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json new file mode 100644 index 00000000000..da168b7e5b2 --- /dev/null +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json @@ -0,0 +1,133 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123", + "ua": "Ubuntu" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "test", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123", + "ua": "Ubuntu" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "pgamssp" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json b/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json new file mode 100644 index 00000000000..48409ba4458 --- /dev/null +++ b/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json @@ -0,0 +1,86 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "pgamssp" + } + ], + "cur": "USD" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Failed to find impression \"test-imp-id\"", + "comparison": "literal" + } + ] +} diff --git a/adapters/pgamssp/pgamssptest/supplemental/bad_response.json b/adapters/pgamssp/pgamssptest/supplemental/bad_response.json new file mode 100644 index 00000000000..8c9f6f523fe --- /dev/null +++ b/adapters/pgamssp/pgamssptest/supplemental/bad_response.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 200, + "body": "" + } + }], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "comparison": "literal" + } + ] +} diff --git a/adapters/pgamssp/pgamssptest/supplemental/status-204.json b/adapters/pgamssp/pgamssptest/supplemental/status-204.json new file mode 100644 index 00000000000..3869591eb40 --- /dev/null +++ b/adapters/pgamssp/pgamssptest/supplemental/status-204.json @@ -0,0 +1,79 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + }], + "expectedBidResponses": [] +} diff --git a/adapters/pgamssp/pgamssptest/supplemental/status-not-200.json b/adapters/pgamssp/pgamssptest/supplemental/status-not-200.json new file mode 100644 index 00000000000..a2ab9e9f502 --- /dev/null +++ b/adapters/pgamssp/pgamssptest/supplemental/status-not-200.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 404, + "body": {} + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 404. Run with request.debug = 1 for more info.", + "comparison": "literal" + } + ] +} diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index 712c23d0786..de6794271d1 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -131,6 +131,7 @@ import ( "github.com/prebid/prebid-server/adapters/outbrain" "github.com/prebid/prebid-server/adapters/ownadx" "github.com/prebid/prebid-server/adapters/pangle" + "github.com/prebid/prebid-server/adapters/pgamssp" "github.com/prebid/prebid-server/adapters/pubmatic" "github.com/prebid/prebid-server/adapters/pubnative" "github.com/prebid/prebid-server/adapters/pulsepoint" @@ -332,6 +333,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderOwnAdx: ownadx.Builder, openrtb_ext.BidderPangle: pangle.Builder, openrtb_ext.BidderPGAM: adtelligent.Builder, + openrtb_ext.BidderPGAMSsp: pgamssp.Builder, openrtb_ext.BidderPubmatic: pubmatic.Builder, openrtb_ext.BidderPubnative: pubnative.Builder, openrtb_ext.BidderPulsepoint: pulsepoint.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 5e4b9308ea1..8686378462c 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -226,6 +226,7 @@ const ( BidderOwnAdx BidderName = "ownadx" BidderPangle BidderName = "pangle" BidderPGAM BidderName = "pgam" + BidderPGAMSsp BidderName = "pgamssp" BidderPubmatic BidderName = "pubmatic" BidderPubnative BidderName = "pubnative" BidderPulsepoint BidderName = "pulsepoint" @@ -433,6 +434,7 @@ func CoreBidderNames() []BidderName { BidderOwnAdx, BidderPangle, BidderPGAM, + BidderPGAMSsp, BidderPubmatic, BidderPubnative, BidderPulsepoint, diff --git a/openrtb_ext/imp_pgamssp.go b/openrtb_ext/imp_pgamssp.go new file mode 100644 index 00000000000..56e4b8bf7ac --- /dev/null +++ b/openrtb_ext/imp_pgamssp.go @@ -0,0 +1,6 @@ +package openrtb_ext + +type ImpExtPgamSsp struct { + PlacementID string `json:"placementId"` + EndpointID string `json:"endpointId"` +} diff --git a/static/bidder-info/pgamssp.yaml b/static/bidder-info/pgamssp.yaml new file mode 100644 index 00000000000..a762d8f15d4 --- /dev/null +++ b/static/bidder-info/pgamssp.yaml @@ -0,0 +1,19 @@ +endpoint: "http://us-east.pgammedia.com/pserver" +maintainer: + email: "info@pgammedia.com" +capabilities: + site: + mediaTypes: + - banner + - video + - native + + app: + mediaTypes: + - banner + - video + - native +userSync: + redirect: + url: "https://cs.pgammedia.com/pserver?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir={{.RedirectURL}}" + userMacro: "[UID]" diff --git a/static/bidder-params/pgamssp.json b/static/bidder-params/pgamssp.json new file mode 100644 index 00000000000..9d060241908 --- /dev/null +++ b/static/bidder-params/pgamssp.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "PgamSSP Adapter Params", + "description": "A schema which validates params accepted by the PgamSSP adapter", + "type": "object", + + "properties": { + "placementId": { + "type": "string", + "minLength": 1, + "description": "Placement ID" + }, + "endpointId": { + "type": "string", + "minLength": 1, + "description": "Endpoint ID" + } + }, + "oneOf": [ + { "required": ["placementId"] }, + { "required": ["endpointId"] } + ] + } \ No newline at end of file From 9bc0cbc1eb2cc4804baed26a8952be999a5e7c98 Mon Sep 17 00:00:00 2001 From: PGAMSSP Date: Thu, 31 Aug 2023 02:09:19 +0300 Subject: [PATCH 2/7] upd --- adapters/pgamssp/pgamssp.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/adapters/pgamssp/pgamssp.go b/adapters/pgamssp/pgamssp.go index e4176542da6..81785ad3047 100644 --- a/adapters/pgamssp/pgamssp.go +++ b/adapters/pgamssp/pgamssp.go @@ -98,14 +98,11 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestDa } func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if responseData.StatusCode == http.StatusNoContent { + if adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } - if responseData.StatusCode != http.StatusOK { - err := &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), - } + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { return nil, []error{err} } From 1cf01d4e7ead8a895ee0b77ac2a610afdf69b518 Mon Sep 17 00:00:00 2001 From: PGAMSSP Date: Thu, 31 Aug 2023 23:13:57 +0300 Subject: [PATCH 3/7] upd --- openrtb_ext/bidders.go | 1 + 1 file changed, 1 insertion(+) diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 715e3b3f442..833417374f6 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -160,6 +160,7 @@ var coreBidderNames []BidderName = []BidderName{ BidderOwnAdx, BidderPangle, BidderPGAM, + BidderPGAMSsp, BidderPubmatic, BidderPubnative, BidderPulsepoint, From 9614955c76db1ce0305157a2834b9fee13a19eee Mon Sep 17 00:00:00 2001 From: PGAMSSP Date: Thu, 31 Aug 2023 23:18:07 +0300 Subject: [PATCH 4/7] upd --- adapters/pgamssp/pgamssptest/supplemental/status-not-200.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/pgamssp/pgamssptest/supplemental/status-not-200.json b/adapters/pgamssp/pgamssptest/supplemental/status-not-200.json index a2ab9e9f502..0c9b3eec08b 100644 --- a/adapters/pgamssp/pgamssptest/supplemental/status-not-200.json +++ b/adapters/pgamssp/pgamssptest/supplemental/status-not-200.json @@ -77,7 +77,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "Unexpected status code: 404. Run with request.debug = 1 for more info.", + "value": "Unexpected status code: 404. Run with request.debug = 1 for more info", "comparison": "literal" } ] From 49dbd8496b8601d78cabd11ffa0dd2b69772b36d Mon Sep 17 00:00:00 2001 From: PGAMSSP Date: Mon, 11 Sep 2023 15:26:40 +0300 Subject: [PATCH 5/7] fix --- adapters/pgamssp/pgamssp.go | 27 +++++++------------ .../supplemental/bad_media_type.json | 8 ++---- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/adapters/pgamssp/pgamssp.go b/adapters/pgamssp/pgamssp.go index 81785ad3047..a5f3f46d000 100644 --- a/adapters/pgamssp/pgamssp.go +++ b/adapters/pgamssp/pgamssp.go @@ -8,7 +8,6 @@ import ( "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" - "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" ) @@ -115,7 +114,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse.Currency = response.Cur for _, seatBid := range response.SeatBid { for i := range seatBid.Bid { - bidType, err := getMediaTypeForImp(seatBid.Bid[i].ImpID, request.Imp) + bidType, err := getBidMediaType(&seatBid.Bid[i]) if err != nil { return nil, []error{err} } @@ -130,22 +129,16 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return bidResponse, nil } -func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { - for _, imp := range imps { - if imp.ID == impID { - if imp.Banner != nil { - return openrtb_ext.BidTypeBanner, nil - } - if imp.Video != nil { - return openrtb_ext.BidTypeVideo, nil - } - if imp.Native != nil { - return openrtb_ext.BidTypeNative, nil - } - } +func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { + var extBid openrtb_ext.ExtBid + err := json.Unmarshal(bid.Ext, &extBid) + if err != nil { + return "", fmt.Errorf("unable to deserialize imp %v bid.ext", bid.ImpID) } - return "", &errortypes.BadInput{ - Message: fmt.Sprintf("Failed to find impression \"%s\"", impID), + if extBid.Prebid == nil { + return "", fmt.Errorf("imp %v with unknown media type", bid.ImpID) } + + return extBid.Prebid.Type, nil } diff --git a/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json b/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json index 48409ba4458..9a226411932 100644 --- a/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json +++ b/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json @@ -63,11 +63,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "ext": {} } ], "seat": "pgamssp" @@ -79,7 +75,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "Failed to find impression \"test-imp-id\"", + "value": "imp test-imp-id with unknown media type", "comparison": "literal" } ] From 600359b6009ec37dcdca07a93fcc28f28744accf Mon Sep 17 00:00:00 2001 From: PGAMSSP Date: Tue, 12 Sep 2023 14:40:16 +0300 Subject: [PATCH 6/7] upd --- adapters/pgamssp/pgamssp.go | 21 ++++++++++--------- .../pgamssptest/exemplary/endpointId.json | 12 ++--------- .../pgamssptest/exemplary/simple-banner.json | 12 ++--------- .../pgamssptest/exemplary/simple-native.json | 12 ++--------- .../pgamssptest/exemplary/simple-video.json | 12 ++--------- .../exemplary/simple-web-banner.json | 12 ++--------- .../supplemental/bad_media_type.json | 2 +- 7 files changed, 22 insertions(+), 61 deletions(-) diff --git a/adapters/pgamssp/pgamssp.go b/adapters/pgamssp/pgamssp.go index a5f3f46d000..378b8e5cbf6 100644 --- a/adapters/pgamssp/pgamssp.go +++ b/adapters/pgamssp/pgamssp.go @@ -130,15 +130,16 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R } func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { - var extBid openrtb_ext.ExtBid - err := json.Unmarshal(bid.Ext, &extBid) - if err != nil { - return "", fmt.Errorf("unable to deserialize imp %v bid.ext", bid.ImpID) - } - - if extBid.Prebid == nil { - return "", fmt.Errorf("imp %v with unknown media type", bid.ImpID) + switch bid.MType { + case openrtb2.MarkupBanner: + return openrtb_ext.BidTypeBanner, nil + case openrtb2.MarkupVideo: + return openrtb_ext.BidTypeVideo, nil + case openrtb2.MarkupAudio: + return openrtb_ext.BidTypeAudio, nil + case openrtb2.MarkupNative: + return openrtb_ext.BidTypeNative, nil + default: + return "", fmt.Errorf("Unable to fetch mediaType in multi-format: %s", bid.ImpID) } - - return extBid.Prebid.Type, nil } diff --git a/adapters/pgamssp/pgamssptest/exemplary/endpointId.json b/adapters/pgamssp/pgamssptest/exemplary/endpointId.json index efd5084f484..72805db16ba 100644 --- a/adapters/pgamssp/pgamssptest/exemplary/endpointId.json +++ b/adapters/pgamssp/pgamssptest/exemplary/endpointId.json @@ -90,11 +90,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 } ], "seat": "pgamssp" @@ -119,11 +115,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 }, "type": "banner" } diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-banner.json b/adapters/pgamssp/pgamssptest/exemplary/simple-banner.json index 816c0c43cc0..3850c4492c2 100644 --- a/adapters/pgamssp/pgamssptest/exemplary/simple-banner.json +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-banner.json @@ -90,11 +90,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 } ], "seat": "pgamssp" @@ -119,11 +115,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 }, "type": "banner" } diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-native.json b/adapters/pgamssp/pgamssptest/exemplary/simple-native.json index 74501451776..8796adacd8e 100644 --- a/adapters/pgamssp/pgamssptest/exemplary/simple-native.json +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-native.json @@ -74,11 +74,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "native" - } - } + "mtype": 4 } ], "seat": "pgamssp" @@ -103,11 +99,7 @@ "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "native" - } - } + "mtype": 4 }, "type": "native" } diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-video.json b/adapters/pgamssp/pgamssptest/exemplary/simple-video.json index f949713069f..a39d0111694 100644 --- a/adapters/pgamssp/pgamssptest/exemplary/simple-video.json +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-video.json @@ -86,11 +86,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } + "mtype": 2 } ], "seat": "pgamssp" @@ -114,11 +110,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } + "mtype": 2 }, "type": "video" } diff --git a/adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json b/adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json index da168b7e5b2..fca8ce176ea 100644 --- a/adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json +++ b/adapters/pgamssp/pgamssptest/exemplary/simple-web-banner.json @@ -90,11 +90,7 @@ "dealid": "test_dealid", "w": 468, "h": 60, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 } ], "seat": "pgamssp" @@ -119,11 +115,7 @@ "dealid": "test_dealid", "w": 468, "h": 60, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 }, "type": "banner" } diff --git a/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json b/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json index 9a226411932..6f016367b33 100644 --- a/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json +++ b/adapters/pgamssp/pgamssptest/supplemental/bad_media_type.json @@ -75,7 +75,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "imp test-imp-id with unknown media type", + "value": "Unable to fetch mediaType in multi-format: test-imp-id", "comparison": "literal" } ] From 5b921d5df16391e241255db97130f2f786f8095b Mon Sep 17 00:00:00 2001 From: PGAMSSP Date: Wed, 17 Apr 2024 23:35:51 +0300 Subject: [PATCH 7/7] add support gpp --- static/bidder-info/pgamssp.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/bidder-info/pgamssp.yaml b/static/bidder-info/pgamssp.yaml index a762d8f15d4..4cb4ad4e1ed 100644 --- a/static/bidder-info/pgamssp.yaml +++ b/static/bidder-info/pgamssp.yaml @@ -15,5 +15,5 @@ capabilities: - native userSync: redirect: - url: "https://cs.pgammedia.com/pserver?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir={{.RedirectURL}}" + url: "https://cs.pgammedia.com/pserver?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}}&redir={{.RedirectURL}}" userMacro: "[UID]"