-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublic.go
91 lines (83 loc) · 2.04 KB
/
public.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2017 David du Colombier. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bitstamp
import (
"encoding/json"
"fmt"
"net/url"
"github.com/0intro/bitstamp/response"
)
func (c *Conn) GetTicker(currencyPair string) (*response.Ticker, error) {
v := url.Values{}
path := fmt.Sprintf("/v2/ticker/%s/", currencyPair)
b, err := c.request("GET", path, v, false)
if err != nil {
return nil, err
}
res := &response.Ticker{}
err = json.Unmarshal(b, res)
if err != nil {
return nil, err
}
return res, nil
}
func (c *Conn) GetTickerHour(currencyPair string) (*response.Ticker, error) {
v := url.Values{}
path := fmt.Sprintf("/v2/ticker_hour/%s/", currencyPair)
b, err := c.request("GET", path, v, false)
if err != nil {
return nil, err
}
res := &response.Ticker{}
err = json.Unmarshal(b, res)
if err != nil {
return nil, err
}
return res, nil
}
func (c *Conn) GetOrderBook(currencyPair string) (*response.OrderBook, error) {
v := url.Values{}
path := fmt.Sprintf("/v2/order_book/%s/", currencyPair)
b, err := c.request("GET", path, v, false)
if err != nil {
return nil, err
}
res := &response.OrderBook{}
err = json.Unmarshal(b, res)
if err != nil {
return nil, err
}
return res, nil
}
func (c *Conn) GetTransactions(currencyPair string, time string) (*[]response.Transaction, error) {
v := url.Values{}
if time != "" {
v.Set("time", time)
}
path := fmt.Sprintf("/v2/transactions/%s/", currencyPair)
b, err := c.request("GET", path, v, false)
if err != nil {
return nil, err
}
res := &[]response.Transaction{}
err = json.Unmarshal(b, res)
if err != nil {
return nil, err
}
return res, nil
}
func (c *Conn) GetTradingPairsInfo() (*[]response.TradingPairInfo, error) {
v := url.Values{}
path := fmt.Sprint("/v2/trading-pairs-info/")
b, err := c.request("GET", path, v, false)
if err != nil {
return nil, err
}
res := &[]response.TradingPairInfo{}
err = json.Unmarshal(b, res)
if err != nil {
return nil, err
}
return res, nil
}