-
Notifications
You must be signed in to change notification settings - Fork 17
/
fills.go
47 lines (37 loc) · 859 Bytes
/
fills.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 goftx
import (
"encoding/json"
"fmt"
"net/http"
"github.com/pkg/errors"
"github.com/grishinsana/goftx/models"
)
const apiFills = "/fills"
type Fills struct {
client *Client
}
func (f *Fills) GetFills(params *models.GetFillsParams) ([]*models.Fill, error) {
queryParams, err := PrepareQueryParams(params)
if err != nil {
return nil, errors.WithStack(err)
}
request, err := f.client.prepareRequest(Request{
Auth: true,
Method: http.MethodGet,
URL: fmt.Sprintf("%s%s", f.client.apiURL, apiFills),
Params: queryParams,
})
if err != nil {
return nil, errors.WithStack(err)
}
response, err := f.client.do(request)
if err != nil {
return nil, errors.WithStack(err)
}
var result []*models.Fill
err = json.Unmarshal(response, &result)
if err != nil {
return nil, errors.WithStack(err)
}
return result, nil
}