mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-18 12:57:39 +00:00
[AB-xxx] adding currency conversion command
This commit is contained in:
@@ -5,5 +5,6 @@ public class WebServicesSlashCommandNames {
|
||||
public static final String URBAN = "urban";
|
||||
public static final String WEATHER = "weather";
|
||||
public static final String WIKIPEDIA = "wikipedia";
|
||||
public static final String CONVERSION = "conversion";
|
||||
public static final String DICTIONARY = "dictionary";
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ public enum WebserviceFeatureDefinition implements FeatureDefinition {
|
||||
THREAD_READER("threadReader"),
|
||||
OPEN_WEATHER_MAP("openWeatherMap"),
|
||||
WIKIPEDIA("wikipedia"),
|
||||
DICTIONARY("dictionary");
|
||||
DICTIONARY("dictionary"),
|
||||
CURRENCY_CONVERSION("currencyConversion");
|
||||
|
||||
private String key;
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.abstracto.webservices.currencyconversion.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||
import dev.sheldan.abstracto.webservices.config.WebserviceFeatureDefinition;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CurrencyConversionApiFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return WebserviceFeatureDefinition.CURRENCY_CONVERSION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.sheldan.abstracto.webservices.currencyconversion.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.exception.AbstractoTemplatedException;
|
||||
|
||||
public class CurrencyNotFoundException extends AbstractoTemplatedException {
|
||||
public CurrencyNotFoundException() {
|
||||
super("Currency not found", "currency_conversion_currency_not_found_exception");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.webservices.currencyconversion.model;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
public class ConvertCurrencyResponseModel {
|
||||
private Currency sourceCurrency;
|
||||
private Currency targetCurrency;
|
||||
private Double sourceValue;
|
||||
private Double targetValue;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.sheldan.abstracto.webservices.currencyconversion.model;
|
||||
|
||||
import java.util.Map;
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Builder
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Currency {
|
||||
private String symbol;
|
||||
private String symbolNative;
|
||||
private String name;
|
||||
private String code;
|
||||
private Map<String, Double> exchangeRates;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.sheldan.abstracto.webservices.currencyconversion.service;
|
||||
|
||||
import dev.sheldan.abstracto.webservices.currencyconversion.model.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CurrencyConversionApiService {
|
||||
List<Currency> getSupportedCurrencies();
|
||||
Currency getCurrencyForString(String input);
|
||||
Double convertCurrency(String sourceCurrency, String targetCurrency, Double amount);
|
||||
Map<String, Double> getExchangeRates(Currency sourceCurrency);
|
||||
Double convertCurrency(Currency sourceCurrency, Currency targetCurrency, Double amount);
|
||||
}
|
||||
Reference in New Issue
Block a user