diff --git a/pom.xml b/pom.xml
index 78cfbdb..69862f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
eu.ztsh
wymiana-walut
- 1.1.0
+ 1.0.0
@@ -28,7 +28,6 @@
3.5.4
- 2.5.0
1.2.1
@@ -63,11 +62,6 @@
lombok
provided
-
- org.springdoc
- springdoc-openapi-starter-webmvc-ui
- ${openapi.version}
-
@@ -116,7 +110,6 @@
${basedir}/src/main/resources/schema
eu.ztsh.wymiana.model
- true
diff --git a/readme.md b/readme.md
deleted file mode 100644
index f2ce86f..0000000
--- a/readme.md
+++ /dev/null
@@ -1,202 +0,0 @@
-# Wymiana walut
-
-Prosty mikroserwis stworzony na potrzeby rekrutacji
-
-## Założenia
-
-- PESEL jedynym identyfikatorem
-- Jedno konto na PESEL
-- Użytkownik pełnoletni
-- Wymiana walut na podstawie tabeli NBP
-- Baza danych in-memory
-
-## Interfejsy
-
-- stworzenie konta
-
- ⇒ POST `/api/user`
- ```json
- {
- "type": "object",
- "properties": {
- "name": {
- "type": "string"
- },
- "surname": {
- "type": "string"
- },
- "pesel": {
- "type": "string"
- },
- "initial": {
- "type": "number",
- "description": "początkowy stan konta w domyślnej walucie"
- }
- },
- "required": [
- "name",
- "surname",
- "pesel",
- "initial"
- ]
- }
- ```
- ⇐ 204/400/409/500
-
-- pobranie informacji o koncie
-
- ⇒ GET `/api/user/{pesel}`
-
- ⇐ 200/400/404/500
- ```json
- {
- "type": "object",
- "def": {
- "currency": {
- "type": "object",
- "properties": {
- "symbol": {
- "type": "string"
- },
- "amount": {
- "type": "number"
- }
- },
- "required": [
- "symbol",
- "amount"
- ]
- }
- },
- "properties": {
- "name": {
- "type": "string"
- },
- "surname": {
- "type": "string"
- },
- "pesel": {
- "type": "string"
- },
- "currencies": {
- "type": "array",
- "items": {
- "$ref": "#/def/currency"
- }
- }
- },
- "required": [
- "name",
- "surname",
- "pesel",
- "currencies"
- ]
- }
- ```
-- zlecenie wymiany walut
-
- ⇒ POST `/api/exchange/{pesel}`
- ```json
- {
- "type": "object",
- "properties": {
- "pesel": {
- "type": "string"
- },
- "from": {
- "type": "string",
- "description": "waluta źródłowa"
- },
- "to": {
- "type": "string",
- "description": "waluta docelowa"
- },
- "toBuy": {
- "type": "number",
- "description": "ilość do zakupu"
- },
- "toSell": {
- "type": "number",
- "description": "ilość do sprzedaży"
- }
- },
- "oneOf": [
- {
- "required": [
- "pesel",
- "from",
- "to",
- "toBuy"
- ]
- },
- {
- "required": [
- "pesel",
- "from",
- "to",
- "toSell"
- ]
- }
- ]
- }
- ```
-
- ⇐ 200/400/404/500
-
- patrz: pobranie informacji o koncie
-
-## Architektura
-
-```mermaid
- flowchart LR
- actor["fa:fa-person"]
- subgraph NBP
- tabC["Tabela C"]
- end
- subgraph proces
- subgraph spring-boot
- core
- subgraph endpoint
- user
- exchange
- end
- end
- hsqldb
- end
-
- actor <--> user
- actor <--> exchange
- endpoint <--> core
- core <--> tabC
- core <-- hsql . port --> hsqldb
-
-```
-
-## Konfiguracja
-
-Aplikacja posiada dostosowaną konfigurację, która obejmuje własności:
-
-### `hsqldb`
-
-Konfiguracja bazy danych
-
-| Nazwa | Opis | Typ | Wartość domyślna |
-|-------|------------------|--------|------------------|
-| name | host bazy danych | string | db |
-| port | port bazy danych | int | 9090 |
-
-### `nbp`
-
-Konfiguracja połączenia z Narodowym Bankiem Polskim
-
-| Nazwa | Opis | Typ | Wartość domyślna |
-|---------|--------------|--------|-------------------|
-| baseurl | host API nbp | string | http://api.nbp.pl |
-
-### `currency`
-
-Konfiguracja walut
-
-| Nazwa | Opis | Typ | Wartość domyślna |
-|---------|-----------------------------------------|--------|------------------|
-| initial | waluta początkowa przy zakładaniu konta | string | PLN |
diff --git a/src/main/java/eu/ztsh/wymiana/config/CurrencyProperties.java b/src/main/java/eu/ztsh/wymiana/config/CurrencyProperties.java
deleted file mode 100644
index 9cfbce1..0000000
--- a/src/main/java/eu/ztsh/wymiana/config/CurrencyProperties.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package eu.ztsh.wymiana.config;
-
-import eu.ztsh.wymiana.model.Symbol;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-@ConfigurationProperties("currency")
-public record CurrencyProperties(Symbol initial) {
-
-}
diff --git a/src/main/java/eu/ztsh/wymiana/data/entity/CurrencyEntity.java b/src/main/java/eu/ztsh/wymiana/data/entity/CurrencyEntity.java
index 95615f0..441b224 100644
--- a/src/main/java/eu/ztsh/wymiana/data/entity/CurrencyEntity.java
+++ b/src/main/java/eu/ztsh/wymiana/data/entity/CurrencyEntity.java
@@ -1,17 +1,12 @@
package eu.ztsh.wymiana.data.entity;
-import eu.ztsh.wymiana.model.Symbol;
import jakarta.persistence.Entity;
-import jakarta.persistence.EnumType;
-import jakarta.persistence.Enumerated;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
-import java.math.BigDecimal;
-
@Data
@NoArgsConstructor
@AllArgsConstructor
@@ -22,8 +17,7 @@ public class CurrencyEntity {
@Id
String pesel;
@Id
- @Enumerated(EnumType.STRING)
- Symbol symbol;
- BigDecimal amount;
+ String symbol;
+ Double amount;
}
diff --git a/src/main/java/eu/ztsh/wymiana/exception/NoDataException.java b/src/main/java/eu/ztsh/wymiana/exception/NoDataException.java
index 1472b0b..8da9ad6 100644
--- a/src/main/java/eu/ztsh/wymiana/exception/NoDataException.java
+++ b/src/main/java/eu/ztsh/wymiana/exception/NoDataException.java
@@ -1,10 +1,8 @@
package eu.ztsh.wymiana.exception;
-import eu.ztsh.wymiana.model.Symbol;
-
public class NoDataException extends RuntimeException {
- public NoDataException(Symbol code, String date) {
+ public NoDataException(String code, String date) {
super("No data for code %s and date %s".formatted(code, date));
}
diff --git a/src/main/java/eu/ztsh/wymiana/model/Currency.java b/src/main/java/eu/ztsh/wymiana/model/Currency.java
index 05e7ab1..0cc6b16 100644
--- a/src/main/java/eu/ztsh/wymiana/model/Currency.java
+++ b/src/main/java/eu/ztsh/wymiana/model/Currency.java
@@ -1,7 +1,5 @@
package eu.ztsh.wymiana.model;
-import java.math.BigDecimal;
-
-public record Currency(Symbol symbol, BigDecimal amount) {
+public record Currency(String symbol, double amount) {
}
diff --git a/src/main/java/eu/ztsh/wymiana/model/Symbol.java b/src/main/java/eu/ztsh/wymiana/model/Symbol.java
deleted file mode 100644
index 4d38bbd..0000000
--- a/src/main/java/eu/ztsh/wymiana/model/Symbol.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package eu.ztsh.wymiana.model;
-
-public enum Symbol {
- PLN,
- USD
-}
diff --git a/src/main/java/eu/ztsh/wymiana/model/User.java b/src/main/java/eu/ztsh/wymiana/model/User.java
index 7ae46a1..a1f28f1 100644
--- a/src/main/java/eu/ztsh/wymiana/model/User.java
+++ b/src/main/java/eu/ztsh/wymiana/model/User.java
@@ -2,6 +2,6 @@ package eu.ztsh.wymiana.model;
import java.util.Map;
-public record User(String name, String surname, String pesel, Map currencies) {
+public record User(String name, String surname, String pesel, Map currencies) {
}
diff --git a/src/main/java/eu/ztsh/wymiana/model/UserCreateRequestConfiguredWrapper.java b/src/main/java/eu/ztsh/wymiana/model/UserCreateRequestConfiguredWrapper.java
deleted file mode 100644
index b4a3619..0000000
--- a/src/main/java/eu/ztsh/wymiana/model/UserCreateRequestConfiguredWrapper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package eu.ztsh.wymiana.model;
-
-import eu.ztsh.wymiana.web.model.UserCreateRequest;
-
-import java.math.BigDecimal;
-
-public class UserCreateRequestConfiguredWrapper {
-
- private final UserCreateRequest request;
- private final Symbol initialSymbol;
-
- public String name() {
- return request.name();
- }
-
- public String surname() {
- return request.surname();
- }
-
- public String pesel() {
- return request.pesel();
- }
-
- public BigDecimal initial() {
- return request.initial();
- }
-
- public Symbol initialSymbol() {
- return initialSymbol;
- }
-
- private UserCreateRequestConfiguredWrapper(Builder builder) {
- this.request = builder.request;
- this.initialSymbol = builder.initial;
- }
-
- public static Builder wrap(UserCreateRequest request) {
- return new Builder().withRequest(request);
- }
-
- public static final class Builder {
-
- private UserCreateRequest request;
- private Symbol initial;
-
- private Builder() {
- }
-
- private Builder withRequest(UserCreateRequest request) {
- this.request = request;
- return this;
- }
-
- public Builder withInitial(Symbol initial) {
- this.initial = initial;
- return this;
- }
-
- public UserCreateRequestConfiguredWrapper build() {
- return new UserCreateRequestConfiguredWrapper(this);
- }
-
- }
-
-}
diff --git a/src/main/java/eu/ztsh/wymiana/service/CurrencyService.java b/src/main/java/eu/ztsh/wymiana/service/CurrencyService.java
index e9736d7..401626a 100644
--- a/src/main/java/eu/ztsh/wymiana/service/CurrencyService.java
+++ b/src/main/java/eu/ztsh/wymiana/service/CurrencyService.java
@@ -4,7 +4,6 @@ import eu.ztsh.wymiana.exception.ExchangeFailedException;
import eu.ztsh.wymiana.exception.InsufficientFundsException;
import eu.ztsh.wymiana.exception.UserNotFoundException;
import eu.ztsh.wymiana.model.Currency;
-import eu.ztsh.wymiana.model.Symbol;
import eu.ztsh.wymiana.model.User;
import eu.ztsh.wymiana.validation.InstanceValidator;
import eu.ztsh.wymiana.web.model.CurrencyExchangeRequest;
@@ -29,56 +28,59 @@ public class CurrencyService {
public User exchange(CurrencyExchangeRequest request) {
validator.validate(request);
return userService.get(request.pesel()).map(user -> {
- if (!request.from().equals(Symbol.PLN) && !request.to().equals(Symbol.PLN)) {
+ if (!request.from().equalsIgnoreCase("PLN") && !request.to().equalsIgnoreCase("PLN")) {
throw new ExchangeFailedException("Either 'from' or 'to' has to be PLN");
}
+ // As we support only USD now, we need to limit second parameter too
+ // Begin: unlock other currencies
+ if (!request.from().equalsIgnoreCase("USD") && !request.to().equalsIgnoreCase("USD")) {
+ throw new ExchangeFailedException("Either 'from' or 'to' has to be USD");
+ }
+ // End: unlock other currencies
- var from = user.currencies().get(request.from());
+ var from = user.currencies().get(request.from().toUpperCase());
if (from == null) {
// There is no currency 'from' opened so no need to check if user has funds to exchange
throw new InsufficientFundsException();
}
var exchanged = performExchange(from,
- Optional.ofNullable(user.currencies().get(request.to())).orElse(create(request.to())),
- Optional.ofNullable(request.toSell()).orElse(BigDecimal.ZERO),
- Optional.ofNullable(request.toBuy()).orElse(BigDecimal.ZERO));
+ Optional.ofNullable(user.currencies().get(request.to().toUpperCase())).orElse(create(request.to())),
+ Optional.ofNullable(request.toSell()).orElse(0D),
+ Optional.ofNullable(request.toBuy()).orElse(0D));
user.currencies().putAll(exchanged);
return userService.update(user);
})
.orElseThrow(() -> new UserNotFoundException(request));
}
- private Currency create(Symbol symbol) {
- return new Currency(symbol, BigDecimal.ZERO);
+ private Currency create(String symbol) {
+ // TODO: check if supported - now limited to PLN <-> USD
+ return new Currency(symbol.toUpperCase(), 0D);
}
- private Map performExchange(Currency from, Currency to, BigDecimal toSell, BigDecimal toBuy) {
- BigDecimal exchangeRate;
- BigDecimal neededFromAmount;
- BigDecimal requestedToAmount;
- if (from.symbol().equals(Symbol.PLN)) {
+ private Map performExchange(Currency from, Currency to, double toSell, double toBuy) {
+ double exchangeRate;
+ double neededFromAmount;
+ double requestedToAmount;
+ if (from.symbol().equalsIgnoreCase("PLN")) {
exchangeRate = nbpService.getSellRate(to.symbol());
- neededFromAmount = round(toBuy.signum() != 0 ? toBuy.multiply(exchangeRate) : toSell);
- requestedToAmount = round(toBuy.signum() != 0 ? toBuy : divide(toSell, exchangeRate));
+ neededFromAmount = round(toBuy != 0 ? toBuy * exchangeRate : toSell);
+ requestedToAmount = round(toBuy != 0 ? toBuy : toSell / exchangeRate);
} else {
exchangeRate = nbpService.getBuyRate(from.symbol());
- neededFromAmount = round(toBuy.signum() != 0 ? divide(toBuy, exchangeRate) : toSell);
- requestedToAmount = round(toBuy.signum() != 0 ? toBuy : toSell.multiply(exchangeRate));
+ neededFromAmount = round(toBuy != 0 ? toBuy / exchangeRate : toSell);
+ requestedToAmount = round(toBuy != 0 ? toBuy : toSell * exchangeRate);
}
- if (neededFromAmount.compareTo(from.amount()) > 0) {
+ if (neededFromAmount > from.amount()) {
throw new InsufficientFundsException();
}
- var newFrom = new Currency(from.symbol(), from.amount().subtract(neededFromAmount));
- var newTo = new Currency(to.symbol(), to.amount().add(requestedToAmount));
+ var newFrom = new Currency(from.symbol(), from.amount() - neededFromAmount);
+ var newTo = new Currency(to.symbol(), to.amount() + requestedToAmount);
return Stream.of(newFrom, newTo).collect(Collectors.toMap(Currency::symbol, currency -> currency));
}
- private BigDecimal round(BigDecimal input) {
- return input.setScale(2, RoundingMode.HALF_UP);
- }
-
- private BigDecimal divide(BigDecimal input, BigDecimal division) {
- return input.setScale(2, RoundingMode.HALF_UP).divide(division, RoundingMode.HALF_UP);
+ private double round(double input) {
+ return BigDecimal.valueOf(input).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
}
diff --git a/src/main/java/eu/ztsh/wymiana/service/NbpService.java b/src/main/java/eu/ztsh/wymiana/service/NbpService.java
index 3d5edd3..e612e0a 100644
--- a/src/main/java/eu/ztsh/wymiana/service/NbpService.java
+++ b/src/main/java/eu/ztsh/wymiana/service/NbpService.java
@@ -2,14 +2,12 @@ package eu.ztsh.wymiana.service;
import eu.ztsh.wymiana.exception.NoDataException;
import eu.ztsh.wymiana.model.Rates;
-import eu.ztsh.wymiana.model.Symbol;
import lombok.RequiredArgsConstructor;
import org.assertj.core.util.VisibleForTesting;
import org.springframework.http.HttpStatusCode;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient;
-import java.math.BigDecimal;
import java.time.Clock;
import java.time.DayOfWeek;
import java.time.LocalDate;
@@ -30,28 +28,28 @@ public class NbpService {
private static final String URI_PATTERN = "/api/exchangerates/rates/c/{code}/{date}/";
private final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- private final ConcurrentMap cache = new ConcurrentHashMap<>(1);
+ private final ConcurrentMap cache = new ConcurrentHashMap<>(1);
- public BigDecimal getSellRate(Symbol currency) {
- return getCurrency(currency).sell();
+ public double getSellRate(String currency) {
+ return getCurrency(currency.toUpperCase()).sell();
}
- public BigDecimal getBuyRate(Symbol currency) {
- return getCurrency(currency).buy();
+ public double getBuyRate(String currency) {
+ return getCurrency(currency.toUpperCase()).buy();
}
- private synchronized RatesCache getCurrency(Symbol currency) {
+ private synchronized RatesCache getCurrency(String currency) {
var today = getFetchDate();
var cacheObject = cache.get(currency);
if (cacheObject == null || cacheObject.date().isBefore(today)) {
var fresh = fetchData(currency, dtf.format(today));
- var rate = fresh.getRates().getFirst();
+ var rate = fresh.getRates().get(0);
cacheObject = new RatesCache(
LocalDate.parse(rate.getEffectiveDate(), dtf),
rate.getBid(),
rate.getAsk()
);
- cache.put(Symbol.valueOf(fresh.getCode().toUpperCase()), cacheObject);
+ cache.put(fresh.getCode(), cacheObject);
}
return cacheObject;
}
@@ -70,8 +68,8 @@ public class NbpService {
}
@VisibleForTesting
- Rates fetchData(Symbol code, String date) {
- return restClient.get().uri(URI_PATTERN, code.name().toLowerCase(), date)
+ Rates fetchData(String code, String date) {
+ return restClient.get().uri(URI_PATTERN, code.toLowerCase(), date)
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError, ((request, response) -> {
throw new NoDataException(code, date);
@@ -84,7 +82,7 @@ public class NbpService {
|| today.getDayOfWeek() == DayOfWeek.SUNDAY;
}
- private record RatesCache(LocalDate date, BigDecimal buy, BigDecimal sell) {
+ private record RatesCache(LocalDate date, double buy, double sell) {
}
diff --git a/src/main/java/eu/ztsh/wymiana/service/UserService.java b/src/main/java/eu/ztsh/wymiana/service/UserService.java
index 2205d19..857bc0f 100644
--- a/src/main/java/eu/ztsh/wymiana/service/UserService.java
+++ b/src/main/java/eu/ztsh/wymiana/service/UserService.java
@@ -1,10 +1,8 @@
package eu.ztsh.wymiana.service;
-import eu.ztsh.wymiana.config.CurrencyProperties;
import eu.ztsh.wymiana.data.repository.UserRepository;
import eu.ztsh.wymiana.exception.UserAlreadyExistsException;
import eu.ztsh.wymiana.model.User;
-import eu.ztsh.wymiana.model.UserCreateRequestConfiguredWrapper;
import eu.ztsh.wymiana.util.UserMapper;
import eu.ztsh.wymiana.validation.InstanceValidator;
import eu.ztsh.wymiana.web.model.UserCreateRequest;
@@ -22,16 +20,13 @@ public class UserService {
private final UserRepository userRepository;
private final InstanceValidator validator;
- private final CurrencyProperties currencyProperties;
public User create(UserCreateRequest request) {
validator.validate(request);
if (userRepository.findById(request.pesel()).isPresent()) {
throw new UserAlreadyExistsException(request);
}
- return UserMapper.entityToPojo(userRepository.save(UserMapper.requestToEntity(
- UserCreateRequestConfiguredWrapper.wrap(request).withInitial(currencyProperties.initial()).build()
- )));
+ return UserMapper.entityToPojo(userRepository.save(UserMapper.requestToEntity(request)));
}
public Optional get(@PESEL String pesel) {
diff --git a/src/main/java/eu/ztsh/wymiana/util/CurrencyMapper.java b/src/main/java/eu/ztsh/wymiana/util/CurrencyMapper.java
index 697e956..b962ddc 100644
--- a/src/main/java/eu/ztsh/wymiana/util/CurrencyMapper.java
+++ b/src/main/java/eu/ztsh/wymiana/util/CurrencyMapper.java
@@ -2,7 +2,6 @@ package eu.ztsh.wymiana.util;
import eu.ztsh.wymiana.data.entity.CurrencyEntity;
import eu.ztsh.wymiana.model.Currency;
-import eu.ztsh.wymiana.model.Symbol;
import java.util.List;
import java.util.Map;
@@ -18,12 +17,12 @@ public class CurrencyMapper {
return new CurrencyEntity(pesel, pojo.symbol(), pojo.amount());
}
- public static Map entitiesToPojoMap(List values) {
+ public static Map entitiesToPojoMap(List values) {
return values.stream().map(CurrencyMapper::entityToPojo)
.collect(Collectors.toMap(Currency::symbol, pojo -> pojo));
}
- public static List pojoMapToEntities(Map currencies, String pesel) {
+ public static List pojoMapToEntities(Map currencies, String pesel) {
return currencies.values().stream().map(entry -> pojoToEntity(entry, pesel)).toList();
}
diff --git a/src/main/java/eu/ztsh/wymiana/util/UserMapper.java b/src/main/java/eu/ztsh/wymiana/util/UserMapper.java
index 31c2a20..39985fb 100644
--- a/src/main/java/eu/ztsh/wymiana/util/UserMapper.java
+++ b/src/main/java/eu/ztsh/wymiana/util/UserMapper.java
@@ -3,8 +3,7 @@ package eu.ztsh.wymiana.util;
import eu.ztsh.wymiana.data.entity.CurrencyEntity;
import eu.ztsh.wymiana.data.entity.UserEntity;
import eu.ztsh.wymiana.model.User;
-import eu.ztsh.wymiana.model.UserCreateRequestConfiguredWrapper;
-import eu.ztsh.wymiana.web.model.UserResponse;
+import eu.ztsh.wymiana.web.model.UserCreateRequest;
import java.util.List;
@@ -20,13 +19,9 @@ public class UserMapper {
CurrencyMapper.pojoMapToEntities(pojo.currencies(), pojo.pesel()));
}
- public static UserResponse pojoToResponse(User pojo) {
- return new UserResponse(pojo.name(), pojo.surname(), pojo.pesel(), pojo.currencies().values().stream().toList());
- }
-
- public static UserEntity requestToEntity(UserCreateRequestConfiguredWrapper request) {
+ public static UserEntity requestToEntity(UserCreateRequest request) {
return new UserEntity(request.pesel(), request.name(), request.surname(),
- List.of(new CurrencyEntity(request.pesel(), request.initialSymbol(), request.initial())));
+ List.of(new CurrencyEntity(request.pesel(), "PLN", request.pln())));
}
private UserMapper() {
diff --git a/src/main/java/eu/ztsh/wymiana/validation/ValidExchangeRequestValidator.java b/src/main/java/eu/ztsh/wymiana/validation/ValidExchangeRequestValidator.java
index 9a01a0c..143876b 100644
--- a/src/main/java/eu/ztsh/wymiana/validation/ValidExchangeRequestValidator.java
+++ b/src/main/java/eu/ztsh/wymiana/validation/ValidExchangeRequestValidator.java
@@ -18,8 +18,8 @@ public class ValidExchangeRequestValidator implements
return (request.from() != null && !request.from().equals(request.to()))
&& !((request.toBuy() == null && request.toSell() == null)
|| (request.toBuy() != null && request.toSell() != null))
- && ((request.toBuy() != null && request.toBuy().signum() >= 0)
- || (request.toSell() != null && request.toSell().signum() >= 0));
+ && ((request.toBuy() != null && request.toBuy() >= 0)
+ || (request.toSell() != null && request.toSell() >= 0));
}
}
diff --git a/src/main/java/eu/ztsh/wymiana/web/controller/ExchangeController.java b/src/main/java/eu/ztsh/wymiana/web/controller/ExchangeController.java
index 39c635d..fb0ee13 100644
--- a/src/main/java/eu/ztsh/wymiana/web/controller/ExchangeController.java
+++ b/src/main/java/eu/ztsh/wymiana/web/controller/ExchangeController.java
@@ -4,16 +4,9 @@ import eu.ztsh.wymiana.exception.InsufficientFundsException;
import eu.ztsh.wymiana.exception.UserNotFoundException;
import eu.ztsh.wymiana.service.CurrencyService;
import eu.ztsh.wymiana.web.model.CurrencyExchangeRequest;
-import eu.ztsh.wymiana.web.model.UserResponse;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.media.Content;
-import io.swagger.v3.oas.annotations.media.Schema;
-import io.swagger.v3.oas.annotations.responses.ApiResponse;
-import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
@@ -29,22 +22,6 @@ public class ExchangeController {
private final CurrencyService currencyService;
- @Operation(summary = "Perform exchange")
- @ApiResponses(value = {
- @ApiResponse(responseCode = "200",
- description = "Exchange performed successfully",
- content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
- schema = @Schema(implementation = UserResponse.class))),
- @ApiResponse(responseCode = "400",
- description = "Insufficient funds",
- content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE)),
- @ApiResponse(responseCode = "404",
- description = "User not found",
- content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE)),
- @ApiResponse(responseCode = "500",
- description = "Another error has occurred",
- content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE))
- })
@PostMapping
public ResponseEntity