-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinfo.go
68 lines (55 loc) · 1.87 KB
/
info.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
package coinpayments
import (
"net/url"
)
// BasicInfoResult is the result we receive back as part of the basic info command response
type BasicInfoResult struct {
Username string `json:"username"`
MerchantID string `json:"merchant_id"`
Email string `json:"email"`
PublicName string `json:"public_name"`
}
// BasicInfoResponse is a response we get back from the basic info command
type BasicInfoResponse struct {
ErrorResponse
Result *BasicInfoResult `json:"result"`
}
// GetError implements the Response interface
func (resp *BasicInfoResponse) GetError() string {
return resp.Error
}
// CallGetBasicInfo calls the get_basic_info command on the API, returning info about our merchant account via the API keys.
func (c *Client) CallGetBasicInfo() (*BasicInfoResult, error) {
var resp BasicInfoResponse
if err := c.Call(CmdGetBasicInfo, url.Values{}, &resp); err != nil {
return nil, err
}
return resp.Result, nil
}
// RatesRequest holds the params the API expects for the rates command
type RatesRequest struct {
Short string `json:"short"`
Accepted string `json:"accepted"`
}
// RatesResult is the result we receive back as part of the rates command response
type RatesResult struct {
IsFiat int8 `json:"is_fiat"`
RateBTC string `json:"rate_btc"`
LastUpdate string `json:"last_update"`
}
// RatesResponse is a response we get back from the rates command
type RatesResponse struct {
ErrorResponse
Result map[string]RatesResult `json:"result"`
}
// CallRates calls the get_basic_info command on the API, returning info about our merchant account via the API keys.
func (c *Client) CallRates(req *RatesRequest) (map[string]RatesResult, error) {
data := url.Values{}
data.Add("short", req.Short)
data.Add("accepted", req.Accepted)
var resp RatesResponse
if err := c.Call(CmdRates, data, &resp); err != nil {
return nil, err
}
return resp.Result, nil
}