Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UOE-10791: Ignored rateLimit field for aidem bidder #841

Merged
merged 13 commits into from
Jul 18, 2024
Prev Previous commit
Next Next commit
changed builder
pm-priyanka-bagade committed Jul 18, 2024
commit 35262d84a3dcf0e7395e294a58fb9d358fd13ded
31 changes: 9 additions & 22 deletions modules/pubmatic/openwrap/adapters/bidders.go
Original file line number Diff line number Diff line change
@@ -709,28 +709,15 @@ func builderAidem(params BidderParameters) (json.RawMessage, error) {
jsonStr := bytes.Buffer{}
jsonStr.WriteByte('{')

//publisherID
if publisherID, ok := getString(params.FieldMap["publisherId"]); ok {
fmt.Fprintf(&jsonStr, `"publisherId":"%s",`, publisherID)
} else {
return nil, fmt.Errorf(errMandatoryParameterMissingFormat, params.AdapterName, "'publisherId'")
}

//siteId
if siteId, ok := getString(params.FieldMap["siteId"]); ok {
fmt.Fprintf(&jsonStr, `"siteId":"%s",`, siteId)
} else {
return nil, fmt.Errorf(errMandatoryParameterMissingFormat, params.AdapterName, "'siteId'")
}

//placementId
if placementId, ok := getString(params.FieldMap["placementId"]); ok {
fmt.Fprintf(&jsonStr, `"placementId":"%s",`, placementId)
}

//rateLimit
if _, ok := getString(params.FieldMap["rateLimit"]); ok {
delete(params.FieldMap, "rateLimit")
fields := []string{"publisherId", "siteId", "placementId"}
mandatoryFields := map[string]bool{"publisherId": true, "siteId": true}

for _, field := range fields {
if value, ok := getString(params.FieldMap[field]); ok {
fmt.Fprintf(&jsonStr, `"%s":"%s",`, field, value)
} else if mandatoryFields[field] {
return nil, fmt.Errorf(errMandatoryParameterMissingFormat, params.AdapterName, field)
}
}

// len=0 (no mandatory params present)
6 changes: 6 additions & 0 deletions modules/pubmatic/openwrap/adapters/bidders_test.go
Original file line number Diff line number Diff line change
@@ -3101,6 +3101,12 @@ func Test_builderAidem(t *testing.T) {
want: json.RawMessage(``),
wantErr: true,
},
{
name: "Invalid Scenerio (Only placementId) is present",
args: args{params: BidderParameters{FieldMap: JSONObject{"placementId": "abcd"}}},
want: json.RawMessage(``),
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {