Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
import java.util.List;

@RestController
@RequestMapping("/v{version:1}/wallets")
@RequestMapping("/v{version:1}/accounts")
public class WalletCommandController {
private final AkcesClient akcesClient;

public WalletCommandController(AkcesClient akcesClient) {
this.akcesClient = akcesClient;
}

@PostMapping("/{walletId}/balances/{currency}/credit")
public Mono<ResponseEntity<BalanceOutput>> creditBalance(@PathVariable("walletId") String walletId,
@PostMapping("/{accountId}/wallet/balances/{currency}/credit")
public Mono<ResponseEntity<BalanceOutput>> creditBalance(@PathVariable("accountId") String accountId,
@PathVariable("currency") String currency,
@RequestBody CreditWalletInput input) {
return Mono.fromCompletionStage(akcesClient.send("TEST", input.toCommand(walletId, currency)))
return Mono.fromCompletionStage(akcesClient.send("TEST", input.toCommand(accountId, currency)))
.map(List::getFirst)
.handle((domainEvent, sink) -> {
if (domainEvent instanceof WalletCreditedEvent) {
Expand All @@ -55,9 +55,9 @@ public Mono<ResponseEntity<BalanceOutput>> creditBalance(@PathVariable("walletId
});
}

@PostMapping("/{walletId}/balances")
public Mono<ResponseEntity<BalanceOutput>> createBalance(@PathVariable("walletId") String walletId, @RequestBody CreateBalanceInput input) {
return Mono.fromCompletionStage(akcesClient.send("TEST", input.toCommand(walletId)))
@PostMapping("/{accountId}/wallet/balances")
public Mono<ResponseEntity<BalanceOutput>> createBalance(@PathVariable("accountId") String accountId, @RequestBody CreateBalanceInput input) {
return Mono.fromCompletionStage(akcesClient.send("TEST", input.toCommand(accountId)))
.map(List::getFirst)
.handle((domainEvent, sink) -> {
if (domainEvent instanceof BalanceCreatedEvent balanceCreatedEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void testCreateAccountAndCreditWallet() {
// credit the wallet for this user id with 1 BTC
CreditWalletInput creditInput = new CreditWalletInput(new BigDecimal("1.0"));
webTestClient.post()
.uri("/v1/wallets/" + accountOutput.userId() + "/balances/EUR/credit")
.uri("/v1/accounts/" + accountOutput.userId() + "/wallet/balances/EUR/credit")
.bodyValue(creditInput)
.exchange()
.expectStatus().is2xxSuccessful()
Expand Down Expand Up @@ -248,7 +248,7 @@ void testCreateAccountAndCreditWalletWithoutBalance() {
// credit the wallet for this user id with 1 ETH
CreditWalletInput creditInput = new CreditWalletInput(new BigDecimal("1.0"));
webTestClient.post()
.uri("/v1/wallets/" + accountOutput.userId() + "/balances/ETH/credit")
.uri("/v1/accounts/" + accountOutput.userId() + "/wallet/balances/ETH/credit")
.bodyValue(creditInput)
.exchange()
.expectStatus().is4xxClientError()
Expand Down Expand Up @@ -283,7 +283,7 @@ void testCreateAccountAndAddBtcBalance() {
// add a BTC balance to the wallet for this user id
CreateBalanceInput createBalanceInput = new CreateBalanceInput("BTC");
webTestClient.post()
.uri("/v1/wallets/" + accountOutput.userId() + "/balances")
.uri("/v1/accounts/" + accountOutput.userId() + "/wallet/balances")
.bodyValue(createBalanceInput)
.exchange()
.expectStatus().is2xxSuccessful();
Expand Down Expand Up @@ -340,14 +340,14 @@ void testPlaceBuyOrder() {

// Credit EUR balance
webTestClient.post()
.uri("/v1/wallets/" + userId + "/balances/EUR/credit")
.uri("/v1/accounts/" + userId + "/wallet/balances/EUR/credit")
.bodyValue(new CreditWalletInput(new BigDecimal("10000.0")))
.exchange()
.expectStatus().is2xxSuccessful();

// Add BTC balance
webTestClient.post()
.uri("/v1/wallets/" + userId + "/balances")
.uri("/v1/accounts/" + userId + "/wallet/balances")
.bodyValue(new CreateBalanceInput("BTC"))
.exchange()
.expectStatus().is2xxSuccessful();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("/v{version:1}/wallets")
@RequestMapping("/v{version:1}/accounts")
public class WalletQueryController {
private final QueryModels queryModels;

public WalletQueryController(QueryModels queryModels) {
this.queryModels = queryModels;
}

@GetMapping("/{walletId}")
Mono<ResponseEntity<WalletQueryModelState>> getWallet(@PathVariable("walletId") String walletId) {
return Mono.fromCompletionStage(queryModels.getHydratedState(WalletQueryModel.class, walletId))
@GetMapping("/{accountId}/wallet")
Mono<ResponseEntity<WalletQueryModelState>> getWallet(@PathVariable("accountId") String accountId) {
return Mono.fromCompletionStage(queryModels.getHydratedState(WalletQueryModel.class, accountId))
.map(ResponseEntity::ok)
.onErrorResume(throwable -> {
if (throwable instanceof QueryModelNotFoundException || throwable instanceof QueryModelIdNotFoundException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void testBuyCrypto() {

// Create an ETH wallet
e2eTestClient.post()
.uri("/v1/wallets/{userId}/balances", userId)
.uri("/v1/accounts/{userId}/wallet/balances", userId)
.bodyValue(new CreateBalanceInput("ETH"))
.exchange()
.expectStatus().is2xxSuccessful()
Expand All @@ -101,7 +101,7 @@ public void testBuyCrypto() {

// credit the EUR wallet with a balance of 1000
e2eTestClient.post()
.uri("/v1/wallets/{userId}/balances/EUR/credit", userId)
.uri("/v1/accounts/{userId}/wallet/balances/EUR/credit", userId)
.bodyValue(new CreditWalletInput(new BigDecimal("1000.00")))
.exchange()
.expectStatus().is2xxSuccessful()
Expand Down Expand Up @@ -139,7 +139,7 @@ public void testBuyCrypto() {

// test the wallet balances
e2eTestClient.get()
.uri("/v1/wallets/{userId}", userId)
.uri("/v1/accounts/{userId}/wallet", userId)
.exchange()
.expectStatus().is2xxSuccessful()
.expectBody(WalletQueryModelState.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void testCreateAccountAndCreditWallet() {
// credit the wallet for this user id with 1 BTC
CreditWalletInput creditInput = new CreditWalletInput(new BigDecimal("1.0"));
webTestClient.post()
.uri("/v1/wallets/" + accountOutput.userId() + "/balances/EUR/credit")
.uri("/v1/accounts/" + accountOutput.userId() + "/wallet/balances/EUR/credit")
.bodyValue(creditInput)
.exchange()
.expectStatus().is2xxSuccessful()
Expand Down Expand Up @@ -276,7 +276,7 @@ void testCreateAccountAndCreditWalletWithoutBalance() {
// credit the wallet for this user id with 1 ETH
CreditWalletInput creditInput = new CreditWalletInput(new BigDecimal("1.0"));
webTestClient.post()
.uri("/v1/wallets/" + accountOutput.userId() + "/balances/ETH/credit")
.uri("/v1/accounts/" + accountOutput.userId() + "/wallet/balances/ETH/credit")
.bodyValue(creditInput)
.exchange()
.expectStatus().is4xxClientError()
Expand Down Expand Up @@ -311,7 +311,7 @@ void testCreateAccountAndAddBtcBalance() {
// add a BTC balance to the wallet for this user id
CreateBalanceInput createBalanceInput = new CreateBalanceInput("BTC");
webTestClient.post()
.uri("/v1/wallets/" + accountOutput.userId() + "/balances")
.uri("/v1/accounts/" + accountOutput.userId() + "/wallet/balances")
.bodyValue(createBalanceInput)
.exchange()
.expectStatus().is2xxSuccessful();
Expand Down Expand Up @@ -440,14 +440,14 @@ void testPlaceBuyOrder() {

// Credit EUR balance
webTestClient.post()
.uri("/v1/wallets/" + userId + "/balances/EUR/credit")
.uri("/v1/accounts/" + userId + "/wallet/balances/EUR/credit")
.bodyValue(new CreditWalletInput(new BigDecimal("10000.0")))
.exchange()
.expectStatus().is2xxSuccessful();

// Add BTC balance
webTestClient.post()
.uri("/v1/wallets/" + userId + "/balances")
.uri("/v1/accounts/" + userId + "/wallet/balances")
.bodyValue(new CreateBalanceInput("BTC"))
.exchange()
.expectStatus().is2xxSuccessful();
Expand Down
Loading