package com.ikon.projectmanagement.controller;

import lombok.RequiredArgsConstructor;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import com.ikon.projectmanagement.api.FxRateApi;
import com.ikon.projectmanagement.dto.response.FxRateResponseDto;
import com.ikon.projectmanagement.service.FxRateService;

@RestController
@RequiredArgsConstructor
public class FxRateController implements FxRateApi {

    private final FxRateService fxRateService;

    @Override
    public ResponseEntity<Page<FxRateResponseDto>> getAllFxRates(
            @RequestHeader("Authorization") String accessToken,
            Pageable pageable) {
        return ResponseEntity.ok(fxRateService.getAllFxRates(pageable));
    }

    public ResponseEntity<FxRateResponseDto> getFxRateByYear(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable String year) {
        return ResponseEntity.ok(fxRateService.getFxRateByYear(year));
    }
}