Documentation ¶
Index ¶
- Constants
- Variables
- type AddressService
- type BlockHeaderService
- type Client
- type ClientOps
- type LoginResponse
- type TransactionService
- type TransportHTTP
- func (h *TransportHTTP) GetAddressTransactionDetails(ctx context.Context, address string) (transactions []*models.Transaction, err error)
- func (h *TransportHTTP) GetAddressTransactions(ctx context.Context, address string) (addr []*models.Address, err error)
- func (h *TransportHTTP) GetBlockHeader(ctx context.Context, block string) (blockHeader *models.BlockHeader, err error)
- func (h *TransportHTTP) GetBlockHeaders(ctx context.Context, fromBlock string, limit uint) (blockHeaders []*models.BlockHeader, err error)
- func (h *TransportHTTP) GetServerURL() string
- func (h *TransportHTTP) GetSubscriptionToken(ctx context.Context, subscriptionID string) (string, error)
- func (h *TransportHTTP) GetToken() string
- func (h *TransportHTTP) GetTransaction(ctx context.Context, txID string) (transaction *models.Transaction, err error)
- func (h *TransportHTTP) IsDebug() bool
- func (h *TransportHTTP) IsSSL() bool
- func (h *TransportHTTP) Login(ctx context.Context, username string, password string) error
- func (h *TransportHTTP) RefreshToken(ctx context.Context) (string, error)
- func (h *TransportHTTP) SetDebug(debug bool)
- func (h *TransportHTTP) SetToken(token string)
- func (h *TransportHTTP) SetVersion(version string)
- func (h *TransportHTTP) UseSSL(useSSL bool)
- type TransportService
- type TransportType
Constants ¶
const ( // FieldID is the id field for most models FieldID = "id" // FieldUsername is the username field for login FieldUsername = "username" // FieldPassword is the password field for login FieldPassword = "password" // FieldSubscriptionID is the subscription id field FieldSubscriptionID = "id" // FieldUserAgent is the field for storing the user agent FieldUserAgent = "user_agent" )
const JungleBusClientVersion = "v0.1.0"
JungleBusClientVersion is the version of the client
const JungleBusUserAgent = "JungleBus: go-client " + JungleBusClientVersion
JungleBusUserAgent the user agent sent to the jungle bus server
Variables ¶
var ErrFailedLogin = errors.New("failed to login to server")
var ErrNoClientSet = errors.New("no transport client set")
ErrNoClientSet is when no client is set
Functions ¶
This section is empty.
Types ¶
type AddressService ¶
type AddressService interface { GetAddressTransactions(ctx context.Context, address string) ([]*models.Address, error) GetAddressTransactionDetails(ctx context.Context, address string) ([]*models.Transaction, error) }
AddressService is the address related requests
type BlockHeaderService ¶
type BlockHeaderService interface { GetBlockHeader(ctx context.Context, block string) (*models.BlockHeader, error) GetBlockHeaders(ctx context.Context, fromBlock string, limit uint) ([]*models.BlockHeader, error) }
BlockHeaderService is the block header related requests
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the transport client
type ClientOps ¶
type ClientOps func(c *Client)
ClientOps are the client options functions
func WithDebugging ¶
WithDebugging will set whether to turn debugging on
func WithHTTPClient ¶
WithHTTPClient will overwrite the default client with a custom client
func WithVersion ¶
WithVersion will set the version of the API to use
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
}
LoginResponse response from server on login or token refresh
type TransactionService ¶
type TransactionService interface {
GetTransaction(ctx context.Context, txID string) (*models.Transaction, error)
}
TransactionService is the transaction related requests
type TransportHTTP ¶
type TransportHTTP struct {
// contains filtered or unexported fields
}
TransportHTTP is the struct for HTTP
func (*TransportHTTP) GetAddressTransactionDetails ¶
func (h *TransportHTTP) GetAddressTransactionDetails(ctx context.Context, address string) (transactions []*models.Transaction, err error)
GetAddressTransactionDetails will get all transactions related to the given address
func (*TransportHTTP) GetAddressTransactions ¶
func (h *TransportHTTP) GetAddressTransactions(ctx context.Context, address string) (addr []*models.Address, err error)
GetAddressTransactions will get the metadata of all transaction related to the given address
func (*TransportHTTP) GetBlockHeader ¶
func (h *TransportHTTP) GetBlockHeader(ctx context.Context, block string) (blockHeader *models.BlockHeader, err error)
GetBlockHeader will get the given block header details Can pass either the block hash or the block height (as a string)
func (*TransportHTTP) GetBlockHeaders ¶
func (h *TransportHTTP) GetBlockHeaders(ctx context.Context, fromBlock string, limit uint) (blockHeaders []*models.BlockHeader, err error)
GetBlockHeaders will get all block headers from the given block, limited by limit Can pass either the block hash or the block height (as a string)
func (*TransportHTTP) GetServerURL ¶
func (h *TransportHTTP) GetServerURL() string
GetServerURL get the server URL for this transport
func (*TransportHTTP) GetSubscriptionToken ¶
func (h *TransportHTTP) GetSubscriptionToken(ctx context.Context, subscriptionID string) (string, error)
GetSubscriptionToken gets a token based on the subscription ID
func (*TransportHTTP) GetToken ¶
func (h *TransportHTTP) GetToken() string
GetToken gets the token to use for all requests
func (*TransportHTTP) GetTransaction ¶
func (h *TransportHTTP) GetTransaction(ctx context.Context, txID string) (transaction *models.Transaction, err error)
GetTransaction will get a transaction by ID
func (*TransportHTTP) IsDebug ¶
func (h *TransportHTTP) IsDebug() bool
IsDebug return the debugging status
func (*TransportHTTP) RefreshToken ¶
func (h *TransportHTTP) RefreshToken(ctx context.Context) (string, error)
RefreshToken gets a new token to use for all requests
func (*TransportHTTP) SetDebug ¶
func (h *TransportHTTP) SetDebug(debug bool)
SetDebug turn the debugging on or off
func (*TransportHTTP) SetToken ¶
func (h *TransportHTTP) SetToken(token string)
SetToken sets the token to use for all requests manually
func (*TransportHTTP) SetVersion ¶
func (h *TransportHTTP) SetVersion(version string)
SetVersion sets the version to use for all calls
func (*TransportHTTP) UseSSL ¶
func (h *TransportHTTP) UseSSL(useSSL bool)
UseSSL turn the SSL on or off
type TransportService ¶
type TransportService interface { AddressService BlockHeaderService TransactionService Login(ctx context.Context, username string, password string) error IsDebug() bool SetDebug(debug bool) GetToken() string GetSubscriptionToken(ctx context.Context, subscriptionID string) (string, error) RefreshToken(ctx context.Context) (string, error) SetToken(token string) SetVersion(version string) UseSSL(useSSL bool) IsSSL() bool GetServerURL() string }
TransportService the transport service interface
func NewTransport ¶
func NewTransport(opts ...ClientOps) (TransportService, error)
NewTransport create a new transport service object
func NewTransportService ¶
func NewTransportService(transportService TransportService) TransportService
NewTransportService create a new transport service interface
type TransportType ¶
type TransportType string
TransportType the type of transport being used (http or graphql)
const ( // JungleBusTransportHTTP uses the http transport for all jungle bus server actions JungleBusTransportHTTP TransportType = "http" // JungleBusTransportMock uses the mock transport for all jungle bus server actions JungleBusTransportMock TransportType = "mock" )