package de.szut.casino.user.transaction;

import de.szut.casino.user.transaction.dto.UserTransactionsDto;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TransactionController {

    private final GetTransactionService transactionService;

    public TransactionController(GetTransactionService transactionService) {
        this.transactionService = transactionService;
    }

    @GetMapping("/user/transactions")
    public ResponseEntity<UserTransactionsDto> getUserTransactions(
            @RequestParam(value = "limit", required = false) Integer limit,
            @RequestParam(value = "offset", required = false) Integer offset
    ) {
        UserTransactionsDto transactionEntities = this.transactionService.getUserTransactionsDto(limit, offset);

        return ResponseEntity.ok(transactionEntities);
    }
}

