forked from Tinkoff/invest-openapi-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_sandbox_client.go
47 lines (34 loc) · 1.18 KB
/
rest_sandbox_client.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
package sdk
type SandboxRestClient struct {
*RestClient
}
func NewSandboxRestClient(token string) *SandboxRestClient {
return &SandboxRestClient{NewRestClientCustom(token, RestApiURL+"/sandbox")}
}
func NewSandboxRestClientCustom(token, apiURL string) *SandboxRestClient {
return &SandboxRestClient{NewRestClientCustom(token, apiURL)}
}
func (c *SandboxRestClient) Register() error {
path := c.apiURL + "/sandbox/register"
return c.postJSONThrow(path, nil)
}
func (c *SandboxRestClient) Clear() error {
path := c.apiURL + "/sandbox/clear"
return c.postJSONThrow(path, nil)
}
func (c *SandboxRestClient) SetCurrencyBalance(currency Currency, balance float64) error {
path := c.apiURL + "/sandbox/currencies/balance"
payload := struct {
Currency Currency `json:"currency"`
Balance float64 `json:"balance"`
}{Currency: currency, Balance: balance}
return c.postJSONThrow(path, payload)
}
func (c *SandboxRestClient) SetPositionsBalance(figi string, balance float64) error {
path := c.apiURL + "/sandbox/positions/balance"
payload := struct {
FIGI string `json:"figi"`
Balance float64 `json:"balance"`
}{FIGI: figi, Balance: balance}
return c.postJSONThrow(path, payload)
}