You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: notifications_controller.rb
    path of file: ./repos/diaspora/app/controllers/api/v1
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Api
  module V1
    class NotificationsController < Api::V1::Base
    
      def index
        after_date = Date.iso8601(params[:only_after]) if params.has_key?(:only_after)

        notifications_query = service.index(BOOLEAN_TYPE.cast(params[:only_unread]), after_date)
        notifications_page = time_pager(notifications_query).response
        notifications_page[:data] = notifications_page[:data].map do |note|
          NotificationPresenter.new(note, default_serializer_options).as_api_json
        end
        render_paged_api_response notifications_page
      rescue ArgumentError
        render_error 422, "Could not process the notifications request"
      end