-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
65 lines (52 loc) · 1.06 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
57
58
59
60
61
62
63
64
65
package main
import (
"errors"
"log"
"github.com/Sagleft/uexchange-go"
"github.com/gin-gonic/gin"
)
func main() {
app := newSolution()
err := checkErrors(
app.parseConfig,
app.initGin,
app.connectExchange,
app.setupRoutes,
app.runGin,
)
if err != nil {
log.Fatalln(err)
}
}
func newSolution() *solution {
return &solution{}
}
func (sol *solution) initGin() error {
sol.Gin = gin.Default()
return nil
}
func (sol *solution) runGin() error {
return sol.Gin.Run()
}
func (sol *solution) connectExchange() error {
//sol.ExchangeClient
// create client
sol.ExchangeClient = uexchange.NewClient()
client := sol.ExchangeClient
// auth
_, err := client.Auth(uexchange.Credentials{
AccountPublicKey: sol.Config.Exchange.PublicKey,
Password: sol.Config.Exchange.Password,
})
if err != nil {
return nil
}
// TODO
return nil
}
func (sol *solution) getExchangePairs() ([]uexchange.PairsDataContainer, error) {
if sol.ExchangeClient == nil {
return nil, errors.New("exchange client is not set")
}
return sol.ExchangeClient.GetPairs()
}