diff --git a/src/main/java/br/com/moip/request/TransferRequest.java b/src/main/java/br/com/moip/request/TransferRequest.java index 447d6e8..eb36539 100644 --- a/src/main/java/br/com/moip/request/TransferRequest.java +++ b/src/main/java/br/com/moip/request/TransferRequest.java @@ -3,6 +3,7 @@ public class TransferRequest { private Integer amount; + private String description; private TransferInstrumentRequest transferInstrument; public TransferRequest amount(Integer amount){ @@ -11,8 +12,18 @@ public TransferRequest amount(Integer amount){ return this; } + public TransferRequest description(String description){ + this.description = description; + + return this; + } + public Integer getAmount() { return amount; } + public String getDescription() { + return description; + } + public TransferRequest transferInstrument(TransferInstrumentRequest transferInstrument){ this.transferInstrument = transferInstrument; diff --git a/src/test/java/br/com/moip/request/TransferRequestTest.java b/src/test/java/br/com/moip/request/TransferRequestTest.java index 6bf88ce..ca004aa 100644 --- a/src/test/java/br/com/moip/request/TransferRequestTest.java +++ b/src/test/java/br/com/moip/request/TransferRequestTest.java @@ -32,4 +32,30 @@ public void testCreateTransfer() throws JSONException { JSONAssert.assertEquals(expectedJSON.toString(), json, true); } + + @Test + public void testCreateTransferWithDescription() throws JSONException { + TransferRequest transfer = new TransferRequest() + .amount(500) + .description("This is a description for a transfer.") + .transferInstrument(new TransferInstrumentRequest() + .bankAccount(new BankAccountRequest() + .bankNumber("001") + .agencyNumber("1111") + .agencyCheckNumber("2") + .accountNumber("9999") + .accountCheckNumber("8") + .checking() + .holder(new HolderRequest() + .fullname("Nome do Portador") + .taxDocument(TaxDocumentRequest.cpf("22222222222")) + ) + ) + ); + + String json = new GsonFactory().gson().toJson(transfer); + JsonObject expectedJSON = getJsonFileAsJsonObject("transfer/createWithDescription.json"); + + JSONAssert.assertEquals(expectedJSON.toString(), json, true); + } } diff --git a/src/test/resources/jsons/transfer/createWithDescription.json b/src/test/resources/jsons/transfer/createWithDescription.json new file mode 100644 index 0000000..4a6f8a6 --- /dev/null +++ b/src/test/resources/jsons/transfer/createWithDescription.json @@ -0,0 +1 @@ +{"amount":500,"description":"This is a description for a transfer.","transferInstrument":{"method":"BANK_ACCOUNT","bankAccount":{"type":"CHECKING","bankNumber":"001","agencyNumber":"1111","agencyCheckNumber":"2","accountNumber":"9999","accountCheckNumber":"8","holder":{"fullname":"Nome do Portador","taxDocument":{"type":"CPF","number":"22222222222"}}}}}