Skip to content

Commit

Permalink
rename api struct for better styling
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgoyette committed Dec 31, 2016
1 parent 6dc7853 commit 167b8fe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ const (
WITHDRAW_FUNDS_URL = "/v1/withdraw/"
)

type GeminiAPI struct {
type GeminiApi struct {
url string
key string
secret string
}

func New(live bool, key, secret string) *GeminiAPI {
func New(live bool, key, secret string) *GeminiApi {
var url string
if url = SANDBOX_URL; live == true {
url = BASE_URL
}

return &GeminiAPI{url: url, key: key, secret: secret}
return &GeminiApi{url: url, key: key, secret: secret}
}

type ApiError struct {
Expand Down Expand Up @@ -242,7 +242,7 @@ func getNonce() int64 {
}

// internal methods
func (g *GeminiAPI) prepPayload(req *requestParams) *requestHeaders {
func (g *GeminiApi) prepPayload(req *requestParams) *requestHeaders {

reqStr, _ := json.Marshal(req)
payload := base64.StdEncoding.EncodeToString([]byte(reqStr))
Expand All @@ -259,7 +259,7 @@ func (g *GeminiAPI) prepPayload(req *requestParams) *requestHeaders {
}
}

func (g *GeminiAPI) request(verb, url string, postParams, getParams requestParams) ([]byte, error) {
func (g *GeminiApi) request(verb, url string, postParams, getParams requestParams) ([]byte, error) {

req, err := http.NewRequest(verb, url, bytes.NewBuffer([]byte{}))
if err != nil {
Expand Down
24 changes: 12 additions & 12 deletions routes-private.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// Past Trades
func (g *GeminiAPI) PastTrades(symbol string, limitTrades int, timestamp int64) ([]Trade, error) {
func (g *GeminiApi) PastTrades(symbol string, limitTrades int, timestamp int64) ([]Trade, error) {

url := g.url + PAST_TRADES_URL

Expand All @@ -31,7 +31,7 @@ func (g *GeminiAPI) PastTrades(symbol string, limitTrades int, timestamp int64)
}

// Trade Volume
func (g *GeminiAPI) TradeVolume() ([][]TradeVolume, error) {
func (g *GeminiApi) TradeVolume() ([][]TradeVolume, error) {

url := g.url + TRADE_VOLUME_URL
params := requestParams{
Expand All @@ -52,7 +52,7 @@ func (g *GeminiAPI) TradeVolume() ([][]TradeVolume, error) {
}

// Active Orders
func (g *GeminiAPI) ActiveOrders() ([]Order, error) {
func (g *GeminiApi) ActiveOrders() ([]Order, error) {

url := g.url + ACTIVE_ORDERS_URL
params := requestParams{
Expand All @@ -73,7 +73,7 @@ func (g *GeminiAPI) ActiveOrders() ([]Order, error) {
}

// Order Status
func (g *GeminiAPI) OrderStatus(orderId string) (Order, error) {
func (g *GeminiApi) OrderStatus(orderId string) (Order, error) {

url := g.url + ORDER_STATUS_URL
params := requestParams{
Expand All @@ -95,7 +95,7 @@ func (g *GeminiAPI) OrderStatus(orderId string) (Order, error) {
}

// New Order
func (g *GeminiAPI) NewOrder(symbol, clientOrderId string, amount, price float64, side string, options []string) (Order, error) {
func (g *GeminiApi) NewOrder(symbol, clientOrderId string, amount, price float64, side string, options []string) (Order, error) {

url := g.url + NEW_ORDER_URL
params := requestParams{
Expand Down Expand Up @@ -126,7 +126,7 @@ func (g *GeminiAPI) NewOrder(symbol, clientOrderId string, amount, price float64
}

// Cancel Order
func (g *GeminiAPI) CancelOrder(orderId string) (Order, error) {
func (g *GeminiApi) CancelOrder(orderId string) (Order, error) {

url := g.url + CANCEL_ORDER_URL
params := requestParams{
Expand All @@ -148,7 +148,7 @@ func (g *GeminiAPI) CancelOrder(orderId string) (Order, error) {
}

// Cancel All
func (g *GeminiAPI) CancelAll() (CancelResult, error) {
func (g *GeminiApi) CancelAll() (CancelResult, error) {
url := g.url + CANCEL_ALL_URL
params := requestParams{
"request": CANCEL_ALL_URL,
Expand All @@ -168,7 +168,7 @@ func (g *GeminiAPI) CancelAll() (CancelResult, error) {
}

// Cancel Session
func (g *GeminiAPI) CancelSession() (GenericResponse, error) {
func (g *GeminiApi) CancelSession() (GenericResponse, error) {
url := g.url + CANCEL_SESSION_URL
params := requestParams{
"request": CANCEL_SESSION_URL,
Expand All @@ -188,7 +188,7 @@ func (g *GeminiAPI) CancelSession() (GenericResponse, error) {
}

// Heartbeat
func (g *GeminiAPI) Heartbeat() (GenericResponse, error) {
func (g *GeminiApi) Heartbeat() (GenericResponse, error) {

url := g.url + HEARTBEAT_URL
params := requestParams{
Expand All @@ -209,7 +209,7 @@ func (g *GeminiAPI) Heartbeat() (GenericResponse, error) {
}

// Balances
func (g *GeminiAPI) Balances() ([]FundBalance, error) {
func (g *GeminiApi) Balances() ([]FundBalance, error) {

url := g.url + BALANCES_URL
params := requestParams{
Expand All @@ -230,7 +230,7 @@ func (g *GeminiAPI) Balances() ([]FundBalance, error) {
}

// New Deposit Address
func (g *GeminiAPI) NewDepositAddress(currency, label string) (DepositAddressResult, error) {
func (g *GeminiApi) NewDepositAddress(currency, label string) (DepositAddressResult, error) {

path := NEW_DEPOSIT_ADDRESS_URL + currency + "/newAddress"
url := g.url + path
Expand All @@ -253,7 +253,7 @@ func (g *GeminiAPI) NewDepositAddress(currency, label string) (DepositAddressRes
}

// Withdraw Crypto Funds
func (g *GeminiAPI) WithdrawFunds(currency, address string, amount float64) (WithdrawFundsResult, error) {
func (g *GeminiApi) WithdrawFunds(currency, address string, amount float64) (WithdrawFundsResult, error) {

path := WITHDRAW_FUNDS_URL + currency
url := g.url + path
Expand Down
12 changes: 6 additions & 6 deletions routes-public.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// Symbols
func (g *GeminiAPI) Symbols() ([]string, error) {
func (g *GeminiApi) Symbols() ([]string, error) {

url := g.url + SYMBOLS_URL

Expand All @@ -24,7 +24,7 @@ func (g *GeminiAPI) Symbols() ([]string, error) {
}

// Ticker
func (g *GeminiAPI) Ticker(symbol string) (Ticker, error) {
func (g *GeminiApi) Ticker(symbol string) (Ticker, error) {

url := g.url + TICKER_URL + symbol

Expand All @@ -43,7 +43,7 @@ func (g *GeminiAPI) Ticker(symbol string) (Ticker, error) {
}

// Order Book
func (g *GeminiAPI) OrderBook(symbol string, limitBids, limitAsks int) (Book, error) {
func (g *GeminiApi) OrderBook(symbol string, limitBids, limitAsks int) (Book, error) {

url := g.url + BOOK_URL + symbol

Expand All @@ -65,7 +65,7 @@ func (g *GeminiAPI) OrderBook(symbol string, limitBids, limitAsks int) (Book, er
}

// Trades
func (g *GeminiAPI) Trades(symbol string, since int64, limitTrades int, includeBreaks bool) ([]Trade, error) {
func (g *GeminiApi) Trades(symbol string, since int64, limitTrades int, includeBreaks bool) ([]Trade, error) {

url := g.url + TRADES_URL + symbol

Expand All @@ -89,7 +89,7 @@ func (g *GeminiAPI) Trades(symbol string, since int64, limitTrades int, includeB
}

// Current Auction
func (g *GeminiAPI) CurrentAuction(symbol string) (CurrentAuction, error) {
func (g *GeminiApi) CurrentAuction(symbol string) (CurrentAuction, error) {

url := g.url + AUCTION_URL + symbol

Expand All @@ -106,7 +106,7 @@ func (g *GeminiAPI) CurrentAuction(symbol string) (CurrentAuction, error) {
}

// Auction History
func (g *GeminiAPI) AuctionHistory(symbol string, since int64, limit int, includeIndicative bool) ([]Auction, error) {
func (g *GeminiApi) AuctionHistory(symbol string, since int64, limit int, includeIndicative bool) ([]Auction, error) {

url := g.url + AUCTION_URL + symbol + "/history"

Expand Down

0 comments on commit 167b8fe

Please sign in to comment.