Skip to content

Commit

Permalink
Merge pull request #89 from uphold/support/merchant-destination-trans…
Browse files Browse the repository at this point in the history
…action-model

Add merchant model to transaction destination
  • Loading branch information
ruipenso authored Apr 11, 2017
2 parents 04a3a55 + 91a67a6 commit 0713f1f
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ public void createTransactionShouldReturnTheTransaction() throws Exception {
"\"currency\": \"BTC\"," +
"\"description\": \"[email protected]\"," +
"\"fee\": \"0.00\"," +
"\"merchant\": {" +
"\"city\": \"foo\"," +
"\"country\": \"bar\"," +
"\"name\": \"foobar\"," +
"\"state\": \"fizbiz\"," +
"\"zipCode\": \"fizbuz\"" +
"}," +
"\"rate\": \"1.00\"," +
"\"type\": \"email\"" +
"}," +
Expand Down Expand Up @@ -185,6 +192,11 @@ public Promise<Transaction> call(UpholdRestAdapter adapter) {
Assert.assertEquals(transaction.getDestination().getCurrency(), "BTC");
Assert.assertEquals(transaction.getDestination().getDescription(), "[email protected]");
Assert.assertEquals(transaction.getDestination().getFee(), "0.00");
Assert.assertEquals(transaction.getDestination().getMerchant().getCity(), "foo");
Assert.assertEquals(transaction.getDestination().getMerchant().getCountry(), "bar");
Assert.assertEquals(transaction.getDestination().getMerchant().getName(), "foobar");
Assert.assertEquals(transaction.getDestination().getMerchant().getState(), "fizbiz");
Assert.assertEquals(transaction.getDestination().getMerchant().getZipCode(), "fizbuz");
Assert.assertEquals(transaction.getDestination().getRate(), "1.00");
Assert.assertEquals(transaction.getDestination().getType(), "email");
Assert.assertEquals(transaction.getParams().getCurrency(), "BTC");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ public void getDestinationShouldReturnTheDestination() {
put("destinationCurrency", "bar");
put("destinationDescription", "biz");
put("destinationFee", "foobuz");
put("destinationMerchantCity", "bar");
put("destinationMerchantCountry", "foo");
put("destinationMerchantName", "buz");
put("destinationMerchantState", "fiz");
put("destinationMerchantZipCode", "biz");
put("destinationRate", "buz");
put("destinationType", "fuzbiz");
put("destinationUsername", "fizbuz");
Expand All @@ -545,6 +550,11 @@ public void getDestinationShouldReturnTheDestination() {
Assert.assertEquals(transaction.getDestination().getCurrency(), "bar");
Assert.assertEquals(transaction.getDestination().getDescription(), "biz");
Assert.assertEquals(transaction.getDestination().getFee(), "foobuz");
Assert.assertEquals(transaction.getDestination().getMerchant().getCity(), "bar");
Assert.assertEquals(transaction.getDestination().getMerchant().getCountry(), "foo");
Assert.assertEquals(transaction.getDestination().getMerchant().getName(), "buz");
Assert.assertEquals(transaction.getDestination().getMerchant().getState(), "fiz");
Assert.assertEquals(transaction.getDestination().getMerchant().getZipCode(), "biz");
Assert.assertEquals(transaction.getDestination().getRate(), "buz");
Assert.assertEquals(transaction.getDestination().getType(), "fuzbiz");
Assert.assertEquals(transaction.getDestination().getUsername(), "fizbuz");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.uphold.uphold_android_sdk.model.transaction.Denomination;
import com.uphold.uphold_android_sdk.model.transaction.Destination;
import com.uphold.uphold_android_sdk.model.transaction.Fee;
import com.uphold.uphold_android_sdk.model.transaction.Merchant;
import com.uphold.uphold_android_sdk.model.transaction.Origin;
import com.uphold.uphold_android_sdk.model.transaction.Parameters;
import com.uphold.uphold_android_sdk.model.transaction.Source;
Expand Down Expand Up @@ -146,6 +147,11 @@ public static Transaction loadTransaction(HashMap<String, String> fields) {
put("destinationCurrency", faker.lorem().fixedString(3));
put("destinationDescription", faker.name().name());
put("destinationFee", faker.lorem().fixedString(3));
put("destinationMerchantCity", faker.address().cityPrefix());
put("destinationMerchantCountry", faker.address().country());
put("destinationMerchantName", faker.name().fullName());
put("destinationMerchantState", faker.address().stateAbbr());
put("destinationMerchantZipCode", faker.address().zipCode());
put("destinationRate", faker.lorem().fixedString(3));
put("destinationType", faker.lorem().fixedString(6));
put("destinationUsername", faker.lorem().fixedString(10));
Expand Down Expand Up @@ -196,7 +202,8 @@ public static Transaction loadTransaction(HashMap<String, String> fields) {
}

Denomination denomination = new Denomination(fakerFields.get("denominationAmount"), fakerFields.get("denominationCurrency"), fakerFields.get("denominationPair"), fakerFields.get("denominationRate"));
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"), fakerFields.get("destinationRate"), fakerFields.get("destinationType"), fakerFields.get("destinationUsername"));
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"));
ArrayList<Fee> fees = new ArrayList<Fee>() {{
add(new Fee(fakerFields.get("feeAmount"), fakerFields.get("feeCurrency"), fakerFields.get("feePercentage"), fakerFields.get("feeTarget"), fakerFields.get("feeType")));
}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Destination implements Serializable {
private final String currency;
private final String description;
private final String fee;
private final Merchant merchant;
private final String rate;
private final String type;
private final String username;
Expand All @@ -33,12 +34,13 @@ public class Destination implements Serializable {
* @param currency The currency from the destination of the transaction.
* @param description The description from the destination of the transaction.
* @param fee The fee from the destination of the transaction.
* @param merchant The merchant from the destination of the transaction.
* @param rate The rate from the destination of the transaction.
* @param type The type from the destination of the transaction.
* @param username The username from the destination of the transaction.
*/

public Destination(String AccountId, String cardId, String accountType, String amount, String base, String commission, String currency, String description, String fee, String rate, String type, String username) {
public Destination(String AccountId, String cardId, String accountType, String amount, String base, String commission, String currency, String description, String fee, Merchant merchant, String rate, String type, String username) {
this.AccountId = AccountId;
this.CardId = cardId;
this.accountType = accountType;
Expand All @@ -48,6 +50,7 @@ public Destination(String AccountId, String cardId, String accountType, String a
this.currency = currency;
this.description = description;
this.fee = fee;
this.merchant = merchant;
this.rate = rate;
this.type = type;
this.username = username;
Expand Down Expand Up @@ -143,6 +146,16 @@ public String getFee() {
return fee;
}

/**
* Gets the merchant from the destination of the transaction.
*
* @return the merchant from the destination of the transaction.
*/

public Merchant getMerchant() {
return merchant;
}

/**
* Gets the rate from the destination of the transaction.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.uphold.uphold_android_sdk.model.transaction;

import java.io.Serializable;

/**
* Merchant model.
*/

public class Merchant implements Serializable {

private final String city;
private final String country;
private final String name;
private final String state;
private final String zipCode;

/**
* Constructor.
*
* @param city The city of the merchant.
* @param country The country of the merchant.
* @param name The name of the merchant.
* @param state The state of the merchant.
* @param zipCode The zip code of the merchant.
*/

public Merchant(String city, String country, String name, String state, String zipCode) {
this.city = city;
this.country = country;
this.name = name;
this.state = state;
this.zipCode = zipCode;
}

/**
* Gets the city of the merchant.
*
* @return the city of the merchant.
*/

public String getCity() {
return city;
}

/**
* Gets the country of the merchant.
*
* @return the country of the merchant.
*/

public String getCountry() {
return country;
}

/**
* Gets the name of the merchant.
*
* @return the name of the merchant.
*/

public String getName() {
return name;
}

/**
* Gets the state of the merchant.
*
* @return the state of the merchant.
*/

public String getState() {
return state;
}

/**
* Gets the zip code of the merchant.
*
* @return the zip code of the merchant.
*/

public String getZipCode() {
return zipCode;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.uphold.uphold_android_sdk.model.transaction.Denomination;
import com.uphold.uphold_android_sdk.model.transaction.Destination;
import com.uphold.uphold_android_sdk.model.transaction.Fee;
import com.uphold.uphold_android_sdk.model.transaction.Merchant;
import com.uphold.uphold_android_sdk.model.transaction.Normalized;
import com.uphold.uphold_android_sdk.model.transaction.Origin;
import com.uphold.uphold_android_sdk.model.transaction.Parameters;
Expand All @@ -29,7 +30,8 @@ public class TransactionTest {
@Test
public void shouldBeSerializable() {
Denomination denomination = new Denomination("foo", "bar", "fuz", "buz");
Destination destination = new Destination("fizbiz", "foobar", "biz", "foobiz", "foobuz", "fizbuz", "fizbiz", "foo", "bar", "fiz", "biz", "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");
Fee fee = new Fee("foo", "bar", "fuz", "buz", "biz");
List<Fee> fees = new ArrayList<>();
List<Normalized> normalizeds = new ArrayList<>();
Expand Down Expand Up @@ -61,6 +63,11 @@ public void shouldBeSerializable() {
Assert.assertEquals(transaction.getDestination().getCurrency(), deserializedTransaction.getDestination().getCurrency() );
Assert.assertEquals(transaction.getDestination().getDescription(), deserializedTransaction.getDestination().getDescription());
Assert.assertEquals(transaction.getDestination().getFee(), deserializedTransaction.getDestination().getFee());
Assert.assertEquals(transaction.getDestination().getMerchant().getCity(), deserializedTransaction.getDestination().getMerchant().getCity());
Assert.assertEquals(transaction.getDestination().getMerchant().getCountry(), deserializedTransaction.getDestination().getMerchant().getCountry());
Assert.assertEquals(transaction.getDestination().getMerchant().getName(), deserializedTransaction.getDestination().getMerchant().getName());
Assert.assertEquals(transaction.getDestination().getMerchant().getState(), deserializedTransaction.getDestination().getMerchant().getState());
Assert.assertEquals(transaction.getDestination().getMerchant().getZipCode(), deserializedTransaction.getDestination().getMerchant().getZipCode());
Assert.assertEquals(transaction.getDestination().getRate(), deserializedTransaction.getDestination().getRate());
Assert.assertEquals(transaction.getDestination().getType(), deserializedTransaction.getDestination().getType());
Assert.assertEquals(transaction.getDestination().getUsername(), deserializedTransaction.getDestination().getUsername());
Expand Down

0 comments on commit 0713f1f

Please sign in to comment.