Skip to content

Commit

Permalink
Modificaciones en DolarController y DolarService
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Marc0Franc0 committed Jan 8, 2024
1 parent 34bce50 commit 3675296
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ ResponseEntity<Money> getDollarCard(){
ResponseEntity<Money> 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<Money> getSolidarityDollar(){
return ResponseEntity.status(HttpStatus.OK).body(dolarService.getSolidarityDollar());
}
Expand All @@ -83,5 +84,14 @@ ResponseEntity<Money> getSolidarityDollar(){
ResponseEntity<Money> 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<Money> getCryptoollar(){
return ResponseEntity.status(HttpStatus.OK).body(dolarService.getCryptoDollar());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

@Builder
@AllArgsConstructor
@ToString
@Data
public class Quote {
@JsonProperty("c")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public interface DolarService {
Money getStockMarketDollar();
Money getSolidarityDollar();
Money getWholesaleDollar();
Money getCryptoDollar();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}


Expand Down

0 comments on commit 3675296

Please sign in to comment.