api

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastPath         = "/last"
	StatePath        = "/state"
	TxsPath          = "/txs"
	CertificatesPath = "/certificates"
	SecretsPath      = "/secrets"
	CompaniesPath    = "/companies"
	KeysPath         = "/keys"
)

Variables

This section is empty.

Functions

func EncodeTx added in v1.3.0

func EncodeTx(tx *entity.Tx) ([]byte, error)

EncodeTx defines the way the tx is encoded (here with the json marshaller).

func SignTx added in v1.3.0

func SignTx(txSigner *entity.TxSigner, chainId string, nonceTime entity.Time, txData entity.TxData) *entity.Tx

SignTx creates a tx data state, signs it and returns a tx ready to be encoded and sent.

func UnmarshalApiResponse added in v1.3.0

func UnmarshalApiResponse(apiResponse *entityApi.RawResponse, dest interface{}) error

UnmarshalApiResponse tries to parse the api response body into the provided interface if the API returns a 200 or a 202 HTTP code. If not, it tries to parse it in a PublicError.

Types

type Client added in v1.4.0

type Client interface {
	Get(route string, headers map[string]string, queryValues map[string]string) (*api.RawResponse, error)
	Post(route string, body []byte, headers map[string]string, queryValues map[string]string) (*api.RawResponse, error)
	AddHeader(key string, value string)
	RemoveHeader(key string)
}

Client interface defines the methods a concrete client must implement.

type FastHttpClient added in v1.4.0

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

FastHttpClient is a fasthttp.FastHttpClient wrapper to dialog with a JSON API.

func NewFastHttpClient added in v1.4.0

func NewFastHttpClient(apiUrl string) *FastHttpClient

FastHttpClient constructor.

func (FastHttpClient) AddHeader added in v1.4.0

func (c FastHttpClient) AddHeader(key string, value string)

AddHeader adds a persistent header that will be sent in every future doRequest calls.

func (FastHttpClient) Get added in v1.4.0

func (c FastHttpClient) Get(
	route string,
	headers map[string]string,
	queryValues map[string]string,
) (*api.RawResponse, error)

Get wraps the doRequest method to do a GET HTTP request.

func (FastHttpClient) Post added in v1.4.0

func (c FastHttpClient) Post(
	route string,
	body []byte,
	headers map[string]string,
	queryValues map[string]string,
) (*api.RawResponse, error)

Post wraps the doRequest method to do a POST HTTP request.

func (FastHttpClient) RemoveHeader added in v1.4.0

func (c FastHttpClient) RemoveHeader(key string)

RemoveHeader removes a persistent header.

type Handler

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

Handler provides helper methods to send and retrieve txs without directly interacting with the HTTP Client.

func NewHandler

func NewHandler(apiUrl string) *Handler

Handler constructor.

func (*Handler) GetAndFormat added in v1.3.0

func (h *Handler) GetAndFormat(route string, queryParams map[string]string, instance interface{}) error

GetAndFormat fetches the API route and try to unmarshal the response in the provided instance.

func (*Handler) RetrieveCertificate

func (h *Handler) RetrieveCertificate(fqId string) (entity.TxData, error)

RetrieveCertificate fetches the API and returns a certificate from the state.

func (*Handler) RetrieveCertificateTxs added in v1.3.0

func (h *Handler) RetrieveCertificateTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)

RetrieveCertificateTxs fetches the API to return all txs related to a certificate fqid.

func (*Handler) RetrieveCompanyKeys added in v1.1.0

func (h *Handler) RetrieveCompanyKeys(companyBcId string, page int, txPerPage int) ([]*account.KeyV1, error)

RetrieveCompanyKeys fetches the API and returns a list of keys for a company from the state.

func (*Handler) RetrieveKey added in v1.3.0

func (h *Handler) RetrieveKey(fqId string) (*account.KeyV1, error)

RetrieveKey fetches the API and returns a key from the state.

func (*Handler) RetrieveKeyTxs added in v1.3.0

func (h *Handler) RetrieveKeyTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)

RetrieveKeyTxs fetches the API to return all txs related to a key fqid.

func (*Handler) RetrieveLastCertificateTx added in v1.3.0

func (h *Handler) RetrieveLastCertificateTx(fqId string) (*entityApi.TxResult, error)

RetrieveLastCertificateTx fetches the API to return the last tx related to a certificate fqid.

func (*Handler) RetrieveLastKeyTx added in v1.3.0

func (h *Handler) RetrieveLastKeyTx(fqId string) (*entityApi.TxResult, error)

RetrieveLastKeyTxs fetches the API to return the last txs related to a key fqid.

func (*Handler) RetrieveLastSecretTx added in v1.3.0

func (h *Handler) RetrieveLastSecretTx(fqId string) (*entityApi.TxResult, error)

RetrieveLastSecretTxs fetches the API to return the last tx related to a secret fqid.

func (*Handler) RetrieveSecret added in v1.3.10

func (h *Handler) RetrieveSecret(fqId string) (entity.TxData, error)

RetrieveSecret fetches the API and returns a secret from the state.

func (*Handler) RetrieveSecretTxs added in v1.3.0

func (h *Handler) RetrieveSecretTxs(fqId string, page int, txPerPage int) (*entityApi.TxResults, error)

RetrieveSecretTxs fetches the API to return all txs related to a secret fqid.

func (*Handler) RetrieveTx added in v1.1.0

func (h *Handler) RetrieveTx(hash string) (*entityApi.TxResult, error)

RetrieveTx fetches the API to return any tx by its hash.

func (*Handler) SafeGet added in v1.1.0

func (h *Handler) SafeGet(route string, queryParams map[string]string) (_ *entityApi.RawResponse, katenaError error)

SafeGet calls the api handler get method and recover if it panics.

func (*Handler) SafePost added in v1.1.0

func (h *Handler) SafePost(route string, body []byte) (_ *entityApi.RawResponse, katenaError error)

SafePost calls the api handler post method and recover if it panics.

func (*Handler) SendRawTx added in v1.3.5

func (h *Handler) SendRawTx(txBytes []byte) (*entityApi.SendTxResult, error)

SendTx accepts an encoded tx and sends it to the Api to return its status and its hash.

func (*Handler) SendTx

func (h *Handler) SendTx(txData entity.TxData, txSigner *entity.TxSigner, chainId string) (status *entityApi.SendTxResult, err error)

SendTx creates a tx from a tx data and the provided tx signer info and chain id, signs it, encodes it and sends it to the api.

Jump to

Keyboard shortcuts

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