-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (52 loc) · 1.44 KB
/
main.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
49
50
51
52
53
54
55
56
package main
import (
"fmt"
CL "github.com/centralnicgroup-opensource/rtldev-middleware-go-sdk/v3/apiclient"
)
func main() {
//sessionless API communication
fmt.Println("--- SESSIONLESS API COMMUNICATION ---")
cl := CL.NewAPIClient()
cl.SetCredentials("test.user", "test.passw0rd") //username, password
cl.SetRemoteIPAddress("1.2.3.4") //for active ip filter setting
//cl.SetOTP("12345678") to provide your 2FA otp code
cl.UseOTESystem()
cl.EnableDebugMode()
r := cl.Request(map[string]interface{}{
"COMMAND": "StatusAccount",
})
if r.IsSuccess() {
fmt.Println("Command succeeded.")
} else {
fmt.Println("Command failed.")
}
fmt.Println()
//session based API communication
fmt.Println("--- SESSION BASED API COMMUNICATION ---")
cl = CL.NewAPIClient()
cl.SetCredentials("test.user", "test.passw0rd") //username, password
cl.SetRemoteIPAddress("1.2.3.4") //for active ip filter setting
cl.UseOTESystem()
cl.EnableDebugMode()
r = cl.Login()
// or cl.Login("12345678") to provide your 2FA otp code
if r.IsSuccess() {
fmt.Println("Login succeeded.")
r = cl.Request(map[string]interface{}{
"COMMAND": "StatusAccount",
})
if r.IsSuccess() {
fmt.Println("Command succeeded.")
r = cl.Logout()
if r.IsSuccess() {
fmt.Println("Logout succeeded.")
} else {
fmt.Println("Logout failed.")
}
} else {
fmt.Println("Command failed.")
}
} else {
fmt.Println("Login failed.")
}
}