From 3675296d2214f8b795a8a58d0e6ead3ce31d2ad5 Mon Sep 17 00:00:00 2001 From: Marc0Franc0 Date: Thu, 28 Dec 2023 15:37:36 -0300 Subject: [PATCH] Modificaciones en DolarController y DolarService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Nuevo endpoint para obtener valores del dolár cripto - Se quito por el momento el endpoint para dolar soliodario ya que no esta disponible en la api externa utilizada --- .../controller/ApiDolar/DolarController.java | 16 ++++++++-- .../ExchangeRates/model/FinnHub/Quote.java | 1 + .../service/DolarApi/DolarService.java | 1 + .../service/DolarApi/DolarServiceImpl.java | 31 +++++++++---------- .../DolarApi/OtherCurrenciesServiceImpl.java | 12 +++---- 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/app/ExchangeRates/controller/ApiDolar/DolarController.java b/src/main/java/com/app/ExchangeRates/controller/ApiDolar/DolarController.java index 76cef00..f6e57dd 100644 --- a/src/main/java/com/app/ExchangeRates/controller/ApiDolar/DolarController.java +++ b/src/main/java/com/app/ExchangeRates/controller/ApiDolar/DolarController.java @@ -64,12 +64,13 @@ ResponseEntity getDollarCard(){ ResponseEntity getStockMarketDollar(){ return ResponseEntity.status(HttpStatus.OK).body(dolarService.getStockMarketDollar()); } - @Operation(summary = "Get Solidarity Dollar", responses = { + /* @Operation(summary = "Get Solidarity Dollar", responses = { @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = MoneyDTO.class))), @ApiResponse(responseCode = "404", description = "Not found", content = @Content)}) - @GetMapping("/solidarity") + @GetMapping("/solidarity")*/ + //No se encuentra disponible en api externa ResponseEntity getSolidarityDollar(){ return ResponseEntity.status(HttpStatus.OK).body(dolarService.getSolidarityDollar()); } @@ -83,5 +84,14 @@ ResponseEntity getSolidarityDollar(){ ResponseEntity getWholesaleDollar(){ return ResponseEntity.status(HttpStatus.OK).body(dolarService.getWholesaleDollar()); } - + @Operation(summary = "Get Wholesale Dollar", responses = { + @ApiResponse(description = "Successful Operation", responseCode = "200", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = MoneyDTO.class))), + @ApiResponse(responseCode = "404", description = "Not found", + content = @Content)}) + @GetMapping("/cripto") + ResponseEntity getCryptoollar(){ + return ResponseEntity.status(HttpStatus.OK).body(dolarService.getCryptoDollar()); + } } \ No newline at end of file diff --git a/src/main/java/com/app/ExchangeRates/model/FinnHub/Quote.java b/src/main/java/com/app/ExchangeRates/model/FinnHub/Quote.java index 91da9d3..8ed6575 100644 --- a/src/main/java/com/app/ExchangeRates/model/FinnHub/Quote.java +++ b/src/main/java/com/app/ExchangeRates/model/FinnHub/Quote.java @@ -5,6 +5,7 @@ @Builder @AllArgsConstructor +@ToString @Data public class Quote { @JsonProperty("c") diff --git a/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarService.java b/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarService.java index 12fa1fc..4592d44 100644 --- a/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarService.java +++ b/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarService.java @@ -12,4 +12,5 @@ public interface DolarService { Money getStockMarketDollar(); Money getSolidarityDollar(); Money getWholesaleDollar(); + Money getCryptoDollar(); } diff --git a/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarServiceImpl.java b/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarServiceImpl.java index 6bc460f..fc3f0b9 100644 --- a/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarServiceImpl.java +++ b/src/main/java/com/app/ExchangeRates/service/DolarApi/DolarServiceImpl.java @@ -2,14 +2,12 @@ import com.app.ExchangeRates.model.DolarApi.Money; import com.app.ExchangeRates.service.util.ApiUtil; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.*; import org.springframework.stereotype.Service; @Service -@Slf4j public class DolarServiceImpl implements DolarService { @Value("${apidolar.base-url}") String baseUrl; @@ -19,63 +17,64 @@ public class DolarServiceImpl implements DolarService { public Money getOfficialDollar() { String uri = baseUrl+"/dolares/oficial"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getBlueDollar() { String uri = baseUrl+"/dolares/blue"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getCCLDollar() { String uri = baseUrl+"/dolares/contadoconliqui"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getDollarCard() { String uri = baseUrl+"/dolares/tarjeta"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getStockMarketDollar() { String uri = baseUrl+"/dolares/bolsa"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getSolidarityDollar() { String uri = baseUrl+"/dolares/solidario"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getWholesaleDollar() { String uri = baseUrl+"/dolares/mayorista"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); + } + + @Override + public Money getCryptoDollar() { + String uri = baseUrl+"/dolares/cripto"; + return apiUtil + .buildApiDolarDTO( + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } } diff --git a/src/main/java/com/app/ExchangeRates/service/DolarApi/OtherCurrenciesServiceImpl.java b/src/main/java/com/app/ExchangeRates/service/DolarApi/OtherCurrenciesServiceImpl.java index aeec692..968b9b0 100644 --- a/src/main/java/com/app/ExchangeRates/service/DolarApi/OtherCurrenciesServiceImpl.java +++ b/src/main/java/com/app/ExchangeRates/service/DolarApi/OtherCurrenciesServiceImpl.java @@ -19,37 +19,33 @@ public class OtherCurrenciesServiceImpl implements OtherCurrenciesService { @Override public Money getEuro() { String uri = baseUrl+"/cotizaciones/eur"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getBrazilianReal() { String uri = baseUrl+"/cotizaciones/brl"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getChileanPeso() { String uri = baseUrl+"/cotizaciones/clp"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); } @Override public Money getUruguayanPeso() { String uri = baseUrl+"/cotizaciones/uyu"; - HttpHeaders headers = new HttpHeaders(); return apiUtil .buildApiDolarDTO( - apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(headers),Money.class)); + apiUtil.buildExchange(uri,HttpMethod.GET,new HttpEntity<>(null),Money.class)); }