import { composeUserRatingURL, initialUserRating, processUserRating } from '../../api/userRating'
import { UserRating, isUserRatingResponse } from '../../api/userRating/types'
import useFetch, { UseFetchReturn } from '../useFetch'

const useUserRating = (userId: number): UseFetchReturn<UserRating> => (
    useFetch(
        composeUserRatingURL(userId),
        'GET',
        false,
        isUserRatingResponse,
        processUserRating,
        initialUserRating
    )
)

export default useUserRating
