Skip to content
Snippets Groups Projects
Commit 6d4b8379 authored by Fernando Ferreira de Lima Filho's avatar Fernando Ferreira de Lima Filho
Browse files

feature: client integration with transfer service

parent be4f551b
No related branches found
No related tags found
1 merge request!5Rest
No preview for this file type
......@@ -167,13 +167,19 @@ public class MachineState {
System.out.println(">>> Please enter with the value that you want transfer");
String v = sc.nextLine();
Account account = new Account(null, accountNumber, null);
TransferMessage transferMessage = new TransferMessage(this.client, account, Double.parseDouble(v));
ResponseEntity<Account> response = restTemplate.postForEntity(HOST_TRANSFER_SERVICE, transferMessage, Account.class);
ResponseEntity<Client> response =
restTemplate.getForEntity(
HOST_TRANSFER_SERVICE +
String.format("/%d?value=%s&toAccount=%s",
this.client.getId(),
v,
accountNumber
),
Client.class);
if(response.getStatusCodeValue() == 200) {
System.out.println(
String.format(">>> Your balance is: %.2f", response.getBody().getBalance())
String.format(">>> Your balance is: %.2f", response.getBody().getAccount().getBalance())
);
} else if(response.getStatusCodeValue() == 500) {
System.out.println(
......
......@@ -10,5 +10,5 @@ public class NameSpace {
public final static String HOST_WITHDRAWAL_SERVICE = String.format("http://127.0.0.1:%d/%s", PORT_WITHDRAWAL_SERVICE, "/gateway/withdrawal/banking/client");
public static final String HOST_DEPOSIT_SERVICE = String.format("http://127.0.0.1:%d/%s", PORT_DEPOSIT_SERVICE, "/gateway/deposit/banking/client");
public static final String HOST_BALANCE_SERVICE = String.format("http://127.0.0.1:%d/%s", PORT_BALANCE_SERVICE, "/gateway/balance/banking/client");
public final static String HOST_TRANSFER_SERVICE = String.format("http://127.0.0.1:%d/%s", PORT_TRANSFER_SERVICE, "transfer");
public final static String HOST_TRANSFER_SERVICE = String.format("http://127.0.0.1:%d/%s", PORT_TRANSFER_SERVICE, "/gateway/transfer/banking/client");
}
......@@ -15,7 +15,7 @@ public class TransferController {
@Autowired
private final TransferService service;
@PatchMapping
@GetMapping
@ResponseStatus(HttpStatus.OK)
public Client transfer(@PathVariable Integer id, @RequestParam(name = "value") Double value,
@RequestParam(name = "toAccount") String toAccountNumber) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment