-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementação do endpoint /accounts/transfer.
Desenvolvimento do endpoint /accounts/transfer para realização da função de transferência de dinheiro entre contas e suas validações.
- Loading branch information
1 parent
a04d0a7
commit e8828a3
Showing
3 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/br/com/maida/desafio/bankapi/model/AccountTransfer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package br.com.maida.desafio.bankapi.model; | ||
|
||
import java.math.BigDecimal; | ||
import javax.validation.constraints.DecimalMin; | ||
import javax.validation.constraints.Digits; | ||
import javax.validation.constraints.NotEmpty; | ||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* | ||
* @author Gabriel Duarte | ||
*/ | ||
public class AccountTransfer { | ||
|
||
@NotNull(message = "Campo source_account_number ausente.") | ||
@NotEmpty(message = "Campo source_account_number vazio.") | ||
private String source_account_number; | ||
|
||
@NotNull(message = "Campo destination_account_number ausente.") | ||
@NotEmpty(message = "Campo destination_account_number vazio.") | ||
private String destination_account_number; | ||
|
||
@NotNull(message = "Campo amount ausente.") | ||
@DecimalMin(value = "0.0", inclusive = false, message = "Valor deve ser maior que zero.") | ||
@Digits(integer=3, fraction=2) | ||
private BigDecimal amount; | ||
|
||
public AccountTransfer() { | ||
|
||
} | ||
|
||
public AccountTransfer(String source_account_number, String destination_account_number, BigDecimal amount) { | ||
this.source_account_number = source_account_number; | ||
this.destination_account_number = destination_account_number; | ||
this.amount = amount; | ||
} | ||
|
||
public String getSource_account_number() { | ||
return source_account_number; | ||
} | ||
|
||
public void setSource_account_number(String source_account_number) { | ||
this.source_account_number = source_account_number; | ||
} | ||
|
||
public String getDestination_account_number() { | ||
return destination_account_number; | ||
} | ||
|
||
public void setDestination_account_number(String destination_account_number) { | ||
this.destination_account_number = destination_account_number; | ||
} | ||
|
||
public BigDecimal getAmount() { | ||
return amount; | ||
} | ||
|
||
public void setAmount(BigDecimal amount) { | ||
this.amount = amount; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/br/com/maida/desafio/bankapi/model/AccountTransferResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package br.com.maida.desafio.bankapi.model; | ||
|
||
import java.math.BigDecimal; | ||
import org.json.JSONObject; | ||
|
||
/** | ||
* | ||
* @author Gabriel Duarte | ||
*/ | ||
public class AccountTransferResponse { | ||
|
||
private BigDecimal amount; | ||
private String source_account_number; | ||
private String destination_account_number; | ||
private JSONObject user_transfer; | ||
|
||
public AccountTransferResponse(BigDecimal amount, String source_account_number, String destination_account_number, String email, String name) { | ||
this.amount = amount; | ||
this.source_account_number = source_account_number; | ||
this.destination_account_number = destination_account_number; | ||
|
||
JSONObject jsonUserTransferAccount = new JSONObject(); | ||
|
||
jsonUserTransferAccount.put("email", email); | ||
jsonUserTransferAccount.put("name", name); | ||
|
||
this.user_transfer = jsonUserTransferAccount; | ||
} | ||
|
||
public BigDecimal getAmount() { | ||
return amount; | ||
} | ||
|
||
public String getSource_account_number() { | ||
return source_account_number; | ||
} | ||
|
||
public String getDestination_account_number() { | ||
return destination_account_number; | ||
} | ||
|
||
public JSONObject getUser_transfer() { | ||
return user_transfer; | ||
} | ||
|
||
} |