public function addRating(int $type, int $itemId, int $rating): UserRatingsDataNoLinks
    {
        if (!in_array($type, self::$ratingTypes, true)) {
            throw new InvalidArgumentException(
                'Invalid rating type, use one of these instead: ' . implode(self::$ratingTypes, ', ')
            );
        }

        try {
            $json = $this->client->performApiCallWithJsonResponse(
                'put',
                sprintf(
                    'user/ratings/%s/%d/%d',
                    $type,
                    (int) $itemId,
                    (int) $rating
                ),
                [
                    'http_errors' => true
                ]
            );
        } catch (ClientException $e) {
            $message = $this->getApiErrorMessage($e->getResponse());

            if ($message !== '') {
                throw CouldNotAddOrUpdateUserRatingException::reason($message);
            }

            throw CouldNotAddOrUpdateUserRatingException::reason($e->getMessage());
        }

        return ResponseHandler::create($json, ResponseHandler::METHOD_USER_RATINGS_ADD)->handle();
    }
public function addRating(int $type, int $itemId, int $rating): UserRatingsDataNoLinks
    {
        if (!in_array($type, self::$ratingTypes, true)) {
            throw new InvalidArgumentException(
                'Invalid rating type, use one of these instead: ' . implode(self::$ratingTypes, ', ')
            );
        }

        try {
            $json = $this->client->performApiCallWithJsonResponse(
                'put',
                sprintf(
                    'user/ratings/%s/%d/%d',
                    $type,
                    (int) $itemId,
                    (int) $rating
                ),
                [
                    'http_errors' => true
                ]
            );
        } catch (ClientException $e) {
            $message = $this->getApiErrorMessage($e->getResponse());

            if ($message !== '') {
                throw CouldNotAddOrUpdateUserRatingException::reason($message);
            }

            throw CouldNotAddOrUpdateUserRatingException::reason($e->getMessage());
        }

        return ResponseHandler::create($json, ResponseHandler::METHOD_USER_RATINGS_ADD)->handle();
    }
public function addRating ( int $ type , int $ itemId , int $ rating ) : UserRatingsDataNoLinks { if ( ! in_array ( $ type , self :: $ ratingTypes , true ) ) { throw new InvalidArgumentException ( 'Invalid rating type, use one of these instead: ' . implode ( self :: $ ratingTypes , ', ' ) ) ; } try { $ json = $ this -> client -> performApiCallWithJsonResponse ( 'put' , sprintf ( 'user/ratings/%s/%d/%d' , $ type , ( int ) $ itemId , ( int ) $ rating ) , [ 'http_errors' => true ] ) ; } catch ( ClientException $ e ) { $ message = $ this -> getApiErrorMessage ( $ e -> getResponse ( ) ) ; if ( $ message !== '' ) { throw CouldNotAddOrUpdateUserRatingException :: reason ( $ message ) ; } throw CouldNotAddOrUpdateUserRatingException :: reason ( $ e -> getMessage ( ) ) ; } return ResponseHandler :: create ( $ json , ResponseHandler :: METHOD_USER_RATINGS_ADD ) -> handle ( ) ; }
Add user rating.

@param int $type Use class constants UsersExtension::RATING_TYPE_*
@param int $itemId
@param int $rating Value between 1 and 10
@return UserRatingsDataNoLinks
@throws RequestFailedException
@throws UnauthorizedException
@throws InvalidArgumentException
@throws InvalidJsonInResponseException
Add user rating .