Skip to content

Commit

Permalink
Merge pull request #1 from solipsis/marketInfo
Browse files Browse the repository at this point in the history
various tweaks to make team-jacob happier
  • Loading branch information
solipsis committed Aug 21, 2018
2 parents 333cb9b + 24207d0 commit 56d4e41
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions shapeshift.go
Expand Up @@ -3,8 +3,8 @@ package shapeshift
import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"log"
"net/http"
"strconv"
)
Expand Down Expand Up @@ -40,7 +40,7 @@ type LimitResponse struct {

type MarketInfoResponse struct {
Pair string `json:"pair,omitempty"`
Rate float64 `json:"rate,omitempty"`
Rate float64 `json:"rate,string,omitempty"`
Limit float64 `json:"limit,omitempty"`
Min float64 `json:"min,omitempty"`
MinerFee float64 `json:"minerFee,omitempty"`
Expand Down Expand Up @@ -205,6 +205,16 @@ func (p Pair) GetLimits() (float64, error) {
return ToFloat(g.Limit), err
}

func MarketInfo() ([]MarketInfoResponse, error) {
r, err := DoHttp("GET", "marketinfo", "")
if err != nil {
return nil, err
}
var arr []MarketInfoResponse
err = json.Unmarshal(r, &arr)
return arr, err
}

func (p Pair) GetInfo() (*MarketInfoResponse, error) {
r, err := DoHttp("GET", "marketinfo", p.Name)
if err != nil {
Expand Down Expand Up @@ -262,7 +272,7 @@ func CoinsAsList() ([]Coin, error) {
var c Coin
err := json.Unmarshal([]byte(*coinJSON), &c)
if err != nil {
log.Println("Error unmarshalling coin:", err)
//log.Println("Error unmarshalling coin:", err)
continue
}
coins = append(coins, c)
Expand Down Expand Up @@ -359,6 +369,9 @@ func DoPostHttp(method string, apimethod string, data interface{}) ([]byte, erro
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, errors.New("There was an error creating your order, Please try again later")
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body = bytes.TrimPrefix(body, []byte("\xef\xbb\xbf"))
Expand Down

0 comments on commit 56d4e41

Please sign in to comment.