-
Notifications
You must be signed in to change notification settings - Fork 11
/
util.go
43 lines (35 loc) · 904 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package util
import (
"strings"
s2hv1beta1 "github.com/agoda-com/samsahai/api/v1beta1"
s2herrors "github.com/agoda-com/samsahai/internal/errors"
)
const (
statusSuccess = "success"
statusFailure = "failure"
)
func CheckMatchingInterval(interval s2hv1beta1.ReporterInterval, isReverify bool) error {
switch interval {
case s2hv1beta1.IntervalEveryTime:
default:
if !isReverify {
return s2herrors.New("interval was not matched")
}
}
return nil
}
func CheckMatchingCriteria(criteria s2hv1beta1.ReporterCriteria, result string) error {
lowerCaseResult := strings.ToLower(result)
switch criteria {
case s2hv1beta1.CriteriaBoth:
case s2hv1beta1.CriteriaSuccess:
if lowerCaseResult != statusSuccess {
return s2herrors.New("criteria was not matched")
}
default:
if lowerCaseResult != statusFailure {
return s2herrors.New("criteria was not matched")
}
}
return nil
}