From 18a34088584166f37efc0260df9783af3902aba1 Mon Sep 17 00:00:00 2001 From: Matheus Nakaya Date: Fri, 2 Mar 2018 09:34:07 -0300 Subject: [PATCH 1/5] fix(Client): fix a bug in method doRequest() --- build.gradle | 2 +- src/main/java/br/com/moip/Client.java | 10 +++++++++- src/main/java/br/com/moip/resource/Order.java | 7 ++++--- src/test/java/br/com/moip/api/OrderAPITest.java | 2 -- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 74be98b..24b208f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'signing' group = 'br.com.moip' archivesBaseName = "java-sdk" -version = '4.1.0' +version = '4.1.1' description = "Moip v2 SDK" diff --git a/src/main/java/br/com/moip/Client.java b/src/main/java/br/com/moip/Client.java index 651f02e..b4104a5 100644 --- a/src/main/java/br/com/moip/Client.java +++ b/src/main/java/br/com/moip/Client.java @@ -106,7 +106,7 @@ private T doRequest(final RequestProps requestProps) { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", USER_AGENT); conn.setRequestProperty("Content-type", requestProps.contentType.getMimeType()); - conn.setRequestProperty("Accept", requestProps.accept); + if (requestProps.accept != null) conn.setRequestProperty("Accept", requestProps.accept); conn.setRequestMethod(requestProps.method); @@ -230,6 +230,14 @@ private static class RequestProps { public RequestProps() {} + public RequestProps(String method, String path, Object object, Class type, ContentType contentType) { + this.method = method; + this.path = path; + this.object = object; + this.type = type; + this.contentType = contentType; + } + public String getMethod() { return method; } public String getPath() { return path; } diff --git a/src/main/java/br/com/moip/resource/Order.java b/src/main/java/br/com/moip/resource/Order.java index e5e0a89..47e45c6 100644 --- a/src/main/java/br/com/moip/resource/Order.java +++ b/src/main/java/br/com/moip/resource/Order.java @@ -3,6 +3,7 @@ import br.com.moip.resource.links.OrderLinks; import java.util.ArrayList; +import java.util.Date; import java.util.List; public class Order { @@ -11,7 +12,7 @@ public class Order { private String ownId; private OrderStatus status; private String platform; - private String createdAt, updatedAt; + private Date createdAt, updatedAt; private Amount amount; private final List items; private final List
addresses = new ArrayList<>(); @@ -51,9 +52,9 @@ public OrderStatus getStatus() { public String getPlatform() { return platform; } - public String getCreatedAt() { return createdAt; } + public Date getCreatedAt() { return createdAt; } - public String getUpdatedAt() { return updatedAt; } + public Date getUpdatedAt() { return updatedAt; } public Amount getAmount() { return amount; diff --git a/src/test/java/br/com/moip/api/OrderAPITest.java b/src/test/java/br/com/moip/api/OrderAPITest.java index ed584cb..7961204 100644 --- a/src/test/java/br/com/moip/api/OrderAPITest.java +++ b/src/test/java/br/com/moip/api/OrderAPITest.java @@ -74,8 +74,6 @@ public void testCreate() { assertEquals("the_order.001", createdOrder.getOwnId()); assertEquals(OrderStatus.CREATED, createdOrder.getStatus()); assertEquals("V2", createdOrder.getPlatform()); - assertEquals("2018-02-22T15:33:38.493-03", createdOrder.getCreatedAt()); - assertEquals("2018-02-22T15:33:38.493-03", createdOrder.getUpdatedAt()); assertEquals(0, createdOrder.getAmount().getPaid().intValue()); assertEquals(11000, createdOrder.getAmount().getTotal().intValue()); assertEquals(0, createdOrder.getAmount().getFees().intValue()); From f57c32d8a449663b588bca650a2cbfe01e5ce8fc Mon Sep 17 00:00:00 2001 From: Matheus Nakaya Date: Fri, 2 Mar 2018 09:59:30 -0300 Subject: [PATCH 2/5] add docs --- CHANGELOG.md | 11 ++++++++++- README.md | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e5c71f..d03e4f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ -# [](https://github.com/moip/moip-sdk-java/compare/v4.0.0...v4.1.0) (2018-01-06) +# [](https://github.com/moip/moip-sdk-java/compare/v4.1.0...v4.1.1) (2018-03-02) + + +### Bug Fixes + +* **Client**: fix a bug in method `doRequest()` ([]()) + + + +# [](https://github.com/moip/moip-sdk-java/compare/v4.0.0...v4.1.0) (2018-02-27) ### Features diff --git a/README.md b/README.md index 73c809d..f6b7eab 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Adicionar no seu pom.xml: br.com.moip java-sdk - 4.1.0 + 4.1.1 ``` From 1db1b206d2a4f6a2662e56aab9b9fa06ce3927a8 Mon Sep 17 00:00:00 2001 From: Matheus Nakaya Date: Fri, 2 Mar 2018 11:22:48 -0300 Subject: [PATCH 3/5] refactor(Client): remove unnecessary constructor --- src/main/java/br/com/moip/Client.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/br/com/moip/Client.java b/src/main/java/br/com/moip/Client.java index b4104a5..3a03c8f 100644 --- a/src/main/java/br/com/moip/Client.java +++ b/src/main/java/br/com/moip/Client.java @@ -230,14 +230,6 @@ private static class RequestProps { public RequestProps() {} - public RequestProps(String method, String path, Object object, Class type, ContentType contentType) { - this.method = method; - this.path = path; - this.object = object; - this.type = type; - this.contentType = contentType; - } - public String getMethod() { return method; } public String getPath() { return path; } From 7b8375f20747ace9a14dbbfd80afd4be07092a60 Mon Sep 17 00:00:00 2001 From: Matheus Nakaya Date: Fri, 2 Mar 2018 14:05:53 -0300 Subject: [PATCH 4/5] test(order): adds missing tests --- src/test/java/br/com/moip/api/OrderAPITest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/br/com/moip/api/OrderAPITest.java b/src/test/java/br/com/moip/api/OrderAPITest.java index 7961204..239f5d1 100644 --- a/src/test/java/br/com/moip/api/OrderAPITest.java +++ b/src/test/java/br/com/moip/api/OrderAPITest.java @@ -23,6 +23,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; import java.util.GregorianCalendar; import java.util.UUID; @@ -74,6 +75,8 @@ public void testCreate() { assertEquals("the_order.001", createdOrder.getOwnId()); assertEquals(OrderStatus.CREATED, createdOrder.getStatus()); assertEquals("V2", createdOrder.getPlatform()); + assertEquals("2018-02-22", simpleDateFormat.format(createdOrder.getCreatedAt())); + assertEquals("2018-02-22", simpleDateFormat.format(createdOrder.getUpdatedAt())); assertEquals(0, createdOrder.getAmount().getPaid().intValue()); assertEquals(11000, createdOrder.getAmount().getTotal().intValue()); assertEquals(0, createdOrder.getAmount().getFees().intValue()); From 7347c67b2cfba8f65dceb45b86830ad1ba477ab8 Mon Sep 17 00:00:00 2001 From: Matheus Nakaya Date: Fri, 2 Mar 2018 16:01:34 -0300 Subject: [PATCH 5/5] docs: fix CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d03e4f8..ca61339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ - + # [](https://github.com/moip/moip-sdk-java/compare/v4.1.0...v4.1.1) (2018-03-02)