mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-08-31 05:10:25 +00:00
implemented getTrytes command request
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
@@ -81,7 +82,8 @@ public class IotaAPIProxy {
|
||||
}
|
||||
|
||||
public GetTransfersResponse getTransfers(String seed, Integer securityLevel) {
|
||||
final Call<GetTransfersResponse> res = service.getTransfers(IotaGetTransferRequest.createGetTransferRequest(seed, securityLevel));
|
||||
final IotaGetTransferRequest tr = IotaGetTransferRequest.createGetTransferRequest(seed, securityLevel);
|
||||
final Call<GetTransfersResponse> res = service.getTransfers(tr);
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
@@ -98,19 +100,19 @@ public class IotaAPIProxy {
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
public FindTransactionResponse findTransactionsByAddresses(String [] addresses) {
|
||||
public FindTransactionResponse findTransactionsByAddresses(final String ... addresses) {
|
||||
return findTransactions(addresses, null, null, null);
|
||||
}
|
||||
|
||||
public FindTransactionResponse findTransactionsByBundles(String [] bundles) {
|
||||
public FindTransactionResponse findTransactionsByBundles(final String ... bundles) {
|
||||
return findTransactions(null, null, null, bundles);
|
||||
}
|
||||
|
||||
public FindTransactionResponse findTransactionsByApprovees(String [] approvees) {
|
||||
public FindTransactionResponse findTransactionsByApprovees(final String ... approvees) {
|
||||
return findTransactions(null, null, approvees, null);
|
||||
}
|
||||
|
||||
public FindTransactionResponse findTransactionsByDigests(String [] digests) {
|
||||
public FindTransactionResponse findTransactionsByDigests(final String ... digests) {
|
||||
return findTransactions(null, digests, null, null);
|
||||
}
|
||||
|
||||
@@ -126,6 +128,16 @@ public class IotaAPIProxy {
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
public GetBundleResponse getBundle(String transaction) {
|
||||
final Call<GetBundleResponse> res = service.getBundle(IotaGetBundleRequest.createIotaGetBundleRequest(transaction));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
public GetTrytesResponse getTrytes(String ... hashes) {
|
||||
final Call<GetTrytesResponse> res = service.getTrytes(IotaGetTrytesRequest.createGetTrytesRequest(hashes));
|
||||
return wrapCheckedException(res).body();
|
||||
}
|
||||
|
||||
protected static <T> Response<T> wrapCheckedException(final Call<T> call) {
|
||||
try {
|
||||
final Response<T> res = call.execute();
|
||||
|
||||
@@ -53,19 +53,19 @@ public interface IotaAPIService {
|
||||
|
||||
/**
|
||||
* Get the list of latest tips (unconfirmed transactions).
|
||||
*
|
||||
*
|
||||
* curl http://localhost:14265 \ -X POST \ -H 'Content-Type:
|
||||
* application/json' \ -d '{"command": "getTips"}'
|
||||
*/
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<GetTipsResponse> getTips(@Body IotaCommandRequest request);
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of latest tips (unconfirmed transactions).
|
||||
*
|
||||
* curl http://localhost:14265 \ -X POST \ -H 'Content-Type:
|
||||
* application/json' \ -d '{"command": "getTips"}'
|
||||
* Get the list of transfers from a specified seed (account).
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getTransfers", "seed": "AAA999999999999999999999999999999999999999999999999999999999999999999999999999999", "securityLevel": 1}'
|
||||
*/
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
@@ -88,22 +88,34 @@ public interface IotaAPIService {
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getInclusionStates", "transactions"Q9HZWYKFWYWZRE9JQKG9REPKIASHUUECPSQO9JT9XNMVKWYGVAZETAIRPTM"], "tips" : []}'
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<GetInclusionStateResponse> getInclusionStates(@Body IotaGetInclusionStateRequest request);
|
||||
|
||||
/**
|
||||
* Get the list of transactions which were bundled with the specified tail transaction. This call returns the full value of all individual transactions, not just the hashes.
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getBundle", "transaction": "ZJVYUGTDRPDYFGFXMKOTV9ZWSGFK9CFPXTITQLQNLPPG9YNAARMKNKYQO9GSCSBIOTGMLJUFLZWSY9999"}'
|
||||
*
|
||||
*/
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<GetBundleResponse> getBundle(@Body IotaGetBundleRequest request);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns the raw trytes data of a transaction.
|
||||
*
|
||||
* curl http://localhost:14265 -X POST -H 'Content-Type: application/json'
|
||||
* -d '{"command": "getTrytes", "hashes": ["OAATQS9VQLSXCLDJVJJVYUGONXAXOFMJOZNSYWRZSWECMXAQQURHQBJNLD9IOFEPGZEPEMPXCIVRX9999"]}'
|
||||
*
|
||||
*/
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<GetTrytesResponse> getTrytes(@Body IotaGetTrytesRequest request);
|
||||
|
||||
/*
|
||||
@Headers({ CONTENT_TYPE_HEADER, USER_AGENT_HEADER })
|
||||
@POST("./")
|
||||
Call<AnalyzeTransactionResponse> analyzeTransactions(@Body IotaAnalyzeTransactionRequest request);
|
||||
|
||||
@@ -17,22 +17,22 @@ public class IotaFindTransactionsRequest extends IotaCommandRequest {
|
||||
return new IotaFindTransactionsRequest();
|
||||
}
|
||||
|
||||
public IotaFindTransactionsRequest byBundles(String [] bundles) {
|
||||
public IotaFindTransactionsRequest byBundles(String ... bundles) {
|
||||
this.bundles = bundles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IotaFindTransactionsRequest byAddresses(String [] addresses) {
|
||||
public IotaFindTransactionsRequest byAddresses(String ... addresses) {
|
||||
this.addresses = addresses;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IotaFindTransactionsRequest byDigests(String [] digests) {
|
||||
public IotaFindTransactionsRequest byDigests(String ... digests) {
|
||||
this.digests = digests;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IotaFindTransactionsRequest byApprovees(String [] approvees) {
|
||||
public IotaFindTransactionsRequest byApprovees(String ... approvees) {
|
||||
this.approvees = approvees;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
package jota.dto.request;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import jota.IotaAPICommands;
|
||||
|
||||
public class IotaGetTransferRequest extends IotaCommandRequest {
|
||||
|
||||
private String seed;
|
||||
private String securityLevel;
|
||||
private Integer securityLevel;
|
||||
|
||||
private IotaGetTransferRequest(final String seed, final String securityLevel) {
|
||||
private IotaGetTransferRequest(final String seed, final Integer securityLevel) {
|
||||
super(IotaAPICommands.GET_TRANSFER);
|
||||
this.seed = seed;
|
||||
this.securityLevel = securityLevel;
|
||||
}
|
||||
|
||||
public static IotaGetTransferRequest createGetTransferRequest(String seed, Integer securityLevel) {
|
||||
return new IotaGetTransferRequest(seed, String.valueOf(securityLevel));
|
||||
return new IotaGetTransferRequest(seed, securityLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package jota.dto.request;
|
||||
|
||||
import jota.IotaAPICommands;
|
||||
|
||||
public class IotaGetTrytesRequest extends IotaCommandRequest {
|
||||
|
||||
private String [] hashes;
|
||||
|
||||
private IotaGetTrytesRequest(final String ... hashes) {
|
||||
super(IotaAPICommands.GET_TRYTES);
|
||||
this.hashes = hashes;
|
||||
}
|
||||
|
||||
public static IotaGetTrytesRequest createGetTrytesRequest(String ... hashes) {
|
||||
return new IotaGetTrytesRequest(hashes);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package jota.dto.response;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
public class GetTransfersResponse extends AbstractResponse {
|
||||
|
||||
private Transfers[] transfers;
|
||||
@@ -26,6 +29,11 @@ public class GetTransfersResponse extends AbstractResponse {
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
public Transfers[] getTransfers() {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package jota.dto.response;
|
||||
|
||||
public class GetTrytesResponse extends AbstractResponse {
|
||||
|
||||
private String [] trites;
|
||||
|
||||
public String[] getTrites() {
|
||||
return trites;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user