Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
larscom committed Dec 6, 2023
1 parent 4655928 commit 8a11327
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 58 deletions.
4 changes: 2 additions & 2 deletions httpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/goccy/go-json"
"github.com/larscom/go-bitvavo/v2/crypto"
"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/types"
"github.com/larscom/go-bitvavo/v2/util"
)

Expand Down Expand Up @@ -102,7 +102,7 @@ func unwrapErr(response *http.Response) error {
return err
}

var bitvavoErr *jsond.BitvavoErr
var bitvavoErr *types.BitvavoErr
if err := json.Unmarshal(bytes, &bitvavoErr); err != nil {
return fmt.Errorf("did not get OK response, code=%d, body=%s", response.StatusCode, string(bytes))
}
Expand Down
32 changes: 16 additions & 16 deletions httpc/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync"
"time"

"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/log"
"github.com/larscom/go-bitvavo/v2/types"
"github.com/larscom/go-bitvavo/v2/util"
)

Expand Down Expand Up @@ -47,24 +47,24 @@ type HttpClient interface {

// GetMarkets returns the available markets with their status (trading,halted,auction) and
// available order types.
GetMarkets() ([]jsond.Market, error)
GetMarkets() ([]types.Market, error)

// GetMarkets returns the available markets with their status (trading,halted,auction) and
// available order types for a single market (e.g: ETH-EUR)
GetMarket(market string) (jsond.Market, error)
GetMarket(market string) (types.Market, error)

// GetAssets returns information on the supported assets
GetAssets() ([]jsond.Asset, error)
GetAssets() ([]types.Asset, error)

// GetAsset returns information on the supported asset by symbol (e.g: ETH).
GetAsset(symbol string) (jsond.Asset, error)
GetAsset(symbol string) (types.Asset, error)

// GetOrderBook returns a book with bids and asks for market.
// That is, the buy and sell orders made by all Bitvavo users in a specific market (e.g: ETH-EUR).
// The orders in the return parameters are sorted by price
//
// Optionally provide the depth to return the top depth orders only.
GetOrderBook(market string, depth ...uint64) (jsond.Book, error)
GetOrderBook(market string, depth ...uint64) (types.Book, error)
}

type Option func(*httpClient)
Expand Down Expand Up @@ -146,8 +146,8 @@ func (c *httpClient) GetTime() (int64, error) {
return int64(resp["time"]), nil
}

