Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/br/com/moip/request/TransferRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class TransferRequest {

private Integer amount;
private String description;
private TransferInstrumentRequest transferInstrument;

public TransferRequest amount(Integer amount){
Expand All @@ -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;

Expand Down
26 changes: 26 additions & 0 deletions src/test/java/br/com/moip/request/TransferRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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"}}}}}