<commit_before>module BoxView
  # Provides access to the BoxView Session API. The Session API is used to
  # to create sessions for specific documents that can be used to view a
  # document using a specific session-based URL.
  class Session
    # The Session API path relative to the base API path
    @@path = '/sessions'

    # The relative path to view a document
    @@view_path = '/view'

    # parameters of view a document
    @@view_param_theme = 'theme='

    # Set the path
    def self.path=(path)
      @@path = path
    end

    # Get the path
    def self.path
      @@path
    end

    # Set the view path
    def self.view_path=(view_path)
      @@view_path = view_path
    end

    # Get the view path
    def self.view_path
      @@view_path
    end

    # Set the view parameter theme
    def self.view_param_theme=(view_param_theme)
      @@view_param_theme = view_param_theme
    end

    # Get the view paramter theme
    def self.view_param_theme
      @@view_param_theme
    end

    # Create a session for a specific document by UUID that is optionally
    # editable and can use user ID and name info from your application,
    # can filter annotations, can grant admin permissions, can be
    # downloadable, can be copy-protected, and can prevent changes from being
    # persisted.
    #
    # @param [String] id The ID of the file to create a session for
    # @param [Hash<String,>] params A hash representing:
    #   [Boolean] 'is_editable' Can users create annotations and comments while
    #     viewing the document with this session key?
    #   [Hash<String, String>] 'user' A hash with keys "id" and "name"
    #     representing a user's unique ID and name in your application; "id"
    #     must be a non-negative signed 32-bit integer; this field is required
    #     if is_editable is true
    #   [String, Array<String>] 'filter' Which annotations should be included
    #     if any - this is usually a string, but could also be an array if it's
    #     a comma-separated list of user IDs as the filter
    #   [Boolean] 'is_admin' Can users modify or delete any annotations or comments
    #     belonging to other users?
    #   [Boolean] 'is_downloadable' Can users download the original document?
    #   [Boolean] 'is_copyprotected' Can text be selected in the document?
    #   [Boolean] 'is_demo' Should we prevent any changes from being persisted?
    #   [String] 'sidebar' Sets if and how the viewer sidebar is included
    #
    # @return [String] A unique session key for the document
    # @raise [CrocodocError]
    def self.create(id, params = {})
      post_params = {document_id: id}

      if params.has_key? 'duration'
        post_params['duration'] = params['duration']
      end

      if params.has_key? 'expires_at'
        post_params['expires_at'] = params['expires_at']
      end

      session = BoxView._request(self.path, 'post', nil, post_params)

      unless session.is_a? Hash and session.has_key? 'id'
        return BoxView._error('missing_session_key', self.name, __method__, session)
      end

      session['id']
    end

    # Get the url to view a specific document with a generated session.
    #
    # @param [String] session_id The id of session generated by self.create
    # @param [String] theme Whether 'light' or 'dark'
    #
    # @return [String] A url to view the document
    def self.view_url(session_id, theme = 'light')
      session_url = BoxView.protocol + '://' + BoxView.host + BoxView.base_path + self.path + '/' + session_id
      session_url + self.view_path + '?' + self.view_param_theme + theme
    end
  end
end<commit_msg>Support is_downloadable post param.<commit_after>module BoxView
  # Provides access to the BoxView Session API. The Session API is used to
  # to create sessions for specific documents that can be used to view a
  # document using a specific session-based URL.
  class Session
    # The Session API path relative to the base API path
    @@path = '/sessions'

    # The relative path to view a document
    @@view_path = '/view'

    # parameters of view a document
    @@view_param_theme = 'theme='

    # Set the path
    def self.path=(path)
      @@path = path
    end

    # Get the path
    def self.path
      @@path
    end

    # Set the view path
    def self.view_path=(view_path)
      @@view_path = view_path
    end

    # Get the view path
    def self.view_path
      @@view_path
    end

    # Set the view parameter theme
    def self.view_param_theme=(view_param_theme)
      @@view_param_theme = view_param_theme
    end

    # Get the view paramter theme
    def self.view_param_theme
      @@view_param_theme
    end

    # Create a session for a specific document by UUID that is optionally
    # editable and can use user ID and name info from your application,
    # can filter annotations, can grant admin permissions, can be
    # downloadable, can be copy-protected, and can prevent changes from being
    # persisted.
    #
    # @param [String] id The ID of the file to create a session for
    # @param [Hash<String,>] params A hash representing:
    #   [Boolean] 'is_editable' Can users create annotations and comments while
    #     viewing the document with this session key?
    #   [Hash<String, String>] 'user' A hash with keys "id" and "name"
    #     representing a user's unique ID and name in your application; "id"
    #     must be a non-negative signed 32-bit integer; this field is required
    #     if is_editable is true
    #   [String, Array<String>] 'filter' Which annotations should be included
    #     if any - this is usually a string, but could also be an array if it's
    #     a comma-separated list of user IDs as the filter
    #   [Boolean] 'is_admin' Can users modify or delete any annotations or comments
    #     belonging to other users?
    #   [Boolean] 'is_downloadable' Can users download the original document?
    #   [Boolean] 'is_copyprotected' Can text be selected in the document?
    #   [Boolean] 'is_demo' Should we prevent any changes from being persisted?
    #   [String] 'sidebar' Sets if and how the viewer sidebar is included
    #
    # @return [String] A unique session key for the document
    # @raise [CrocodocError]
    def self.create(id, params = {})
      post_params = {document_id: id}

      if params.has_key? 'duration'
        post_params['duration'] = params['duration']
      end

      if params.has_key? 'expires_at'
        post_params['expires_at'] = params['expires_at']
      end

      if params.has_key? 'is_downloadable'
        post_params['is_downloadable'] = params['is_downloadable'] ? 'true' : 'false'
      end

      if params.has_key? 'is_text_selectable'
        post_params['is_text_selectable'] = params['is_text_selectable'] ? 'true' : 'false'
      end

      session = BoxView._request(self.path, 'post', nil, post_params)

      unless session.is_a? Hash and session.has_key? 'id'
        return BoxView._error('missing_session_key', self.name, __method__, session)
      end

      session['id']
    end

    # Get the url to view a specific document with a generated session.
    #
    # @param [String] session_id The id of session generated by self.create
    # @param [String] theme Whether 'light' or 'dark'
    #
    # @return [String] A url to view the document
    def self.view_url(session_id, theme = 'light')
      session_url = BoxView.protocol + '://' + BoxView.host + BoxView.base_path + self.path + '/' + session_id
      session_url + self.view_path + '?' + self.view_param_theme + theme
    end
  end
end
{'fraction_non_alphanumeric': 0.08281764318630679, 'fraction_numerical': 0.0005266622778143515, 'mean_word_length': 2.8113396889111892, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3064694', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2182, 'n_words': 852}