package de.szut.casino.user.transaction;

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

@RestController
public class TransactionController {

    @Autowired
    private GetTransactionService transactionService;

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

        return ResponseEntity.ok(transactionEntities);
    }
}

