package ru.ibs.socrates.confexporter.controller;

import java.time.OffsetDateTime;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import ru.ibs.socrates.confexporter.api.ProjectApi;
import ru.ibs.socrates.confexporter.api.dto.ProjectContentResponse;
import ru.ibs.socrates.confexporter.api.dto.ProjectResponse;
import ru.ibs.socrates.confexporter.service.content.service.ProjectService;


/**
 * project контроллер.
 */
@RestController
@RequiredArgsConstructor
public class ProjectController implements ProjectApi {

  private final ProjectService projectService;

  @Override
  public ResponseEntity<ProjectResponse> getProjects(OffsetDateTime timestamp) {
    return ResponseEntity.ok(projectService.projectFromTimestamp(timestamp));
  }


  @Override
  public ResponseEntity<ProjectContentResponse> getProjectContent(String sourceId) {
    return ResponseEntity.ok(projectService.projectContent(sourceId));
  }
  
  @Override
  public ResponseEntity<ProjectContentResponse> getProjectContentFromDate(
      String sourceId, OffsetDateTime dateFrom) {
    return ResponseEntity.ok(projectService.getProjectContentFromDate(sourceId, dateFrom));
  }

}
