private function _downgrade_site() {
            $this->_logger->entrance();

            $deactivate_license = fs_request_get_bool( 'deactivate_license' );

            $api  = $this->get_api_site_scope();
            $site = $api->call( 'downgrade.json', 'put', array( 'deactivate_license' => $deactivate_license ) );

            $plan_downgraded = false;
            $plan            = false;
            if ( $this->is_api_result_entity( $site ) ) {
                $prev_plan_id = $this->_site->plan_id;

                // Update new site plan id.
                $this->_site->plan_id = $site->plan_id;

                $plan         = $this->get_plan();
                $subscription = $this->_sync_site_subscription( $this->_license );

                // Plan downgraded if plan was changed or subscription was cancelled.
                $plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) ||
                                   ( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() );
            } else {
                // handle different error cases.
                $this->handle_license_deactivation_result(
                    $site,
                    $this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...'
                );
            }

            if ( ! $plan_downgraded ) {
                return (object) array(
                    'error' => (object) array(
                        'message' => $this->get_text_inline( 'Seems like we are having some temporary issue with your subscription cancellation. Please try again in few minutes.', 'subscription-cancellation-failure-message' )
                    )
                );
            }

            // Remove previous sticky message about upgrade (if exist).
            $this->_admin_notices->remove_sticky( 'plan_upgraded' );

            $this->_admin_notices->add(
                sprintf( $this->get_text_inline( 'Your subscription was successfully cancelled. Your %s plan license will expire in %s.', 'plan-x-downgraded-message' ),
                    $plan->title,
                    human_time_diff( time(), strtotime( $this->_license->expiration ) )
                )
            );

            // Store site updates.
            $this->_store_site();

            if ( $deactivate_license &&
                 ! FS_Plugin_License::is_valid_id( $site->license_id )
            ) {
                if ( $this->_site->is_localhost() ) {
                    $this->_license->activated_local = max( 0, $this->_license->activated_local - 1 );
                } else {
                    $this->_license->activated = max( 0, $this->_license->activated - 1 );
                }

                // Handle successful license deactivation result.
                $this->handle_license_deactivation_result( $this->_license );
            }

            return $site;
        }