inlock

package module
v0.0.0-...-9774582 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-inlock

INLOCK.io API library in Golang

Example

package main

import (
	"context"
	"fmt"
	"github.com/bitbandi/go-inlock"
)

func main() {
	auth := context.WithValue(context.Background(), inlock.ContextAPIKey, inlock.APIKey{
		Key:    "apikey",
		Secret: "apisecret",
	})
	cfg := inlock.NewConfiguration()
	client := inlock.NewAPIClient(cfg)
	balance, resp, err := client.OtherApi.GetBalance(auth, &inlock.OtherApiGetBalanceOpts{})
	fmt.Println(balance, resp, err)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	AddressApi *AddressApiService

	OtherApi *OtherApiService

	TokenmarketApi *TokenmarketApiService

	WithdrawApi *WithdrawApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the INLOCK API API v1.4.5 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type APIError

type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type APIKey

type APIKey struct {
	Key    string
	Secret string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	Error  APIError  `json:"error,omitempty"`
	Result APIResult `json:"result"`
}

type APIResult

type APIResult struct {
	Status       string `json:"status"`
	ResponseData map[string]json.RawMessage
}

func (*APIResult) UnmarshalJSON

func (rs *APIResult) UnmarshalJSON(b []byte) error

type AddressApiService

type AddressApiService service

func (*AddressApiService) GetWithdrawDetails

func (a *AddressApiService) GetWithdrawDetails(ctx context.Context, ticker string) (WithdrawDetailsResp, *http.Response, error)

AddressApiService Returns the data necessary for managing user wallet withdrawals.:tag address

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param ticker Ticker of the coin.

@return WithdrawDetailsResp

func (*AddressApiService) ListDepositAddresses

func (a *AddressApiService) ListDepositAddresses(ctx context.Context, ticker string) (DepositAddressesResp, *http.Response, error)

AddressApiService Returns the deposit addresses of the user for the given coin ID.:tag address

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param ticker Tickoer of the coin.

@return DepositAddressesResp

type BalanceResp

type BalanceResp struct {
	// fiat values calculated in this currency (default: usd)
	Fiat string `json:"fiat,omitempty"`
	// total available balance in fiat.
	Total string `json:"total,omitempty"`
	// sum pending interest in fiat.
	AccruingInterestFiat string `json:"accruing_interest_fiat,omitempty"`
	// sum of total interest earned in fiat.
	TotalInterestEarnedFiat string `json:"total_interest_earned_fiat,omitempty"`
	// List of detailed balance entries per coins
	Coins []BalanceRespCoins `json:"coins,omitempty"`
}

type BalanceRespCoins

type BalanceRespCoins struct {
	// ticker of coin of the balance
	Ticker string `json:"ticker,omitempty"`
	// amount of available balance in normal format
	Balance string `json:"balance,omitempty"`
	// amount of pending balance (deposit under confirming or pending withdrawal)
	Pending string `json:"pending,omitempty"`
	// locked amount (defined for further functions, but not used in INLOCK WL)
	Locked string `json:"locked,omitempty"`
	// pending interest. (in kind)
	AccruingInterest string `json:"accruing_interest,omitempty"`
	// amount of interest credited since onboarding. (in kind)
	TotalInterestEarned string `json:"total_interest_earned,omitempty"`
	// amount of available in fiat
	BalanceFiat string `json:"balance_fiat,omitempty"`
	// amount of pending balance in fiat
	PendingFiat string `json:"pending_fiat,omitempty"`
	// locked amount in fiat
	LockedFiat string `json:"locked_fiat,omitempty"`
	// pending interest in fiat
	AccruingInterestFiat string `json:"accruing_interest_fiat,omitempty"`
	// amount of interest credited since onboarding in fiat
	TotalInterestEarnedFiat string `json:"total_interest_earned_fiat,omitempty"`
}

type BuyTokenLimitBody

type BuyTokenLimitBody struct {
	Amount string `json:"amount"`
	Limit  string `json:"limit"`
	Pair   string `json:"pair"`
}

type BuyTokenMarketBody

type BuyTokenMarketBody struct {
	// Amount to buy.
	Amount string `json:"amount"`
	// Trading pair of the market e.g.: XBTILK.
	Pair string `json:"pair"`
	// Limit of cost. Spend at most limit amount.
	Limit string `json:"limit,omitempty"`
	// Limit of price. The average price of the buy order is capped at this value. limit and limit_price can not be specified at the same time.
	LimitPrice string `json:"limit_price,omitempty"`
}

type BuyTokenMarketResult

type BuyTokenMarketResult struct {
	// Amount of token bought.
	Bought string `json:"bought,omitempty"`
	// Amount of money spent.
	Spent string `json:"spent,omitempty"`
}

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type DepositAddressesResp

type DepositAddressesResp struct {
	// addresses of the user
	Addresses []DepositAddressesRespAddresses `json:"addresses,omitempty"`
}

type DepositAddressesRespAddresses

type DepositAddressesRespAddresses struct {
	// ticker of coin
	Ticker string `json:"ticker,omitempty"`
	// chain identifier. Possible results: native, bep2, bep20, erc20, trc20, omni, sol, cardano
	Network string `json:"network,omitempty"`
	// is this address is primary for coin? Only native chain's address can be primary
	Primary bool `json:"primary,omitempty"`
	// address for coin deposits on chain
	Address string `json:"address,omitempty"`
	// additional memo for deposits (only valid on bep2 network)
	Memo string `json:"memo,omitempty"`
}

type GeneralErrorResponse

type GeneralErrorResponse struct {
	Result *GeneralErrorResponseResult `json:"result,omitempty"`
	Error_ *GeneralErrorResponseError  `json:"error,omitempty"`
}

type GeneralErrorResponseError

type GeneralErrorResponseError struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

type GeneralErrorResponseResult

type GeneralErrorResponseResult struct {
	Status   string       `json:"status,omitempty"`
	ENDPOINT *interface{} `json:"ENDPOINT,omitempty"`
}

type GenericSwaggerError

type GenericSwaggerError struct {
	// contains filtered or unexported fields
}

GenericSwaggerError Provides access to the body, error and model on returned errors.

func (GenericSwaggerError) Body

func (e GenericSwaggerError) Body() []byte

Body returns the raw bytes of the response

func (GenericSwaggerError) Error

func (e GenericSwaggerError) Error() string

Error returns non-empty string if there was an error.

func (GenericSwaggerError) Model

func (e GenericSwaggerError) Model() interface{}

Model returns the unpacked model of the error

type LoanHistoryResp

type LoanHistoryResp struct {
	// List of event records.
	Events []LoanHistoryRespEvents `json:"events,omitempty"`
}

type LoanHistoryRespEvents

type LoanHistoryRespEvents struct {
	// Unique ID of the event.
	EvId int64 `json:"ev_id,omitempty"`
	// Time of creation. Unix timestamp in UTC.
	Created int64 `json:"created,omitempty"`
	// Type of event.
	Type_ string `json:"type,omitempty"`
	// Amount related to the event. Optional, can be null.
	Amt string `json:"amt,omitempty"`
	// Ticker related to the event. Optional, can be null.
	Ticker string `json:"ticker,omitempty"`
}

type OrderBookResp

type OrderBookResp struct {
	// Market e.g.: 'XBTILK'
	Market string `json:"market,omitempty"`
	// Sell items
	Sell []OrderBookRespSell `json:"sell,omitempty"`
	// Buy items
	Buy []OrderBookRespSell `json:"buy,omitempty"`
}

type OrderBookRespSell

type OrderBookRespSell struct {
	// Amount of the order
	Amount string `json:"amount,omitempty"`
	// Price of the order
	Price string `json:"price,omitempty"`
	// the order is the user's own order
	Own bool `json:"own,omitempty"`
}

type OrderIdResp

type OrderIdResp struct {
	// ID of the order
	Orderid int64 `json:"orderid,omitempty"`
}

type OtherApiGetBalanceOpts

type OtherApiGetBalanceOpts struct {
	Fiat optional.String
}

type OtherApiGetLoanHistoryOpts

type OtherApiGetLoanHistoryOpts struct {
	AfterId optional.Int64
	Count   optional.Int64
}

type OtherApiGetSwapHistoryOpts

type OtherApiGetSwapHistoryOpts struct {
	CoinFrom optional.String
	CoinTo   optional.String
	AfterId  optional.Int64
	Count    optional.Int64
}

type OtherApiGetTmLimitHistoryOpts

type OtherApiGetTmLimitHistoryOpts struct {
	Coin    optional.String
	AfterId optional.Int64
	Count   optional.Int64
}

type OtherApiGetTmMarketHistoryOpts

type OtherApiGetTmMarketHistoryOpts struct {
	Coin    optional.String
	AfterId optional.Int64
	Count   optional.Int64
}

type OtherApiGetWalletHistoryOpts

type OtherApiGetWalletHistoryOpts struct {
	Coin    optional.String
	AfterId optional.Int64
	Count   optional.Int64
}

type OtherApiService

type OtherApiService service

func (*OtherApiService) BuyTokenMarket

OtherApiService Buy token on INLOCK Tokenmarket (market order, instant fulfilled or revert).

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return BuyTokenMarketResult

func (*OtherApiService) GetBalance

func (a *OtherApiService) GetBalance(ctx context.Context, localVarOptionals *OtherApiGetBalanceOpts) (BalanceResp, *http.Response, error)

func (*OtherApiService) GetLoanHistory

func (a *OtherApiService) GetLoanHistory(ctx context.Context, localVarOptionals *OtherApiGetLoanHistoryOpts) (LoanHistoryResp, *http.Response, error)

func (*OtherApiService) GetSwapHistory

func (a *OtherApiService) GetSwapHistory(ctx context.Context, localVarOptionals *OtherApiGetSwapHistoryOpts) (SwapHistoryResp, *http.Response, error)

func (*OtherApiService) GetTmLimitHistory

func (a *OtherApiService) GetTmLimitHistory(ctx context.Context, localVarOptionals *OtherApiGetTmLimitHistoryOpts) (TmHistoryResp, *http.Response, error)

func (*OtherApiService) GetTmMarketHistory

func (a *OtherApiService) GetTmMarketHistory(ctx context.Context, localVarOptionals *OtherApiGetTmMarketHistoryOpts) (TmHistoryResp, *http.Response, error)

func (*OtherApiService) GetWalletHistory

func (a *OtherApiService) GetWalletHistory(ctx context.Context, localVarOptionals *OtherApiGetWalletHistoryOpts) (WalletHistoryResp, *http.Response, error)

func (*OtherApiService) SellTokenMarket

OtherApiService Sell token on INLOCK Tokenmarket (market order, instantly fulfilled or reverted).

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return SellTokenMarketResult

type SellTokenLimitBody

type SellTokenLimitBody struct {
	Amount string `json:"amount"`
	Limit  string `json:"limit"`
	Pair   string `json:"pair"`
}

type SellTokenMarketBody

type SellTokenMarketBody struct {
	// Amount to sell.
	Amount string `json:"amount"`
	// Trading pair of the market e.g.: XBTILK.
	Pair string `json:"pair"`
}

type SellTokenMarketResult

type SellTokenMarketResult struct {
	// Amount of token sold.
	Sold string `json:"sold,omitempty"`
	// Amount of money gain.
	Gain string `json:"gain,omitempty"`
}

type StartWithdrawBody

type StartWithdrawBody struct {
	// Withdrawal address.
	Address string `json:"address"`
	// Ticker of the coin.
	Ticker string `json:"ticker"`
	// network of chain of a multichain asset.
	Network string `json:"network"`
	// Amount to withdraw.
	Amount string `json:"amount"`
}

type StartWithdrawResp

type StartWithdrawResp struct {
	// Request ID.
	ReqId int64 `json:"req_id,omitempty"`
}

type SwapHistoryResp

type SwapHistoryResp struct {
	// List of event records.
	Events []SwapHistoryRespEvents `json:"events,omitempty"`
}

type SwapHistoryRespEvents

type SwapHistoryRespEvents struct {
	// Unique ID of event.
	EvId int64 `json:"ev_id,omitempty"`
	// Time of creation. Unix timestamp in UTC.
	Created int64 `json:"created,omitempty"`
	// Type of event.
	Type_ string `json:"type,omitempty"`
	// From amount.
	FromAmt string `json:"from_amt,omitempty"`
	// From ticker.
	FromTicker string `json:"from_ticker,omitempty"`
	// To ticker.
	ToTicker string `json:"to_ticker,omitempty"`
	// Price.
	Price string `json:"price,omitempty"`
	// To amount.
	ToAmt string `json:"to_amt,omitempty"`
	// From coin is the primary (e.g. for price display) or the to coin.
	FromPrimary bool `json:"from_primary,omitempty"`
}

type TmHistoryResp

type TmHistoryResp struct {
	// List of event records.
	Events []TmHistoryRespEvents `json:"events,omitempty"`
}

type TmHistoryRespEvents

type TmHistoryRespEvents struct {
	// Unique ID of the event.
	EvId int64 `json:"ev_id,omitempty"`
	// Time of creation. Unix timestamp in UTC.
	Created int64 `json:"created,omitempty"`
	// Type of event.
	Type_ string `json:"type,omitempty"`
	// Amount of ILK bought/sold.
	Amt string `json:"amt,omitempty"`
	// Cost of buy/sell.
	Cost string `json:"cost,omitempty"`
	// Ticker of cost.
	Ticker string `json:"ticker,omitempty"`
}

type TokenmarketApiService

type TokenmarketApiService service

func (*TokenmarketApiService) BuyTokenLimit

TokenmarketApiService Buy token:tag _tokenmarket

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return OrderIdResp

func (*TokenmarketApiService) GetTokenMarket

func (a *TokenmarketApiService) GetTokenMarket(ctx context.Context, pair string) (OrderBookResp, *http.Response, error)

TokenmarketApiService Returns all of the orderbook for the given trading pair:tag _tokenmarket

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param pair

@return OrderBookResp

func (*TokenmarketApiService) SellTokenLimit

TokenmarketApiService Sell token:tag _tokenmarket

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return OrderIdResp

type WalletHistoryResp

type WalletHistoryResp struct {
	// List of event records.
	Events []WalletHistoryRespEvents `json:"events,omitempty"`
}

type WalletHistoryRespEvents

type WalletHistoryRespEvents struct {
	// Unique ID of the event.
	EvId int64 `json:"ev_id,omitempty"`
	// Time of creation. Unix timestamp in UTC.
	Created int64 `json:"created,omitempty"`
	// Type of event.
	Type_ string `json:"type,omitempty"`
	// Status of withdraw events.
	Status string `json:"status,omitempty"`
	// Amount related to the event. Optional, can be null.
	Amt string `json:"amt,omitempty"`
	// Ticker related to the event. Optional, can be null.
	Ticker string `json:"ticker,omitempty"`
	// Shows the sender of the transfer. Optional, only used in internal/badge transfers
	FromUser string `json:"from_user,omitempty"`
	// Shows the receiver of the transfer. Optional, only used in internal/badge transfers
	ToUser string `json:"to_user,omitempty"`
	// Second amount related to the event. Optional, can be null.
	Amt2 string `json:"amt2,omitempty"`
	// Second ticker related to the event. Optional, can be null.
	Ticker2 string `json:"ticker2,omitempty"`
	// Third amount related to the event. Optional, can be null.
	Amt3 string `json:"amt3,omitempty"`
	// Description related to the event. Can be null.
	Desc string `json:"desc,omitempty"`
}

type WithdrawApiService

type WithdrawApiService service

func (*WithdrawApiService) StartWithdraw

WithdrawApiService Requests a new withdrawal from user balance.:tag withdraw

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param body

@return StartWithdrawResp

type WithdrawDetailsResp

type WithdrawDetailsResp struct {
	// List of withdraw details for each supported chain.
	Chains []WithdrawDetailsRespChains `json:"chains,omitempty"`
}

type WithdrawDetailsRespAddresses

type WithdrawDetailsRespAddresses struct {
	// Address
	Address string `json:"address,omitempty"`
	// User defined description.
	Description string `json:"description,omitempty"`
	// Memo
	Memo string `json:"memo,omitempty"`
	// timestamp if the withdraw address is locked
	LockedUntil int64 `json:"locked_until,omitempty"`
}

type WithdrawDetailsRespChains

type WithdrawDetailsRespChains struct {
	// Ticker of the coin
	Ticker string `json:"ticker,omitempty"`
	// Chain identifier
	Network string `json:"network,omitempty"`
	// Short name of chain
	ChainShortName string `json:"chain_short_name,omitempty"`
	// Long name of chain
	ChainLongName string `json:"chain_long_name,omitempty"`
	// True if this is the recommended, primary (native) chain for withdraw, false otherwise.
	IsPrimary bool `json:"is_primary,omitempty"`
	// Withdraw addresses of the user.
	Addresses []WithdrawDetailsRespAddresses `json:"addresses,omitempty"`
	// Minimal withdraw amount.
	MinAmt string `json:"min_amt,omitempty"`
	// Fix withdraw fee in the same coin.
	FeeBase string `json:"fee_base,omitempty"`
	// Fee multiplier in the same coin (fee = fee_base + amount * fee_mult).
	FeeMult string                      `json:"fee_mult,omitempty"`
	FeeInfo *WithdrawDetailsRespFeeInfo `json:"fee_info,omitempty"`
	// Congestion status of the network: \"no\", \"slight\", \"significant\", \"heavy\", \"disabled\".
	Congestion string `json:"congestion,omitempty"`
}

type WithdrawDetailsRespFeeInfo

type WithdrawDetailsRespFeeInfo struct {
	// True if this withdraw will be free by zero withdraw fee, otherwise false
	FreeWithdraw bool `json:"free_withdraw,omitempty"`
	// True if this withdraws fee will be waived, otherwise false
	WaivedWithdraw bool `json:"waived_withdraw,omitempty"`
	// monthly total waived withdrawal fees
	TotalWaives int64 `json:"total_waives,omitempty"`
	// already used monthly waived fees on withdrawals
	UsedWaives int64 `json:"used_waives,omitempty"`
	// source of waived fees (should be: \"ilkbalance\",\"badge\",\"gift\",\"other\" or None.)
	Reason string `json:"reason,omitempty"`
}

Info about free withdrawals.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址