diff --git a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java index df66e90..09f2112 100644 --- a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java +++ b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/CardTest.java @@ -89,6 +89,13 @@ public void createTransactionShouldReturnTheTransaction() throws Exception { "\"currency\": \"BTC\"," + "\"description\": \"Foo Bar\"," + "\"fee\": \"0.00\"," + + "\"merchant\": {" + + "\"city\": \"foo\"," + + "\"country\": \"biz\"," + + "\"name\": \"foobiz\"," + + "\"state\": \"fuzbiz\"," + + "\"zipCode\": \"fizbaz\"" + + "}," + "\"rate\": \"1.00\"," + "\"type\": \"card\"," + "\"username\": \"foobar\"" + @@ -181,6 +188,11 @@ public Promise call(UpholdRestAdapter adapter) { Assert.assertEquals(transaction.getOrigin().getCurrency(), "BTC"); Assert.assertEquals(transaction.getOrigin().getDescription(), "Foo Bar"); Assert.assertEquals(transaction.getOrigin().getFee(), "0.00"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getCity(), "foo"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getCountry(), "biz"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getName(), "foobiz"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getState(), "fuzbiz"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getZipCode(), "fizbaz"); Assert.assertEquals(transaction.getOrigin().getRate(), "1.00"); Assert.assertEquals(transaction.getOrigin().getType(), "card"); Assert.assertEquals(transaction.getOrigin().getUsername(), "foobar"); diff --git a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/TransactionTest.java b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/TransactionTest.java index 1bcbab0..543f9dc 100644 --- a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/TransactionTest.java +++ b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/integration/model/TransactionTest.java @@ -596,6 +596,11 @@ public void getOriginShouldReturnTheOrigin() { put("originCurrency", "bar"); put("originDescription", "biz"); put("originFee", "foobuz"); + put("originMerchantCity", "bar"); + put("originMerchantCountry", "foo"); + put("originMerchantName", "buz"); + put("originMerchantState", "fiz"); + put("originMerchantZipCode", "biz"); put("originRate", "buz"); put("originSourcesAmount", "fuzbiz,fizbuz"); put("originSourcesId", "foo,bar"); @@ -610,6 +615,11 @@ public void getOriginShouldReturnTheOrigin() { Assert.assertEquals(transaction.getOrigin().getCurrency(), "bar"); Assert.assertEquals(transaction.getOrigin().getDescription(), "biz"); Assert.assertEquals(transaction.getOrigin().getFee(), "foobuz"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getCity(), "bar"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getCountry(), "foo"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getName(), "buz"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getState(), "fiz"); + Assert.assertEquals(transaction.getOrigin().getMerchant().getZipCode(), "biz"); Assert.assertEquals(transaction.getOrigin().getRate(), "buz"); Assert.assertEquals(transaction.getOrigin().getSources().size(), 2); Assert.assertEquals(transaction.getOrigin().getSources().get(0).getAmount(), "fuzbiz"); diff --git a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java index dbe2c21..f170ba6 100644 --- a/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java +++ b/src/app/src/androidTest/java/com/uphold/uphold_android_sdk/test/util/Fixtures.java @@ -193,6 +193,11 @@ public static Transaction loadTransaction(HashMap fields) { put("originCurrency", faker.lorem().fixedString(3)); put("originDescription", faker.name().fullName()); put("originFee", faker.numerify("123456789")); + put("originMerchantCity", faker.address().cityPrefix()); + put("originMerchantCountry", faker.address().country()); + put("originMerchantName", faker.name().fullName()); + put("originMerchantState", faker.address().stateAbbr()); + put("originMerchantZipCode", faker.address().zipCode()); put("originRate", faker.numerify("123456789")); put("originSourcesAmount", String.format("%s,%s,%s", faker.numerify("123456789"), faker.numerify("123456789"), faker.numerify("123456789"))); put("originSourcesId", String.format("%s,%s,%s", faker.lorem().fixedString(24), faker.lorem().fixedString(24), faker.lorem().fixedString(24))); @@ -221,8 +226,8 @@ public static Transaction loadTransaction(HashMap fields) { } Denomination denomination = new Denomination(fakerFields.get("denominationAmount"), fakerFields.get("denominationCurrency"), fakerFields.get("denominationPair"), fakerFields.get("denominationRate")); - Merchant merchant = new Merchant(fakerFields.get("destinationMerchantCity"), fakerFields.get("destinationMerchantCountry"), fakerFields.get("destinationMerchantName"), fakerFields.get("destinationMerchantState"), fakerFields.get("destinationMerchantZipCode")); - Destination destination = new Destination(fakerFields.get("destinationAccountId"), fakerFields.get("destinationCardId"), fakerFields.get("destinationAccountType"), fakerFields.get("destinationAmount"), fakerFields.get("destinationBase"), fakerFields.get("destinationCommission"), fakerFields.get("destinationCurrency"), fakerFields.get("destinationDescription"), fakerFields.get("destinationFee"), merchant,fakerFields.get("destinationRate"), fakerFields.get("destinationType"), fakerFields.get("destinationUsername")); + Merchant destinationMerchant = new Merchant(fakerFields.get("destinationMerchantCity"), fakerFields.get("destinationMerchantCountry"), fakerFields.get("destinationMerchantName"), fakerFields.get("destinationMerchantState"), fakerFields.get("destinationMerchantZipCode")); + Destination destination = new Destination(fakerFields.get("destinationAccountId"), fakerFields.get("destinationCardId"), fakerFields.get("destinationAccountType"), fakerFields.get("destinationAmount"), fakerFields.get("destinationBase"), fakerFields.get("destinationCommission"), fakerFields.get("destinationCurrency"), fakerFields.get("destinationDescription"), fakerFields.get("destinationFee"), destinationMerchant,fakerFields.get("destinationRate"), fakerFields.get("destinationType"), fakerFields.get("destinationUsername")); ArrayList fees = new ArrayList() {{ add(new Fee(fakerFields.get("feeAmount"), fakerFields.get("feeCurrency"), fakerFields.get("feePercentage"), fakerFields.get("feeTarget"), fakerFields.get("feeType"))); }}; @@ -237,7 +242,8 @@ public static Transaction loadTransaction(HashMap fields) { ArrayList normalized = new ArrayList() {{ add(new com.uphold.uphold_android_sdk.model.transaction.Normalized(fakerFields.get("normalizedAmount"), fakerFields.get("normalizedCommission"), fakerFields.get("normalizedCurrency"), fakerFields.get("normalizedFee"), fakerFields.get("normalizedRate"))); }}; - Origin origin = new Origin(fakerFields.get("originAccountId"), fakerFields.get("originCardId"), fakerFields.get("originAccountType"), fakerFields.get("originAmount"), fakerFields.get("originBase"), fakerFields.get("originCommission"), fakerFields.get("originCurrency"), fakerFields.get("originDescription"), fakerFields.get("originFee"), fakerFields.get("originRate"), sources, fakerFields.get("originType"), fakerFields.get("originUsername")); + Merchant originMerchant = new Merchant(fakerFields.get("originMerchantCity"), fakerFields.get("originMerchantCountry"), fakerFields.get("originMerchantName"), fakerFields.get("originMerchantState"), fakerFields.get("originMerchantZipCode")); + Origin origin = new Origin(fakerFields.get("originAccountId"), fakerFields.get("originCardId"), fakerFields.get("originAccountType"), fakerFields.get("originAmount"), fakerFields.get("originBase"), fakerFields.get("originCommission"), fakerFields.get("originCurrency"), fakerFields.get("originDescription"), fakerFields.get("originFee"), originMerchant, fakerFields.get("originRate"), sources, fakerFields.get("originType"), fakerFields.get("originUsername")); Parameters parameters = new Parameters(fakerFields.get("parametersCurrency"), fakerFields.get("parametersMargin"), fakerFields.get("parametersPair"), fakerFields.get("parametersProgress"), fakerFields.get("parametersRate"), fakerFields.get("parametersRefunds"), Integer.parseInt(fakerFields.get("parametersTtl")), fakerFields.get("parametersTxid"), fakerFields.get("parametersType")); return new Transaction(fakerFields.get("transactionId"), fakerFields.get("transactionCreatedAt"), denomination, destination, fees, fakerFields.get("transactionMessage"), fakerFields.get("transactionNetwork"), normalized, origin, parameters, fakerFields.get("transactionRefundedById"), fakerFields.get("transactionStatus"), fakerFields.get("transactionType")); diff --git a/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java b/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java index 58c348f..c465a26 100644 --- a/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java +++ b/src/app/src/main/java/com/uphold/uphold_android_sdk/model/transaction/Origin.java @@ -18,6 +18,7 @@ public class Origin implements Serializable { private final String currency; private final String description; private final String fee; + private final Merchant merchant; private final String rate; private final List sources; private final String type; @@ -35,13 +36,14 @@ public class Origin implements Serializable { * @param currency The currency from the origin of the transaction. * @param description The description from the origin of the transaction. * @param fee The fee from the origin of the transaction. + * @param merchant The merchant from the origin of the transaction. * @param rate The rate from the origin of the transaction. * @param sources The sources from the origin of the transaction. * @param type The type from the origin of the transaction. * @param username The username from the origin of the transaction. */ - public Origin(String AccountId, String cardId, String accountType, String amount, String base, String commission, String currency, String description, String fee, String rate, List sources, String type, String username) { + public Origin(String AccountId, String cardId, String accountType, String amount, String base, String commission, String currency, String description, String fee, Merchant merchant, String rate, List sources, String type, String username) { this.AccountId = AccountId; this.CardId = cardId; this.accountType = accountType; @@ -51,6 +53,7 @@ public Origin(String AccountId, String cardId, String accountType, String amount this.currency = currency; this.description = description; this.fee = fee; + this.merchant = merchant; this.rate = rate; this.sources = sources; this.type = type; @@ -147,6 +150,16 @@ public String getFee() { return fee; } + /** + * Gets the merchant from the origin of the transaction. + * + * @return the merchant from the origin of the transaction. + */ + + public Merchant getMerchant() { + return merchant; + } + /** * Gets the rate from the origin of the transaction. * diff --git a/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java b/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java index d0dcd7e..48695c1 100644 --- a/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java +++ b/src/app/src/test/java/com/uphold/uphold_android_sdk/test/unit/model/TransactionTest.java @@ -30,13 +30,14 @@ public class TransactionTest { @Test public void shouldBeSerializable() { Denomination denomination = new Denomination("foo", "bar", "fuz", "buz"); - Merchant merchant = new Merchant("foo", "bar", "biz", "buz", "foobar"); - Destination destination = new Destination("fizbiz", "foobar", "biz", "foobiz", "foobuz", "fizbuz", "fizbiz", "foo", "bar", merchant, "fiz", "biz", "buz"); + Merchant destinationMerchant = new Merchant("foo", "bar", "biz", "buz", "foobar"); + Destination destination = new Destination("fizbiz", "foobar", "biz", "foobiz", "foobuz", "fizbuz", "fizbiz", "foo", "bar", destinationMerchant, "fiz", "biz", "buz"); Fee fee = new Fee("foo", "bar", "fuz", "buz", "biz"); List fees = new ArrayList<>(); List normalizeds = new ArrayList<>(); List sources = new ArrayList<>(); - Origin origin = new Origin("biz", "foo", "fiz", "bar", "foobar", "foobiz", "fiz", "biz", "fuzbuz", "fuz", sources, "buz", "FOOBAR"); + Merchant originMerchant = new Merchant("fuz", "biz", "boz", "baz", "foobiz"); + Origin origin = new Origin("biz", "foo", "fiz", "bar", "foobar", "foobiz", "fiz", "biz", "fuzbuz", originMerchant, "fuz", sources, "buz", "FOOBAR"); Parameters parameters = new Parameters("foobar", "foobiz", "foobuz", "fizbiz", "fuz", "fiz", 1, "foo", "bar"); Normalized normalized = new Normalized("foo", "bar", "fiz", "biz", "fixbiz"); Source source = new Source("FUZBUZ", "FIZBIZ"); @@ -94,6 +95,11 @@ public void shouldBeSerializable() { Assert.assertEquals(transaction.getOrigin().getCurrency(), deserializedTransaction.getOrigin().getCurrency()); Assert.assertEquals(transaction.getOrigin().getDescription(), deserializedTransaction.getOrigin().getDescription()); Assert.assertEquals(transaction.getOrigin().getFee(), deserializedTransaction.getOrigin().getFee()); + Assert.assertEquals(transaction.getOrigin().getMerchant().getCity(), deserializedTransaction.getOrigin().getMerchant().getCity()); + Assert.assertEquals(transaction.getOrigin().getMerchant().getCountry(), deserializedTransaction.getOrigin().getMerchant().getCountry()); + Assert.assertEquals(transaction.getOrigin().getMerchant().getName(), deserializedTransaction.getOrigin().getMerchant().getName()); + Assert.assertEquals(transaction.getOrigin().getMerchant().getState(), deserializedTransaction.getOrigin().getMerchant().getState()); + Assert.assertEquals(transaction.getOrigin().getMerchant().getZipCode(), deserializedTransaction.getOrigin().getMerchant().getZipCode()); Assert.assertEquals(transaction.getOrigin().getRate(), deserializedTransaction.getOrigin().getRate()); Assert.assertEquals(transaction.getOrigin().getSources().size(), deserializedTransaction.getOrigin().getSources().size()); Assert.assertEquals(transaction.getOrigin().getSources().get(0).getAmount(), deserializedTransaction.getOrigin().getSources().get(0).getAmount());