Package com.github.katenachain.api
Class Handler
- java.lang.Object
-
- com.github.katenachain.api.Handler
-
public class Handler extends Object
Handler provides helper methods to send and retrieve tx without directly interacting with the HTTP Client.
-
-
Constructor Summary
Constructors Constructor Description Handler(String apiUrl, Serializer serializer)Handler constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getTxDataState(String chainId, Instant nonceTime, TxData txData)returns the sorted and marshaled json representation of a TxData ready to be signed.TxDataretrieveCertificate(String fqId)fetches the API and returns a certificate from the state.TxResultsretrieveCertificateTxs(String fqId, int page, int txPerPage)fetches the API to return all txs related to a certificate fqid.KeyV1[]retrieveCompanyKeys(String companyBcId, int page, int txPerPage)fetches the API and returns a list of keys for a company from the state.KeyV1retrieveKey(String fqId)fetches the API and returns a key from the state.TxResultsretrieveKeyTxs(String fqId, int page, int txPerPage)fetches the API to return all txs related to a key fqid.TxResultretrieveLastCertificateTx(String fqId)fetches the API to return the last tx related to a certificate fqid.TxResultretrieveLastKeyTx(String fqId)fetches the API to return the last tx related to a key fqid.TxResultretrieveLastSecretTx(String fqId)fetches the API to return the last tx related to a secret fqid.TxDataretrieveSecret(String fqId)fetches the API and returns a secret from the state.TxResultsretrieveSecretTxs(String fqId, int page, int txPerPage)fetches the API to return all txs related to a secret fqid.TxResultretrieveTx(String hash)fetches the API to return any tx by its hash.SendTxResultsendTx(Tx tx)accepts an encoded tx and sends it to the Api to return its status and its hash.TxsignTx(TxSigner txSigner, String chainId, Instant nonceTime, TxData txData)signs a tx data and returns a new tx ready to be sent.
-
-
-
Constructor Detail
-
Handler
public Handler(String apiUrl, Serializer serializer)
Handler constructor.- Parameters:
apiUrl-serializer-
-
-
Method Detail
-
retrieveLastCertificateTx
public TxResult retrieveLastCertificateTx(String fqId) throws IOException, ApiException
fetches the API to return the last tx related to a certificate fqid.- Parameters:
fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveCertificateTxs
public TxResults retrieveCertificateTxs(String fqId, int page, int txPerPage) throws IOException, ApiException
fetches the API to return all txs related to a certificate fqid.- Parameters:
fqId-page-txPerPage-- Returns:
- Throws:
IOExceptionApiException
-
retrieveLastSecretTx
public TxResult retrieveLastSecretTx(String fqId) throws IOException, ApiException
fetches the API to return the last tx related to a secret fqid.- Parameters:
fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveSecretTxs
public TxResults retrieveSecretTxs(String fqId, int page, int txPerPage) throws IOException, ApiException
fetches the API to return all txs related to a secret fqid.- Parameters:
txPerPage-page-fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveLastKeyTx
public TxResult retrieveLastKeyTx(String fqId) throws IOException, ApiException
fetches the API to return the last tx related to a key fqid.- Parameters:
fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveKeyTxs
public TxResults retrieveKeyTxs(String fqId, int page, int txPerPage) throws IOException, ApiException
fetches the API to return all txs related to a key fqid.- Parameters:
txPerPage-page-fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveTx
public TxResult retrieveTx(String hash) throws IOException, ApiException
fetches the API to return any tx by its hash.- Parameters:
hash-- Returns:
- Throws:
IOExceptionApiException
-
retrieveCertificate
public TxData retrieveCertificate(String fqId) throws IOException, ApiException
fetches the API and returns a certificate from the state.- Parameters:
fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveSecret
public TxData retrieveSecret(String fqId) throws IOException, ApiException
fetches the API and returns a secret from the state.- Parameters:
fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveKey
public KeyV1 retrieveKey(String fqId) throws IOException, ApiException
fetches the API and returns a key from the state.- Parameters:
fqId-- Returns:
- Throws:
IOExceptionApiException
-
retrieveCompanyKeys
public KeyV1[] retrieveCompanyKeys(String companyBcId, int page, int txPerPage) throws IOException, ApiException
fetches the API and returns a list of keys for a company from the state.- Parameters:
txPerPage-page-companyBcId-- Returns:
- Throws:
IOExceptionApiException
-
sendTx
public SendTxResult sendTx(Tx tx) throws IOException, ApiException
accepts an encoded tx and sends it to the Api to return its status and its hash.- Parameters:
tx-- Returns:
- Throws:
IOExceptionApiException
-
signTx
public Tx signTx(TxSigner txSigner, String chainId, Instant nonceTime, TxData txData) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException
signs a tx data and returns a new tx ready to be sent.- Parameters:
chainId-nonceTime-txSigner-txData-- Returns:
- Throws:
NoSuchAlgorithmExceptionInvalidKeyExceptionSignatureException
-
-