Skip to content

Commit

Permalink
Merge pull request #108 from plivo/VT-3276
Browse files Browse the repository at this point in the history
Removed range validation for ringtimeout and delaydial params in MPC
  • Loading branch information
huzaif-plivo authored Jul 29, 2021
2 parents 8827dfa + b36da72 commit 0d568cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## [7.2.2](https://github.com/plivo/plivo-go/tree/v7.2.2) (2021-07-29)
- Removed validation for `ringtimeout` and `delaydial` params in [Start a multi party call](https://www.plivo.com/docs/voice/api/multiparty-call#start-a-new-multiparty-call).

## [7.2.1](https://github.com/plivo/plivo-go/tree/v7.2.1) (2021-07-22)
- Updated default HTTP client request timeout to 5 seconds.

Expand Down
2 changes: 1 addition & 1 deletion baseclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/google/go-querystring/query"
)

const sdkVersion = "7.2.1"
const sdkVersion = "7.2.2"

const lookupBaseUrl = "lookup.plivo.com"

Expand Down
4 changes: 2 additions & 2 deletions multipartycall.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ func (service *MultiPartyCallService) AddParticipant(basicParams MultiPartyCallB
if params.RingTimeout == nil {
params.RingTimeout = 45
} else {
MultipleValidIntegers("RingTimeout", params.RingTimeout, 15, 120)
MultipleValidIntegers("RingTimeout", params.RingTimeout)
}
if params.DelayDial == nil {
params.DelayDial = 0
} else {
MultipleValidIntegers("DelayDial", params.DelayDial, 0, 120)
MultipleValidIntegers("DelayDial", params.DelayDial)
}
req, err := service.client.NewRequest("POST", params, "MultiPartyCall/%s/Participant", mpcId)
if err != nil {
Expand Down
19 changes: 4 additions & 15 deletions validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,17 @@ import (
"strings"
)

func MultipleValidIntegers(paramname string, paramvalue interface{}, lowerbound int, upperbound int) {
if reflect.TypeOf(paramvalue).Kind() == reflect.Int {
paramvalue := paramvalue.(int)
if paramvalue < lowerbound || paramvalue > upperbound {
error := paramname + " values must be in the range [" + strconv.Itoa(lowerbound) + " , " + strconv.Itoa(upperbound) + "]"
logrus.Fatal(error)
}
} else if reflect.TypeOf(paramvalue).Kind() == reflect.String {
func MultipleValidIntegers(paramname string, paramvalue interface{}) {
if reflect.TypeOf(paramvalue).Kind() == reflect.String {
paramvalue := paramvalue.(string)
values := strings.SplitN(paramvalue, "<", -1)
for i := 0; i < len(values); i++ {
val, err := strconv.Atoi(values[i])
_, err := strconv.Atoi(values[i])
if err != nil {
logrus.Fatal(paramname + " Destination values in the string must be integers")
} else {
if val < lowerbound || val > upperbound {
error := paramname + " Destination values must be in the range [" + strconv.Itoa(lowerbound) + " , " + strconv.Itoa(upperbound) + "]"
logrus.Fatal(error)
}
}
}
} else {
} else if reflect.TypeOf(paramvalue).Kind() != reflect.Int && reflect.TypeOf(paramvalue).Kind() != reflect.String {
logrus.Fatal(paramname + " must be either string or integer")
}
}

0 comments on commit 0d568cb

Please sign in to comment.