diff --git a/pom.xml b/pom.xml
index efe9d08f..2df80e4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
com.mercadopago
dx-java
- 1.0.36
+ 1.1.0
jar
Mercadopago SDK
diff --git a/src/main/java/com/mercadopago/core/MPBase.java b/src/main/java/com/mercadopago/core/MPBase.java
index 6eb9a5d9..9aa72d62 100644
--- a/src/main/java/com/mercadopago/core/MPBase.java
+++ b/src/main/java/com/mercadopago/core/MPBase.java
@@ -533,7 +533,7 @@ private static String parsePath(String path, HashMap entry : mapParams.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
diff --git a/src/main/java/com/mercadopago/resources/Preference.java b/src/main/java/com/mercadopago/resources/Preference.java
index 37cb7c63..60bb1e2e 100644
--- a/src/main/java/com/mercadopago/resources/Preference.java
+++ b/src/main/java/com/mercadopago/resources/Preference.java
@@ -21,8 +21,10 @@
*/
public class Preference extends MPBase {
- @NotNull private ArrayList- items = null;
- @NotNull private Payer payer = null;
+ @NotNull
+ private ArrayList
- items = null;
+ @NotNull
+ private Payer payer = null;
private PaymentMethods paymentMethods = null;
private Shipments shipments = null;
private BackUrls backUrls = null;
@@ -60,6 +62,7 @@ public enum ProcessingMode {
}
private ArrayList processingModes = null;
private Boolean binaryMode = null;
+ private ArrayList taxes = null;
public ArrayList
- getItems() {
return items;
@@ -266,6 +269,22 @@ public Preference setBinaryMode(Boolean binaryMode) {
return this;
}
+ public ArrayList getTaxes() { return this.taxes; }
+
+ public Preference setTaxes(ArrayList taxes) {
+ this.taxes = taxes;
+ return this;
+ }
+
+ public Preference appendTax(Tax tax) {
+ if (this.taxes == null) {
+ this.taxes = new ArrayList<>();
+ }
+ this.taxes.add(tax);
+ return this;
+ }
+
+
public static Preference findById(String id) throws MPException {
return findById(id, WITHOUT_CACHE);
}
diff --git a/src/main/java/com/mercadopago/resources/datastructures/preference/Tax.java b/src/main/java/com/mercadopago/resources/datastructures/preference/Tax.java
new file mode 100644
index 00000000..07e905dd
--- /dev/null
+++ b/src/main/java/com/mercadopago/resources/datastructures/preference/Tax.java
@@ -0,0 +1,36 @@
+package com.mercadopago.resources.datastructures.preference;
+
+/**
+ * Mercado Pago MercadoPago
+ * Preference Tax class
+ *
+ * Created by Danilo Elias on 26/08/2019.
+ */
+public class Tax {
+
+ private TaxType type = null;
+ public enum TaxType {
+ IVA,
+ INC
+ }
+ private Float value = null;
+
+ public TaxType getType() {
+ return type;
+ }
+
+ public Float getValue() {
+ return value;
+ }
+
+ public Tax setType(TaxType type) {
+ this.type = type;
+ return this;
+ }
+
+ public Tax setValue(Float value) {
+ this.value = value;
+ return this;
+ }
+
+}
diff --git a/src/test/java/mercadopago/resources/PreferenceTest.java b/src/test/java/mercadopago/resources/PreferenceTest.java
index 27d8ed50..571948b1 100644
--- a/src/test/java/mercadopago/resources/PreferenceTest.java
+++ b/src/test/java/mercadopago/resources/PreferenceTest.java
@@ -13,7 +13,6 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Date;
import java.util.UUID;
@@ -100,6 +99,10 @@ public void preferenceGettersSettersTest() throws MPException {
DifferentialPricing differentialPricing = new DifferentialPricing();
differentialPricing.setId(0);
+ Tax tax = new Tax();
+ tax.setType(Tax.TaxType.IVA);
+ tax.setValue(500f);
+
Preference preference = new Preference();
preference.appendItem(item);
preference.setPayer(payer);
@@ -116,6 +119,7 @@ public void preferenceGettersSettersTest() throws MPException {
preference.setMarketplace("Marketplace");
preference.setMarketplaceFee(.01f);
preference.setDifferentialPricing(differentialPricing);
+ preference.appendTax(tax);
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
@@ -186,6 +190,10 @@ public void preferenceGettersSettersTest() throws MPException {
JsonObject jsonDifferentialPricing = (JsonObject) jsonPreference.get("differential_pricing");
assertEquals(differentialPricing.getId().intValue(), jsonDifferentialPricing.get("id").getAsInt());
+ JsonObject jsonTax = (JsonObject) jsonPreference.get("taxes").getAsJsonArray().get(0);
+ assertEquals(tax.getType().toString(), jsonTax.get("type").getAsString());
+ assertEquals(tax.getValue(), jsonTax.get("value").getAsFloat(), 0.0f);
+
assertEquals(preference.getNotificationUrl(), jsonPreference.get("notification_url").getAsString());
assertNull(jsonPreference.get("id"));
assertNull(jsonPreference.get("init_point"));