From 7afb162cbfc42be8b4f925803dea50ec270346d3 Mon Sep 17 00:00:00 2001 From: Nilesh Chate <97721111+pm-nilesh-chate@users.noreply.github.com> Date: Thu, 9 Nov 2023 09:31:39 +0530 Subject: [PATCH] UOE-9681: fix pubmatic2 params (#641) --- modules/pubmatic/openwrap/bidderparams/pubmatic.go | 6 ++++++ modules/pubmatic/openwrap/bidderparams/pubmatic_test.go | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/pubmatic/openwrap/bidderparams/pubmatic.go b/modules/pubmatic/openwrap/bidderparams/pubmatic.go index e6fc965cee3..cf440a14a35 100644 --- a/modules/pubmatic/openwrap/bidderparams/pubmatic.go +++ b/modules/pubmatic/openwrap/bidderparams/pubmatic.go @@ -13,6 +13,12 @@ import ( func PreparePubMaticParamsV25(rctx models.RequestCtx, cache cache.Cache, bidRequest openrtb2.BidRequest, imp openrtb2.Imp, impExt models.ImpExtension, partnerID int) (string, string, bool, []byte, error) { wrapExt := fmt.Sprintf(`{"%s":%d,"%s":%d}`, models.SS_PM_VERSION_ID, rctx.DisplayID, models.SS_PM_PROFILE_ID, rctx.ProfileID) + + // change profile id for pubmatic2 + if secondaryProfileID, ok := rctx.PartnerConfigMap[partnerID][models.KEY_PROFILE_ID]; ok { + wrapExt = fmt.Sprintf(`{"%s":0,"%s":%s}`, models.SS_PM_VERSION_ID, models.SS_PM_PROFILE_ID, secondaryProfileID) + } + extImpPubMatic := openrtb_ext.ExtImpPubmatic{ PublisherId: strconv.Itoa(rctx.PubID), WrapExt: json.RawMessage(wrapExt), diff --git a/modules/pubmatic/openwrap/bidderparams/pubmatic_test.go b/modules/pubmatic/openwrap/bidderparams/pubmatic_test.go index 728fb2c6880..62788ad0429 100644 --- a/modules/pubmatic/openwrap/bidderparams/pubmatic_test.go +++ b/modules/pubmatic/openwrap/bidderparams/pubmatic_test.go @@ -322,6 +322,7 @@ func TestPreparePubMaticParamsV25(t *testing.T) { models.TIMEOUT: "200", models.KEY_GEN_PATTERN: "_AU_@_DIV_@_W_x_H_", models.SERVER_SIDE_FLAG: "1", + models.KEY_PROFILE_ID: "1323", }, }, }, @@ -369,7 +370,7 @@ func TestPreparePubMaticParamsV25(t *testing.T) { matchedSlot: "/Test_Adunit1234@Div1@200x300", matchedPattern: "", isRegexSlot: false, - params: []byte(`{"publisherId":"5890","adSlot":"/Test_Adunit1234@DIV1@200x300","wrapper":{"version":1,"profile":123},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`), + params: []byte(`{"publisherId":"5890","adSlot":"/Test_Adunit1234@DIV1@200x300","wrapper":{"version":0,"profile":1323},"keywords":[{"key":"test_key1","value":["test_value1","test_value2"]},{"key":"test_key2","value":["test_value1","test_value2"]}]}`), wantErr: false, }, },