Skip to content

Commit

Permalink
addressing review comment to use StringInt
Browse files Browse the repository at this point in the history
  • Loading branch information
anand-venkatraman committed Jun 28, 2024
1 parent 4539af1 commit 394b0da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
20 changes: 9 additions & 11 deletions adapters/pulsepoint/pulsepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"fmt"
"net/http"
"strconv"
"reflect"

"github.com/prebid/prebid-server/v2/adapters"
"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/errortypes"
"github.com/prebid/prebid-server/v2/openrtb_ext"
"github.com/prebid/prebid-server/v2/util/jsonutil"

"github.com/prebid/openrtb/v20/openrtb2"
)
Expand Down Expand Up @@ -179,16 +181,12 @@ func getBidType(imp openrtb2.Imp) openrtb_ext.BidType {
return ""
}

func parseParam(paramName string, paramValue interface{}) (string, error) {
if paramValue != nil {
extractedValue := fmt.Sprint(paramValue)
_, err := strconv.Atoi(extractedValue)
if err != nil {
return "", errors.New("expected int value for param - " + paramName + ", got value - " + extractedValue)
} else {
return extractedValue, nil
}
} else {
return "", errors.New("param not found - " + paramName)
func parseParam(paramName string, paramValue jsonutil.StringInt) (string, error) {
ref := reflect.ValueOf(paramValue)
value := int(ref.Int())
// verify we got a non-zero value
if value == 0 {
return "", errors.New("param not found - " + paramName)
}
return strconv.Itoa(value), nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"httpCalls": [],
"expectedMakeRequestsErrors": [{
"value": "expected int value for param - tagID, got value - ab1001",
"value": "Value looks like Number/Boolean/None, but can't find its end: ',' or '}' symbol",
"comparison": "literal"
}],
"expectedBidResponses": [],
Expand Down
8 changes: 6 additions & 2 deletions openrtb_ext/imp_pulsepoint.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package openrtb_ext

import (
"github.com/prebid/prebid-server/v2/util/jsonutil"
)

// ExtImpPulsePoint defines the json spec for bidrequest.imp[i].ext.prebid.bidder.pulsepoint
// PubId/TagId are mandatory params

type ExtImpPulsePoint struct {
PubID interface{} `json:"cp"`
TagID interface{} `json:"ct"`
PubID jsonutil.StringInt `json:"cp"`
TagID jsonutil.StringInt `json:"ct"`
}

0 comments on commit 394b0da

Please sign in to comment.