-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublic_availablebooks.go
More file actions
41 lines (35 loc) · 924 Bytes
/
public_availablebooks.go
File metadata and controls
41 lines (35 loc) · 924 Bytes
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
package bitso
import (
"encoding/json"
"fmt"
)
type AvailableBookResponse struct {
Success bool `json:"success"`
Error Error `json:"error,omitempty"`
Books Books `json:"payload,omitempty"`
}
type Books []Book
type Book struct {
Book string `json:"book"`
MinimumAmount float64 `json:"minimum_amount,string"`
MaximumAmount float64 `json:"maximum_amount,string"`
MinimumPrice float64 `json:"minimum_price,string"`
MaximumPrice float64 `json:"maximum_price,string"`
MinimumValue float64 `json:"minimum_value,string"`
MaximumValue float64 `json:"maximum_value,string"`
}
func (api *API) AvailableBooks() (Books, error) {
data, err := api.ask("available_books/", nil)
if err != nil {
return nil, err
}
ab := AvailableBookResponse{}
err = json.Unmarshal(data, &ab)
if err != nil {
return nil, err
}
if api.Devel {
fmt.Printf("DATA RECEIVED: %+v\n", ab)
}
return ab.Books, nil
}