expanded getAccountData

This commit is contained in:
pinpong 2017-11-06 21:21:43 +01:00
parent 836688139f
commit e0dc12681f
5 changed files with 27 additions and 15 deletions

View File

@ -479,7 +479,7 @@ public class IotaAPI extends IotaAPICore {
@SuppressWarnings("unchecked") GetBalancesAndFormatResponse newinputs = getInputs(seed, security, 0, 0, totalValue); @SuppressWarnings("unchecked") GetBalancesAndFormatResponse newinputs = getInputs(seed, security, 0, 0, totalValue);
// If inputs with enough balance // If inputs with enough balance
return addRemainder(seed, security, newinputs.getInput(), bundle, tag, totalValue, remainder, signatureFragments); return addRemainder(seed, security, newinputs.getInputs(), bundle, tag, totalValue, remainder, signatureFragments);
} }
} else { } else {
@ -724,7 +724,7 @@ public class IotaAPI extends IotaAPICore {
GetTransferResponse gtr = getTransfers(seed, security, start, end, inclusionStates); GetTransferResponse gtr = getTransfers(seed, security, start, end, inclusionStates);
GetBalancesAndFormatResponse gbr = getInputs(seed, security, start, end, threshold); GetBalancesAndFormatResponse gbr = getInputs(seed, security, start, end, threshold);
return GetAccountDataResponse.create(gna.getAddresses(), gtr.getTransfers(), gbr.getTotalBalance(), stopWatch.getElapsedTimeMili()); return GetAccountDataResponse.create(gna.getAddresses(), gtr.getTransfers(), gbr.getInputs(), gbr.getTotalBalance(), stopWatch.getElapsedTimeMili());
} }
/** /**

View File

@ -1,6 +1,7 @@
package jota.dto.response; package jota.dto.response;
import jota.model.Bundle; import jota.model.Bundle;
import jota.model.Input;
import java.util.List; import java.util.List;
@ -11,16 +12,18 @@ public class GetAccountDataResponse extends AbstractResponse {
private List<String> addresses; private List<String> addresses;
private Bundle[] transferBundle; private Bundle[] transferBundle;
private List<Input> inputs;
private long balance; private long balance;
/** /**
* Initializes a new instance of the GetAccountDataResponse class. * Initializes a new instance of the GetAccountDataResponse class.
*/ */
public static GetAccountDataResponse create(List<String> addresses, Bundle[] transferBundle, long balance, long duration) { public static GetAccountDataResponse create(List<String> addresses, Bundle[] transferBundle, List<Input> inputs, long balance, long duration) {
GetAccountDataResponse res = new GetAccountDataResponse(); GetAccountDataResponse res = new GetAccountDataResponse();
res.addresses = addresses; res.addresses = addresses;
res.transferBundle = transferBundle; res.transferBundle = transferBundle;
res.inputs = inputs;
res.balance = balance; res.balance = balance;
res.setDuration(duration); res.setDuration(duration);
return res; return res;
@ -44,6 +47,15 @@ public class GetAccountDataResponse extends AbstractResponse {
return transferBundle; return transferBundle;
} }
/**
* Gets the inputs.
*
* @return The inputs.
*/
public List<Input> getInput() {
return inputs;
}
/** /**
* Gets the balance. * Gets the balance.
* *

View File

@ -9,16 +9,16 @@ import java.util.List;
**/ **/
public class GetBalancesAndFormatResponse extends AbstractResponse { public class GetBalancesAndFormatResponse extends AbstractResponse {
private List<Input> input; private List<Input> inputs;
private long totalBalance; private long totalBalance;
/** /**
* Initializes a new instance of the GetBalancesAndFormatResponse class. * Initializes a new instance of the GetBalancesAndFormatResponse class.
*/ */
public static GetBalancesAndFormatResponse create(List<Input> inputs, long totalBalance2, long duration) { public static GetBalancesAndFormatResponse create(List<Input> inputs, long totalBalance, long duration) {
GetBalancesAndFormatResponse res = new GetBalancesAndFormatResponse(); GetBalancesAndFormatResponse res = new GetBalancesAndFormatResponse();
res.setInput(inputs); res.inputs = inputs;
res.setTotalBalance(totalBalance2); res.totalBalance = totalBalance;
res.setDuration(duration); res.setDuration(duration);
return res; return res;
} }
@ -28,8 +28,8 @@ public class GetBalancesAndFormatResponse extends AbstractResponse {
* *
* @return The transactions. * @return The transactions.
*/ */
public List<Input> getInput() { public List<Input> getInputs() {
return input; return inputs;
} }
/** /**
@ -37,8 +37,8 @@ public class GetBalancesAndFormatResponse extends AbstractResponse {
* *
* @param input The input. * @param input The input.
*/ */
public void setInput(List<Input> input) { public void setInputs(List<Input> input) {
this.input = input; this.inputs = inputs;
} }
/** /**

View File

@ -15,6 +15,7 @@ public class GetTransferResponse extends AbstractResponse {
public static GetTransferResponse create(Bundle[] transferBundle, long duration) { public static GetTransferResponse create(Bundle[] transferBundle, long duration) {
GetTransferResponse res = new GetTransferResponse(); GetTransferResponse res = new GetTransferResponse();
res.transferBundle = transferBundle; res.transferBundle = transferBundle;
res.setDuration(duration);
return res; return res;
} }

View File

@ -117,8 +117,7 @@ public class IotaAPITest {
System.out.println(res); System.out.println(res);
assertThat(res, IsNull.notNullValue()); assertThat(res, IsNull.notNullValue());
assertThat(res.getTotalBalance(), IsNull.notNullValue()); assertThat(res.getTotalBalance(), IsNull.notNullValue());
assertThat(res.getInput(), IsNull.notNullValue()); assertThat(res.getInputs(), IsNull.notNullValue());
} }
@Test @Test
@ -146,7 +145,7 @@ public class IotaAPITest {
GetBalancesAndFormatResponse rsp = iotaClient.getInputs(TEST_SEED1, 2, 0, 0, 100); GetBalancesAndFormatResponse rsp = iotaClient.getInputs(TEST_SEED1, 2, 0, 0, 100);
for (Input input : rsp.getInput()) { for (Input input : rsp.getInputs()) {
inputlist.add(input); inputlist.add(input);
} }
transfers.add(new jota.model.Transfer(TEST_ADDRESS_WITHOUT_CHECKSUM_SECURITY_LEVEL_2, 0, TEST_MESSAGE, TEST_TAG)); transfers.add(new jota.model.Transfer(TEST_ADDRESS_WITHOUT_CHECKSUM_SECURITY_LEVEL_2, 0, TEST_MESSAGE, TEST_TAG));
@ -256,7 +255,7 @@ public class IotaAPITest {
GetBalancesAndFormatResponse rsp = iotaClient.getInputs(TEST_SEED1, 2, 0, 0, 100); GetBalancesAndFormatResponse rsp = iotaClient.getInputs(TEST_SEED1, 2, 0, 0, 100);
for (Input input : rsp.getInput()) { for (Input input : rsp.getInputs()) {
inputlist.add(input); inputlist.add(input);
} }