Fixes + stable gateway ids
This commit is contained in:
44
api/payments/storage/model/report_visibility.go
Normal file
44
api/payments/storage/model/report_visibility.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
import "strings"
|
||||
|
||||
// ReportVisibility controls which audience should see a step in reports/timelines.
|
||||
type ReportVisibility string
|
||||
|
||||
const (
|
||||
ReportVisibilityUnspecified ReportVisibility = ""
|
||||
ReportVisibilityHidden ReportVisibility = "hidden"
|
||||
ReportVisibilityUser ReportVisibility = "user"
|
||||
ReportVisibilityBackoffice ReportVisibility = "backoffice"
|
||||
ReportVisibilityAudit ReportVisibility = "audit"
|
||||
)
|
||||
|
||||
// NormalizeReportVisibility trims and lowercases the visibility value.
|
||||
func NormalizeReportVisibility(value ReportVisibility) ReportVisibility {
|
||||
return ReportVisibility(strings.ToLower(strings.TrimSpace(string(value))))
|
||||
}
|
||||
|
||||
// IsValidReportVisibility reports whether the value is a supported enum variant.
|
||||
func IsValidReportVisibility(value ReportVisibility) bool {
|
||||
switch NormalizeReportVisibility(value) {
|
||||
case ReportVisibilityUnspecified,
|
||||
ReportVisibilityHidden,
|
||||
ReportVisibilityUser,
|
||||
ReportVisibilityBackoffice,
|
||||
ReportVisibilityAudit:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// IsUserVisible returns true when the step should be shown to end users.
|
||||
// Unspecified is treated as user-visible for backward compatibility.
|
||||
func (value ReportVisibility) IsUserVisible() bool {
|
||||
switch NormalizeReportVisibility(value) {
|
||||
case ReportVisibilityUnspecified, ReportVisibilityUser:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user