diff --git a/CHANGELOG.md b/CHANGELOG.md
index 039c4f0..cd290a0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,16 @@
+
+# [](https://github.com/moip/moip-sdk-java/compare/v3.3.0...v3.4.0) (2017-11-08)
+
+
+### Features
+
+* **Order:** adding OrderStatus to Order object ([71a42d8](https://github.com/moip/moip-sdk-java/commit/71a42d8))
+* **CreditCardRequest:** Add id property, getter and setter ([bb59c12](https://github.com/moip/moip-sdk-java/commit/bb59c12))
+* **Amount:** Added fees, refunds, liquid, currency properties and getters for them ([e90fce0](https://github.com/moip/moip-sdk-java/commit/e90fce0))
+* **BankAccount** Add method to delete a bank account. ([113ff51](https://github.com/moip/moip-sdk-java/commit/113ff51))
+* **BankAccount** Add method to update a bank account. ([b99fd12](https://github.com/moip/moip-sdk-java/commit/b99fd12))
+
+
# [](https://github.com/moip/moip-sdk-java/compare/v3.2.0...v3.3.0) (2017-10-10)
diff --git a/README.md b/README.md
index 9e22a01..6fa4584 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,12 @@
- [Criação](#criação-6)
- [Consulta](#consulta-7)
- [Verifica se usuário já possui Conta Moip](#verifica-se-usuário-já-possui-conta-moip)
+ - [Contas Bancárias](#contas-bancárias)
+ - [Criação](#criação-7)
+ - [Consulta](#consulta-8)
+ - [Exclusão](#exclusão-1)
+ - [Atualização](#atualização)
+ - [Listagem](#listagem-1)
- [Custódia](#custódia)
- [Pagamento com custódia](#pagamento-com-custódia)
- [Liberação de custódia](#liberação-de-custódia)
@@ -78,7 +84,7 @@ Adicionar no seu pom.xml:
br.com.moip
java-sdk
- 3.3.0
+ 3.4.0
```
@@ -630,6 +636,56 @@ System.out.println(account);
api.account().checkAccountExists("123.456.798-91");
```
+## Contas Bancárias
+### Criação
+```java
+BankAccount createdBankAccount = api.create("MPA-E0BAC6D15696",
+ new BankAccountRequest()
+ .bankNumber("237")
+ .agencyNumber("12346")
+ .agencyCheckNumber("0")
+ .accountNumber("12345679")
+ .accountCheckNumber("7")
+ .checking()
+ .holder(new HolderRequest()
+ .fullname("Vagner")
+ .taxDocument(TaxDocumentRequest.cpf("22222222222"))
+ )
+);
+```
+### Consulta
+```java
+BankAccount createdBankAccount = api.get("BKA-E0BAC6D15696");
+```
+### Exclusão
+```java
+api.delete("BKA-E0BAC6D15696");
+```
+### Atualização
+```java
+BankAccount createdBankAccount = api.update("BKA-E0BAC6D15696",
+ new BankAccountRequest()
+ .bankNumber("237")
+ .agencyNumber("12345")
+ .agencyCheckNumber("8")
+ .accountNumber("12345678")
+ .accountCheckNumber("8")
+ .checking()
+ .holder(
+ new HolderRequest()
+ .fullname("Demo Moip")
+ .taxDocument(
+ TaxDocumentRequest.cpf("62213453322")
+ )
+ )
+);
+```
+
+### Listagem
+```java
+List createdBankAccounts = api.getList("MPA-E0BAC6D15696");
+```
+
## Custódia
### Pagamento com custódia
```java
diff --git a/build.gradle b/build.gradle
index 0f80920..d947603 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,7 +4,7 @@ apply plugin: 'signing'
group = 'br.com.moip'
archivesBaseName = "java-sdk"
-version = '3.3.0'
+version = '3.4.0'
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 1fefbff..7bf32cb 100644
--- a/src/main/java/br/com/moip/Client.java
+++ b/src/main/java/br/com/moip/Client.java
@@ -73,6 +73,10 @@ public T post(final String path, final Object object, final Class type, C
return doRequest("POST", path, object, type, contentType);
}
+ public T put(final String path, final Object object, final Class type) {
+ return doRequest("PUT", path, object, type, ContentType.APPLICATION_JSON);
+ }
+
public T get(String path, Class type) {
return doRequest("GET", path, null, type, ContentType.APPLICATION_JSON);
}
diff --git a/src/main/java/br/com/moip/api/BankAccountsAPI.java b/src/main/java/br/com/moip/api/BankAccountsAPI.java
index e7a9227..52b2060 100644
--- a/src/main/java/br/com/moip/api/BankAccountsAPI.java
+++ b/src/main/java/br/com/moip/api/BankAccountsAPI.java
@@ -1,13 +1,13 @@
package br.com.moip.api;
+import java.util.Arrays;
+import java.util.List;
+
import br.com.moip.Client;
+import br.com.moip.exception.ValidationException;
import br.com.moip.request.BankAccountRequest;
import br.com.moip.resource.BankAccount;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
public class BankAccountsAPI {
private final Client client;
@@ -29,5 +29,23 @@ public List getList(final String moipAccount) {
return Arrays.asList(bankAccounts);
}
+
+ public BankAccount update(final String id, final BankAccountRequest bankAccountRequest) {
+ return client.put(String.format("/v2/bankaccounts/%s", id), bankAccountRequest, BankAccount.class);
+ }
+
+ public Boolean delete(final String id) {
+ try {
+ client.delete(String.format("/v2/bankaccounts/%s", id), BankAccount.class);
+
+ return true;
+ } catch (ValidationException e) {
+ if (e.getResponseCode() != 404) {
+ throw new ValidationException(e.getResponseCode(), e.getResponseStatus(), e.getError());
+ }
+ }
+ return false;
+ }
+
}
diff --git a/src/main/java/br/com/moip/request/CreditCardRequest.java b/src/main/java/br/com/moip/request/CreditCardRequest.java
index cd5a9f2..bb62f10 100644
--- a/src/main/java/br/com/moip/request/CreditCardRequest.java
+++ b/src/main/java/br/com/moip/request/CreditCardRequest.java
@@ -2,6 +2,7 @@
public class CreditCardRequest {
+ private String id;
private String hash;
private String number;
private String expirationMonth;
@@ -10,6 +11,16 @@ public class CreditCardRequest {
private Boolean store;
private HolderRequest holder;
+ public String getId() {
+ return id;
+ }
+
+ public CreditCardRequest id(final String id) {
+ this.id = id;
+
+ return this;
+ }
+
public String getHash() {
return hash;
}
diff --git a/src/main/java/br/com/moip/resource/Amount.java b/src/main/java/br/com/moip/resource/Amount.java
index f006ece..5a3bcb1 100644
--- a/src/main/java/br/com/moip/resource/Amount.java
+++ b/src/main/java/br/com/moip/resource/Amount.java
@@ -3,15 +3,40 @@
public class Amount {
private Integer total;
+ private Integer fees;
+ private Integer refunds;
+ private Integer liquid;
+ private String currency;
public Integer getTotal() {
return total;
}
+ public Integer getFees() {
+ return fees;
+ }
+
+ public Integer getRefunds() {
+ return refunds;
+ }
+
+ public Integer getLiquid() {
+ return liquid;
+ }
+
+ public String getCurrency() {
+ return currency;
+ }
+
@Override
public String toString() {
return new StringBuilder("Amount{")
.append("total=").append(total)
+ .append(", fees=").append(fees)
+ .append(", refunds=").append(refunds)
+ .append(", liquid=").append(liquid)
+ .append(", currency='").append(currency)
+ .append('\'')
.append('}').toString();
}
}
diff --git a/src/main/java/br/com/moip/resource/Order.java b/src/main/java/br/com/moip/resource/Order.java
index 73f88ce..cf605af 100644
--- a/src/main/java/br/com/moip/resource/Order.java
+++ b/src/main/java/br/com/moip/resource/Order.java
@@ -9,6 +9,7 @@ public class Order {
private String id;
private Amount amount;
+ private OrderStatus status;
private String ownId;
private final List- items;
private Customer customer;
@@ -48,6 +49,14 @@ public OrderLinks getLinks() {
return _links;
}
+ public OrderStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(OrderStatus status) {
+ this.status = status;
+ }
+
public Order(){
items = new ArrayList
- ();
}
diff --git a/src/test/java/br/com/moip/api/BankAccountAPITest.java b/src/test/java/br/com/moip/api/BankAccountAPITest.java
index 74cc5ce..3fd962b 100644
--- a/src/test/java/br/com/moip/api/BankAccountAPITest.java
+++ b/src/test/java/br/com/moip/api/BankAccountAPITest.java
@@ -37,18 +37,18 @@ public void setUp() {
public void shouldCreateBankAccount() {
BankAccount createdBankAccount = api.create("MPA-E0BAC6D15696",
- new BankAccountRequest()
- .bankNumber("237")
- .agencyNumber("12346")
- .agencyCheckNumber("0")
- .accountNumber("12345679")
- .accountCheckNumber("7")
- .checking()
- .holder(new HolderRequest()
- .fullname("Vagner")
- .taxDocument(TaxDocumentRequest.cpf("22222222222")
- )
- )
+ new BankAccountRequest()
+ .bankNumber("237")
+ .agencyNumber("12346")
+ .agencyCheckNumber("0")
+ .accountNumber("12345679")
+ .accountCheckNumber("7")
+ .checking()
+ .holder(new HolderRequest()
+ .fullname("Vagner")
+ .taxDocument(TaxDocumentRequest.cpf("22222222222")
+ )
+ )
);
assertTrue(createdBankAccount.getId().startsWith("BKA-"));
}
@@ -58,7 +58,6 @@ public void shouldCreateBankAccount() {
public void shouldGetOneAccount() {
BankAccount createdBankAccount = api.get("BKA-P9O93Z6PKUTI");
assertEquals("BKA-P9O93Z6PKUTI", createdBankAccount.getId());
-
}
@Play("bankaccounts/getlist")
@@ -72,4 +71,31 @@ public void shouldGetAccountList() {
assertEquals("BKA-WX44D0AEV2NH", createdBankAccounts.get(3).getId());
}
+ @Play("bankaccounts/update")
+ @Test
+ public void shouldUpdateBankAccount() {
+ BankAccount createdBankAccount = api.update("BKA-E0BAC6D15696",
+ new BankAccountRequest()
+ .bankNumber("237")
+ .agencyNumber("12345")
+ .agencyCheckNumber("8")
+ .accountNumber("12345678")
+ .accountCheckNumber("8")
+ .checking()
+ .holder(
+ new HolderRequest()
+ .fullname("Demo Moip")
+ .taxDocument(
+ TaxDocumentRequest.cpf("62213453322")
+ )
+ )
+ );
+ assertTrue(createdBankAccount.getId().startsWith("BKA-"));
+ }
+
+ @Play("bankaccounts/delete")
+ @Test
+ public void shouldDeleteBankAccount() {
+ assertTrue(api.delete("BKA-E0BAC6D15696"));
+ }
}
diff --git a/src/test/java/br/com/moip/api/OrderAPITest.java b/src/test/java/br/com/moip/api/OrderAPITest.java
index 8d532d9..88d53b0 100644
--- a/src/test/java/br/com/moip/api/OrderAPITest.java
+++ b/src/test/java/br/com/moip/api/OrderAPITest.java
@@ -11,6 +11,7 @@
import br.com.moip.request.CheckoutPreferencesRequest;
import br.com.moip.request.InstallmentRequest;
import br.com.moip.resource.Order;
+import br.com.moip.resource.OrderStatus;
import br.com.moip.response.OrderListResponse;
import com.rodrigosaito.mockwebserver.player.Play;
import com.rodrigosaito.mockwebserver.player.Player;
@@ -48,6 +49,7 @@ public void testGet() {
Order order = api.get("ORD-HCOWQ2QJKTAT");
assertEquals("ORD-HCOWQ2QJKTAT", order.getId());
+ assertEquals(OrderStatus.CREATED, order.getStatus());
}
@Play("orders/create")
diff --git a/src/test/resources/plays/bankaccounts/delete.yaml b/src/test/resources/plays/bankaccounts/delete.yaml
new file mode 100644
index 0000000..e5ba239
--- /dev/null
+++ b/src/test/resources/plays/bankaccounts/delete.yaml
@@ -0,0 +1,13 @@
+!play
+interactions:
+-
+ request:
+ uri: /v2/bankaccounts/BKA-E0BAC6D15696
+ headers:
+ Authorization: Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg==
+ method: DELETE
+ response:
+ status: 200
+ headers:
+ "Content-Type": application/json
+ body: |
diff --git a/src/test/resources/plays/bankaccounts/update.yaml b/src/test/resources/plays/bankaccounts/update.yaml
new file mode 100644
index 0000000..8b68d45
--- /dev/null
+++ b/src/test/resources/plays/bankaccounts/update.yaml
@@ -0,0 +1,15 @@
+!play
+interactions:
+-
+ request:
+ uri: /v2/bankaccounts/BKA-E0BAC6D15696
+ headers:
+ "Content-Type": application/json
+ Authorization: Basic MDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMTAxMDE6QUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQkFCQUJBQg==
+ method: PUT
+ response:
+ status: 201
+ headers:
+ "Content-Type": application/json
+ body: |
+ { "id": "BKA-E0BAC6D15696","agencyNumber": 12345,"holder": {"taxDocument": {"number": "622.134.533-22","type": "CPF"},"fullname": "Demo Moip"},"accountNumber": 12345678,"status": "NOT_VERIFIED","createdAt": "2015-10-29T15:50:27.746-02:00","accountCheckNumber": "8","_links": {"self": {"href": "https://sandbox.moip.com.br/v2/accounts/MPA-8307EF11B83E/bankaccounts"}},"bankName": "BANCO BRADESCO S.A.","type": "CHECKING","agencyCheckNumber": "8","bankNumber": "237"}
\ No newline at end of file