forked from veritrans/go-midtrans
-
Notifications
You must be signed in to change notification settings - Fork 1
/
envtype.go
48 lines (39 loc) · 921 Bytes
/
envtype.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
44
45
46
47
48
package midtrans
import (
"strings"
)
// EnvironmentType value
type EnvironmentType int8
const (
_ EnvironmentType = iota
// Sandbox : represent sandbox environment
Sandbox
// Production : represent production environment
Production
)
var typeString = map[EnvironmentType]string{
Sandbox: "https://api.sandbox.midtrans.com",
Production: "https://api.midtrans.com",
}
// implement stringer
func (e EnvironmentType) String() string {
for k, v := range typeString {
if k == e {
return v
}
}
return "undefined"
}
// SnapURL : Get environment API URL
func (e EnvironmentType) SnapURL() string {
return strings.Replace(e.String(), "api.", "app.", 1)
}
// IrisURL : Get environment API URL
func (e EnvironmentType) IrisURL() string {
if Production == e {
return "https://app.midtrans.com/iris"
} else if Sandbox == e {
return "https://app.sandbox.midtrans.com/iris"
}
return "undefined"
}