func (c *httpClient) GetMarkets() ([]jsond.Market, error) {
return httpGet[[]jsond.Market](
func (c *httpClient) GetMarkets() ([]types.Market, error) {
return httpGet[[]types.Market](
fmt.Sprintf("%s/markets", httpUrl),
emptyParams,
c.updateRateLimit,
Expand All @@ -157,11 +157,11 @@ func (c *httpClient) GetMarkets() ([]jsond.Market, error) {
)
}

func (c *httpClient) GetMarket(market string) (jsond.Market, error) {
func (c *httpClient) GetMarket(market string) (types.Market, error) {
params := make(url.Values)
params.Add("market", market)

return httpGet[jsond.Market](
return httpGet[types.Market](
fmt.Sprintf("%s/markets", httpUrl),
params,
c.updateRateLimit,
Expand All @@ -171,8 +171,8 @@ func (c *httpClient) GetMarket(market string) (jsond.Market, error) {
)
}

func (c *httpClient) GetAssets() ([]jsond.Asset, error) {
return httpGet[[]jsond.Asset](
func (c *httpClient) GetAssets() ([]types.Asset, error) {
return httpGet[[]types.Asset](
fmt.Sprintf("%s/assets", httpUrl),
emptyParams,
c.updateRateLimit,
Expand All @@ -182,11 +182,11 @@ func (c *httpClient) GetAssets() ([]jsond.Asset, error) {
)
}

func (c *httpClient) GetAsset(symbol string) (jsond.Asset, error) {
func (c *httpClient) GetAsset(symbol string) (types.Asset, error) {
params := make(url.Values)
params.Add("symbol", symbol)

return httpGet[jsond.Asset](
return httpGet[types.Asset](
fmt.Sprintf("%s/assets", httpUrl),
params,
c.updateRateLimit,
Expand All @@ -196,13 +196,13 @@ func (c *httpClient) GetAsset(symbol string) (jsond.Asset, error) {
)
}

func (c *httpClient) GetOrderBook(market string, depth ...uint64) (jsond.Book, error) {
func (c *httpClient) GetOrderBook(market string, depth ...uint64) (types.Book, error) {
params := make(url.Values)
if len(depth) > 0 {
params.Add("depth", fmt.Sprint(depth[0]))
}

return httpGet[jsond.Book](
return httpGet[types.Book](
fmt.Sprintf("%s/%s/book", httpUrl, market),
params,
c.updateRateLimit,
Expand Down
14 changes: 7 additions & 7 deletions httpc/httpclientauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (

"net/url"

"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/types"
)

type HttpClientAuth interface {
// GetBalance returns the balance on the account.
// Optionally provide the symbol to filter for in uppercase (e.g: ETH)
GetBalance(symbol ...string) ([]jsond.Balance, error)
GetBalance(symbol ...string) ([]types.Balance, error)

// GetAccount returns trading volume and fees for account.
GetAccount() (jsond.Account, error)
GetAccount() (types.Account, error)
}

type httpClientAuth struct {
Expand Down Expand Up @@ -45,13 +45,13 @@ func newHttpClientAuth(
}
}

func (c *httpClientAuth) GetBalance(symbol ...string) ([]jsond.Balance, error) {
func (c *httpClientAuth) GetBalance(symbol ...string) ([]types.Balance, error) {
params := make(url.Values)
if len(symbol) > 0 {
params.Add("symbol", symbol[0])
}

return httpGet[[]jsond.Balance](
return httpGet[[]types.Balance](
fmt.Sprintf("%s/balance", httpUrl),
params,
c.updateRateLimit,
Expand All @@ -61,8 +61,8 @@ func (c *httpClientAuth) GetBalance(symbol ...string) ([]jsond.Balance, error) {
)
}

func (c *httpClientAuth) GetAccount() (jsond.Account, error) {
return httpGet[jsond.Account](
func (c *httpClientAuth) GetAccount() (types.Account, error) {
return httpGet[types.Account](
fmt.Sprintf("%s/account", httpUrl),
emptyParams,
c.updateRateLimit,
Expand Down
2 changes: 1 addition & 1 deletion jsond/account.go → types/account.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

import (
"github.com/goccy/go-json"
Expand Down
2 changes: 1 addition & 1 deletion jsond/asset.go → types/asset.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

import (
"github.com/goccy/go-json"
Expand Down
2 changes: 1 addition & 1 deletion jsond/balance.go → types/balance.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

import (
"github.com/goccy/go-json"
Expand Down
2 changes: 1 addition & 1 deletion jsond/book.go → types/book.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

import (
"github.com/goccy/go-json"
Expand Down
2 changes: 1 addition & 1 deletion jsond/candle.go → types/candle.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion jsond/error.go → types/error.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion jsond/fill.go → types/fill.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

type Fill struct {
// The id of the order on which has been filled
Expand Down
2 changes: 1 addition & 1 deletion jsond/market.go → types/market.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

import (
"github.com/goccy/go-json"
Expand Down
2 changes: 1 addition & 1 deletion jsond/order.go → types/order.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

type Order struct {
Guid string `json:"guid"`
Expand Down
2 changes: 1 addition & 1 deletion jsond/ticker.go → types/ticker.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

type Ticker struct {
// The price of the best (highest) bid offer available, only sent when either bestBid or bestBidSize has changed.
Expand Down
2 changes: 1 addition & 1 deletion jsond/ticker24h.go → types/ticker24h.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

type Ticker24h struct {
// The open price of the 24 hour period.
Expand Down
2 changes: 1 addition & 1 deletion jsond/trade.go → types/trade.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jsond
package types

type Trade struct {
// The trade ID of the returned trade (UUID).
Expand Down
10 changes: 5 additions & 5 deletions wsc/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/goccy/go-json"
"github.com/larscom/go-bitvavo/v2/crypto"
"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/log"
"github.com/larscom/go-bitvavo/v2/types"
"github.com/larscom/go-bitvavo/v2/util"
"github.com/smallnest/safemap"
)
Expand All @@ -20,7 +20,7 @@ type OrderEvent struct {
Market string `json:"market"`

// The order itself.
Order jsond.Order `json:"order"`
Order types.Order `json:"order"`
}

func (o *OrderEvent) UnmarshalJSON(bytes []byte) error {
Expand Down Expand Up @@ -59,7 +59,7 @@ func (o *OrderEvent) UnmarshalJSON(bytes []byte) error {

o.Market = market
o.Event = event
o.Order = jsond.Order{
o.Order = types.Order{
Guid: guid,
OrderId: orderId,
Created: int64(created),
Expand Down Expand Up @@ -91,7 +91,7 @@ type FillEvent struct {
// The market which was requested in the subscription
Market string `json:"market"`
// The fill itself
Fill jsond.Fill `json:"fill"`
Fill types.Fill `json:"fill"`
}

func (f *FillEvent) UnmarshalJSON(bytes []byte) error {
Expand Down Expand Up @@ -119,7 +119,7 @@ func (f *FillEvent) UnmarshalJSON(bytes []byte) error {

f.Market = market
f.Event = event
f.Fill = jsond.Fill{
f.Fill = types.Fill{
OrderId: orderId,
FillId: fillId,
Timestamp: int64(timestamp),
Expand Down
4 changes: 2 additions & 2 deletions wsc/book.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package wsc
import (
"fmt"

"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/log"
"github.com/larscom/go-bitvavo/v2/types"

"github.com/goccy/go-json"
"github.com/larscom/go-bitvavo/v2/util"
Expand All @@ -19,7 +19,7 @@ type BookEvent struct {
Market string `json:"market"`

// The book containing the bids and asks.
Book jsond.Book `json:"book"`
Book types.Book `json:"book"`
}

func (b *BookEvent) UnmarshalJSON(bytes []byte) error {
Expand Down
4 changes: 2 additions & 2 deletions wsc/candles.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/log"
"github.com/larscom/go-bitvavo/v2/types"
"github.com/larscom/go-bitvavo/v2/util"

"github.com/goccy/go-json"
Expand All @@ -23,7 +23,7 @@ type CandlesEvent struct {
Interval string `json:"interval"`

// The candle in the defined time period.
Candle jsond.Candle `json:"candle"`
Candle types.Candle `json:"candle"`
}

type CandlesEventHandler interface {
Expand Down
6 changes: 3 additions & 3 deletions wsc/ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package wsc
import (
"fmt"

"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/log"
"github.com/larscom/go-bitvavo/v2/types"

"github.com/goccy/go-json"
"github.com/larscom/go-bitvavo/v2/util"
Expand All @@ -19,7 +19,7 @@ type TickerEvent struct {
Market string `json:"market"`

// The ticker containing the prices.
Ticker jsond.Ticker `json:"ticker"`
Ticker types.Ticker `json:"ticker"`
}

func (t *TickerEvent) UnmarshalJSON(bytes []byte) error {
Expand All @@ -40,7 +40,7 @@ func (t *TickerEvent) UnmarshalJSON(bytes []byte) error {
)

t.Market = market
t.Ticker = jsond.Ticker{
t.Ticker = types.Ticker{
BestBid: util.IfOrElse(len(bestBid) > 0, func() float64 { return util.MustFloat64(bestBid) }, 0),
BestBidSize: util.IfOrElse(len(bestBidSize) > 0, func() float64 { return util.MustFloat64(bestBidSize) }, 0),
BestAsk: util.IfOrElse(len(bestAsk) > 0, func() float64 { return util.MustFloat64(bestAsk) }, 0),
Expand Down
6 changes: 3 additions & 3 deletions wsc/ticker24h.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package wsc
import (
"fmt"

"github.com/larscom/go-bitvavo/v2/jsond"
"github.com/larscom/go-bitvavo/v2/log"
"github.com/larscom/go-bitvavo/v2/types"

"github.com/goccy/go-json"
"github.com/larscom/go-bitvavo/v2/util"
Expand All @@ -19,7 +19,7 @@ type Ticker24hEvent struct {
Market string `json:"market"`

// The ticker24h containing the prices etc.
Ticker24h jsond.Ticker24h `json:"ticker24h"`
Ticker24h types.Ticker24h `json:"ticker24h"`
}

func (t *Ticker24hEvent) UnmarshalJSON(bytes []byte) error {
Expand Down Expand Up @@ -58,7 +58,7 @@ func (t *Ticker24hEvent) UnmarshalJSON(bytes []byte) error {

t.Event = event
t.Market = market
t.Ticker24h = jsond.Ticker24h{
t.Ticker24h = types.Ticker24h{
Open: util.IfOrElse(len(open) > 0, func() float64 { return util.MustFloat64(open) }, 0),
High: util.IfOrElse(len(high) > 0, func() float64 { return util.MustFloat64(high) }, 0),
Low: util.IfOrElse(len(low) > 0, func() float64 { return util.MustFloat64(low) }, 0),
Expand Down
Loading

0 comments on commit 8a11327

Please sign in to comment.