-
Notifications
You must be signed in to change notification settings - Fork 0
/
chast.go
56 lines (49 loc) · 976 Bytes
/
chast.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 chast
import (
"net/http"
"github.com/FairyTale5571/go-mono/internal/api"
)
type Chast struct {
mode string
storeID string
key string
apiClient *api.APIClient
}
const (
testURL = "https://u2-demo-ext.mono.st4g3.com/api"
stageURL = "https://u2-ext.mono.st4g3.com/api"
prodURL = "https://u2.monobank.com.ua/api"
)
type Opts struct {
// Mode - режим роботи, може бути test, stage, prod
Mode string
StoreID string
Key string
Client *http.Client
}
func NewChast(opts Opts) *Chast {
var url string
switch opts.Mode {
case "test":
url = testURL
case "stage":
url = stageURL
case "prod":
url = prodURL
default:
url = testURL
}
if opts.Client == nil {
opts.Client = http.DefaultClient
}
return &Chast{
mode: opts.Mode,
storeID: opts.StoreID,
key: opts.Key,
apiClient: &api.APIClient{
BaseURL: url,
Client: opts.Client,
ErrorParserFunc: errorParser,
},
}
}