=begin
#Files

#Upload and manage files.

The version of the OpenAPI document: v3

Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1

=end

require 'cgi'

module Hubspot
  module Files
    class FilesApi
      attr_accessor :api_client

      def initialize(api_client = ApiClient.default)
        @api_client = api_client
      end
      # Delete file by ID
      # Delete a file by ID
      # @param file_id [String] FileId to delete
      # @param [Hash] opts the optional parameters
      # @return [nil]
      def archive(file_id, opts = {})
        archive_with_http_info(file_id, opts)
        nil
      end

      # Delete file by ID
      # Delete a file by ID
      # @param file_id [String] FileId to delete
      # @param [Hash] opts the optional parameters
      # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
      def archive_with_http_info(file_id, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.archive ...'
        end
        # verify the required parameter 'file_id' is set
        if @api_client.config.client_side_validation && file_id.nil?
          fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.archive"
        end
        pattern = Regexp.new(/\d+/)
        if @api_client.config.client_side_validation && file_id !~ pattern
          fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.archive, must conform to the pattern #{pattern}."
        end

        # resource path
        local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

        # query parameters
        query_params = opts[:query_params] || {}

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['*/*'])

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type]

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.archive",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Check import status
      # Check the status of requested import.
      # @param task_id [String] Import by URL task ID
      # @param [Hash] opts the optional parameters
      # @return [FileActionResponse]
      def check_import(task_id, opts = {})
        data, _status_code, _headers = check_import_with_http_info(task_id, opts)
        data
      end

      # Check import status
      # Check the status of requested import.
      # @param task_id [String] Import by URL task ID
      # @param [Hash] opts the optional parameters
      # @return [Array<(FileActionResponse, Integer, Hash)>] FileActionResponse data, response status code and response headers
      def check_import_with_http_info(task_id, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.check_import ...'
        end
        # verify the required parameter 'task_id' is set
        if @api_client.config.client_side_validation && task_id.nil?
          fail ArgumentError, "Missing the required parameter 'task_id' when calling FilesApi.check_import"
        end
        # resource path
        local_var_path = '/files/v3/files/import-from-url/async/tasks/{taskId}/status'.sub('{' + 'taskId' + '}', CGI.escape(task_id.to_s))

        # query parameters
        query_params = opts[:query_params] || {}

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type] || 'FileActionResponse'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.check_import",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#check_import\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # GDPR-delete file
      # Delete a file in accordance with GDPR regulations.
      # @param file_id [String] ID of file to GDPR delete
      # @param [Hash] opts the optional parameters
      # @return [nil]
      def delete(file_id, opts = {})
        delete_with_http_info(file_id, opts)
        nil
      end

      # GDPR-delete file
      # Delete a file in accordance with GDPR regulations.
      # @param file_id [String] ID of file to GDPR delete
      # @param [Hash] opts the optional parameters
      # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
      def delete_with_http_info(file_id, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.delete ...'
        end
        # verify the required parameter 'file_id' is set
        if @api_client.config.client_side_validation && file_id.nil?
          fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.delete"
        end
        pattern = Regexp.new(/\d+/)
        if @api_client.config.client_side_validation && file_id !~ pattern
          fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.delete, must conform to the pattern #{pattern}."
        end

        # resource path
        local_var_path = '/files/v3/files/{fileId}/gdpr-delete'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

        # query parameters
        query_params = opts[:query_params] || {}

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['*/*'])

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type]

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.delete",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Search files
      # Search through files in the file manager. Does not display hidden or archived files.
      # @param [Hash] opts the optional parameters
      # @option opts [Array<String>] :properties A list of file properties to return.
      # @option opts [String] :after Offset search results by this value. The default offset is 0 and the maximum offset of items for a given search is 10,000. Narrow your search down if you are reaching this limit.
      # @option opts [String] :before 
      # @option opts [Integer] :limit Number of items to return. Default limit is 10, maximum limit is 100.
      # @option opts [Array<String>] :sort Sort files by a given field.
      # @option opts [Array<Integer>] :ids Search by a list of file IDs.
      # @option opts [Integer] :id_lte 
      # @option opts [Integer] :id_gte 
      # @option opts [Time] :created_at Search files by time of creation.
      # @option opts [Time] :created_at_lte Search files by less than or equal to time of creation. Can be used with &#x60;createdAtGte&#x60; to create a range.
      # @option opts [Time] :created_at_gte Search files by greater than or equal to time of creation. Can be used with &#x60;createdAtLte&#x60; to create a range.
      # @option opts [Time] :updated_at Search files by time of latest updated.
      # @option opts [Time] :updated_at_lte Search files by less than or equal to time of latest update. Can be used with &#x60;updatedAtGte&#x60; to create a range.
      # @option opts [Time] :updated_at_gte Search files by greater than or equal to time of latest update. Can be used with &#x60;updatedAtLte&#x60; to create a range.
      # @option opts [String] :name Search for files containing the given name.
      # @option opts [String] :path Search files by path.
      # @option opts [Array<Integer>] :parent_folder_ids Search files within given &#x60;folderId&#x60;.
      # @option opts [Integer] :size Search files by exact file size in bytes.
      # @option opts [Integer] :size_lte Search files by less than or equal to file size. Can be used with &#x60;sizeGte&#x60; to create a range.
      # @option opts [Integer] :size_gte Search files by greater than or equal to file size. Can be used with &#x60;sizeLte&#x60; to create a range.
      # @option opts [Integer] :height Search files by height of image or video.
      # @option opts [Integer] :height_lte Search files by less than or equal to height of image or video. Can be used with &#x60;heightGte&#x60; to create a range.
      # @option opts [Integer] :height_gte Search files by greater than or equal to height of image or video. Can be used with &#x60;heightLte&#x60; to create a range.
      # @option opts [Integer] :width Search files by width of image or video.
      # @option opts [Integer] :width_lte Search files by less than or equal to width of image or video. Can be used with &#x60;widthGte&#x60; to create a range.
      # @option opts [Integer] :width_gte Search files by greater than or equal to width of image or video. Can be used with &#x60;widthLte&#x60; to create a range.
      # @option opts [String] :encoding Search files by specified encoding.
      # @option opts [String] :type Filter by provided file type.
      # @option opts [String] :extension Search files by given extension.
      # @option opts [String] :url Search by file URL.
      # @option opts [Boolean] :is_usable_in_content If &#x60;true&#x60;, shows files that have been marked to be used in new content. If &#x60;false&#x60;, shows files that should not be used in new content.
      # @option opts [Boolean] :allows_anonymous_access Search files by access. If &#x60;true&#x60;, will show only public files. If &#x60;false&#x60;, will show only private files.
      # @option opts [String] :file_md5 Search files by a specific md5 hash.
      # @option opts [Time] :expires_at Search files by exact expires time. Time must be epoch time in milliseconds.
      # @option opts [Time] :expires_at_lte Search files by less than or equal to expires time. Can be used with &#x60;expiresAtGte&#x60; to create a range.
      # @option opts [Time] :expires_at_gte Search files by greater than or equal to expires time. Can be used with &#x60;expiresAtLte&#x60; to create a range.
      # @return [CollectionResponseFile]
      def do_search(opts = {})
        data, _status_code, _headers = do_search_with_http_info(opts)
        data
      end

      # Search files
      # Search through files in the file manager. Does not display hidden or archived files.
      # @param [Hash] opts the optional parameters
      # @option opts [Array<String>] :properties A list of file properties to return.
      # @option opts [String] :after Offset search results by this value. The default offset is 0 and the maximum offset of items for a given search is 10,000. Narrow your search down if you are reaching this limit.
      # @option opts [String] :before 
      # @option opts [Integer] :limit Number of items to return. Default limit is 10, maximum limit is 100.
      # @option opts [Array<String>] :sort Sort files by a given field.
      # @option opts [Array<Integer>] :ids Search by a list of file IDs.
      # @option opts [Integer] :id_lte 
      # @option opts [Integer] :id_gte 
      # @option opts [Time] :created_at Search files by time of creation.
      # @option opts [Time] :created_at_lte Search files by less than or equal to time of creation. Can be used with &#x60;createdAtGte&#x60; to create a range.
      # @option opts [Time] :created_at_gte Search files by greater than or equal to time of creation. Can be used with &#x60;createdAtLte&#x60; to create a range.
      # @option opts [Time] :updated_at Search files by time of latest updated.
      # @option opts [Time] :updated_at_lte Search files by less than or equal to time of latest update. Can be used with &#x60;updatedAtGte&#x60; to create a range.
      # @option opts [Time] :updated_at_gte Search files by greater than or equal to time of latest update. Can be used with &#x60;updatedAtLte&#x60; to create a range.
      # @option opts [String] :name Search for files containing the given name.
      # @option opts [String] :path Search files by path.
      # @option opts [Array<Integer>] :parent_folder_ids Search files within given &#x60;folderId&#x60;.
      # @option opts [Integer] :size Search files by exact file size in bytes.
      # @option opts [Integer] :size_lte Search files by less than or equal to file size. Can be used with &#x60;sizeGte&#x60; to create a range.
      # @option opts [Integer] :size_gte Search files by greater than or equal to file size. Can be used with &#x60;sizeLte&#x60; to create a range.
      # @option opts [Integer] :height Search files by height of image or video.
      # @option opts [Integer] :height_lte Search files by less than or equal to height of image or video. Can be used with &#x60;heightGte&#x60; to create a range.
      # @option opts [Integer] :height_gte Search files by greater than or equal to height of image or video. Can be used with &#x60;heightLte&#x60; to create a range.
      # @option opts [Integer] :width Search files by width of image or video.
      # @option opts [Integer] :width_lte Search files by less than or equal to width of image or video. Can be used with &#x60;widthGte&#x60; to create a range.
      # @option opts [Integer] :width_gte Search files by greater than or equal to width of image or video. Can be used with &#x60;widthLte&#x60; to create a range.
      # @option opts [String] :encoding Search files by specified encoding.
      # @option opts [String] :type Filter by provided file type.
      # @option opts [String] :extension Search files by given extension.
      # @option opts [String] :url Search by file URL.
      # @option opts [Boolean] :is_usable_in_content If &#x60;true&#x60;, shows files that have been marked to be used in new content. If &#x60;false&#x60;, shows files that should not be used in new content.
      # @option opts [Boolean] :allows_anonymous_access Search files by access. If &#x60;true&#x60;, will show only public files. If &#x60;false&#x60;, will show only private files.
      # @option opts [String] :file_md5 Search files by a specific md5 hash.
      # @option opts [Time] :expires_at Search files by exact expires time. Time must be epoch time in milliseconds.
      # @option opts [Time] :expires_at_lte Search files by less than or equal to expires time. Can be used with &#x60;expiresAtGte&#x60; to create a range.
      # @option opts [Time] :expires_at_gte Search files by greater than or equal to expires time. Can be used with &#x60;expiresAtLte&#x60; to create a range.
      # @return [Array<(CollectionResponseFile, Integer, Hash)>] CollectionResponseFile data, response status code and response headers
      def do_search_with_http_info(opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.do_search ...'
        end
        # resource path
        local_var_path = '/files/v3/files/search'

        # query parameters
        query_params = opts[:query_params] || {}
        query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?
        query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
        query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?
        query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
        query_params[:'sort'] = @api_client.build_collection_param(opts[:'sort'], :multi) if !opts[:'sort'].nil?
        query_params[:'ids'] = @api_client.build_collection_param(opts[:'ids'], :multi) if !opts[:'ids'].nil?
        query_params[:'idLte'] = opts[:'id_lte'] if !opts[:'id_lte'].nil?
        query_params[:'idGte'] = opts[:'id_gte'] if !opts[:'id_gte'].nil?
        query_params[:'createdAt'] = opts[:'created_at'] if !opts[:'created_at'].nil?
        query_params[:'createdAtLte'] = opts[:'created_at_lte'] if !opts[:'created_at_lte'].nil?
        query_params[:'createdAtGte'] = opts[:'created_at_gte'] if !opts[:'created_at_gte'].nil?
        query_params[:'updatedAt'] = opts[:'updated_at'] if !opts[:'updated_at'].nil?
        query_params[:'updatedAtLte'] = opts[:'updated_at_lte'] if !opts[:'updated_at_lte'].nil?
        query_params[:'updatedAtGte'] = opts[:'updated_at_gte'] if !opts[:'updated_at_gte'].nil?
        query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
        query_params[:'path'] = opts[:'path'] if !opts[:'path'].nil?
        query_params[:'parentFolderIds'] = @api_client.build_collection_param(opts[:'parent_folder_ids'], :multi) if !opts[:'parent_folder_ids'].nil?
        query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
        query_params[:'sizeLte'] = opts[:'size_lte'] if !opts[:'size_lte'].nil?
        query_params[:'sizeGte'] = opts[:'size_gte'] if !opts[:'size_gte'].nil?
        query_params[:'height'] = opts[:'height'] if !opts[:'height'].nil?
        query_params[:'heightLte'] = opts[:'height_lte'] if !opts[:'height_lte'].nil?
        query_params[:'heightGte'] = opts[:'height_gte'] if !opts[:'height_gte'].nil?
        query_params[:'width'] = opts[:'width'] if !opts[:'width'].nil?
        query_params[:'widthLte'] = opts[:'width_lte'] if !opts[:'width_lte'].nil?
        query_params[:'widthGte'] = opts[:'width_gte'] if !opts[:'width_gte'].nil?
        query_params[:'encoding'] = opts[:'encoding'] if !opts[:'encoding'].nil?
        query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
        query_params[:'extension'] = opts[:'extension'] if !opts[:'extension'].nil?
        query_params[:'url'] = opts[:'url'] if !opts[:'url'].nil?
        query_params[:'isUsableInContent'] = opts[:'is_usable_in_content'] if !opts[:'is_usable_in_content'].nil?
        query_params[:'allowsAnonymousAccess'] = opts[:'allows_anonymous_access'] if !opts[:'allows_anonymous_access'].nil?
        query_params[:'fileMd5'] = opts[:'file_md5'] if !opts[:'file_md5'].nil?
        query_params[:'expiresAt'] = opts[:'expires_at'] if !opts[:'expires_at'].nil?
        query_params[:'expiresAtLte'] = opts[:'expires_at_lte'] if !opts[:'expires_at_lte'].nil?
        query_params[:'expiresAtGte'] = opts[:'expires_at_gte'] if !opts[:'expires_at_gte'].nil?

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type] || 'CollectionResponseFile'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.do_search",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#do_search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Retrieve file by ID
      # Retrieve a file by its ID.
      # @param file_id [String] ID of the desired file.
      # @param [Hash] opts the optional parameters
      # @option opts [Array<String>] :properties null
      # @return [File]
      def get_by_id(file_id, opts = {})
        data, _status_code, _headers = get_by_id_with_http_info(file_id, opts)
        data
      end

      # Retrieve file by ID
      # Retrieve a file by its ID.
      # @param file_id [String] ID of the desired file.
      # @param [Hash] opts the optional parameters
      # @option opts [Array<String>] :properties null
      # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
      def get_by_id_with_http_info(file_id, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.get_by_id ...'
        end
        # verify the required parameter 'file_id' is set
        if @api_client.config.client_side_validation && file_id.nil?
          fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.get_by_id"
        end
        pattern = Regexp.new(/\d+/)
        if @api_client.config.client_side_validation && file_id !~ pattern
          fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.get_by_id, must conform to the pattern #{pattern}."
        end

        # resource path
        local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

        # query parameters
        query_params = opts[:query_params] || {}
        query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type] || 'File'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.get_by_id",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Retrieve file by path
      # Retrieve a file by its path.
      # @param path [String] The path of the file. 
      # @param [Hash] opts the optional parameters
      # @option opts [Array<String>] :properties Properties to return in the response.
      # @return [FileStat]
      def get_metadata(path, opts = {})
        data, _status_code, _headers = get_metadata_with_http_info(path, opts)
        data
      end

      # Retrieve file by path
      # Retrieve a file by its path.
      # @param path [String] The path of the file. 
      # @param [Hash] opts the optional parameters
      # @option opts [Array<String>] :properties Properties to return in the response.
      # @return [Array<(FileStat, Integer, Hash)>] FileStat data, response status code and response headers
      def get_metadata_with_http_info(path, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.get_metadata ...'
        end
        # verify the required parameter 'path' is set
        if @api_client.config.client_side_validation && path.nil?
          fail ArgumentError, "Missing the required parameter 'path' when calling FilesApi.get_metadata"
        end
        pattern = Regexp.new(/.+/)
        if @api_client.config.client_side_validation && path !~ pattern
          fail ArgumentError, "invalid value for 'path' when calling FilesApi.get_metadata, must conform to the pattern #{pattern}."
        end

        # resource path
        local_var_path = '/files/v3/files/stat/{path}'.sub('{' + 'path' + '}', CGI.escape(path.to_s))

        # query parameters
        query_params = opts[:query_params] || {}
        query_params[:'properties'] = @api_client.build_collection_param(opts[:'properties'], :csv) if !opts[:'properties'].nil?

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type] || 'FileStat'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.get_metadata",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#get_metadata\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Get signed URL to access private file
      # Generates signed URL that allows temporary access to a private file.
      # @param file_id [String] ID of file.
      # @param [Hash] opts the optional parameters
      # @option opts [String] :size For image files. This will resize the image to the desired size before sharing. Does not affect the original file, just the file served by this signed URL.
      # @option opts [Integer] :expiration_seconds How long in seconds the link will provide access to the file.
      # @option opts [Boolean] :upscale If size is provided, this will upscale the image to fit the size dimensions.
      # @return [SignedUrl]
      def get_signed_url(file_id, opts = {})
        data, _status_code, _headers = get_signed_url_with_http_info(file_id, opts)
        data
      end

      # Get signed URL to access private file
      # Generates signed URL that allows temporary access to a private file.
      # @param file_id [String] ID of file.
      # @param [Hash] opts the optional parameters
      # @option opts [String] :size For image files. This will resize the image to the desired size before sharing. Does not affect the original file, just the file served by this signed URL.
      # @option opts [Integer] :expiration_seconds How long in seconds the link will provide access to the file.
      # @option opts [Boolean] :upscale If size is provided, this will upscale the image to fit the size dimensions.
      # @return [Array<(SignedUrl, Integer, Hash)>] SignedUrl data, response status code and response headers
      def get_signed_url_with_http_info(file_id, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.get_signed_url ...'
        end
        # verify the required parameter 'file_id' is set
        if @api_client.config.client_side_validation && file_id.nil?
          fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.get_signed_url"
        end
        pattern = Regexp.new(/\d+/)
        if @api_client.config.client_side_validation && file_id !~ pattern
          fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.get_signed_url, must conform to the pattern #{pattern}."
        end

        allowable_values = ["thumb", "icon", "medium", "preview"]
        if @api_client.config.client_side_validation && opts[:'size'] && !allowable_values.include?(opts[:'size'])
          fail ArgumentError, "invalid value for \"size\", must be one of #{allowable_values}"
        end
        # resource path
        local_var_path = '/files/v3/files/{fileId}/signed-url'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

        # query parameters
        query_params = opts[:query_params] || {}
        query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
        query_params[:'expirationSeconds'] = opts[:'expiration_seconds'] if !opts[:'expiration_seconds'].nil?
        query_params[:'upscale'] = opts[:'upscale'] if !opts[:'upscale'].nil?

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type] || 'SignedUrl'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.get_signed_url",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#get_signed_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Import file from URL
      # Asynchronously imports the file at the given URL into the file manager.
      # @param import_from_url_input [ImportFromUrlInput] 
      # @param [Hash] opts the optional parameters
      # @return [ImportFromUrlTaskLocator]
      def import_from_url(import_from_url_input, opts = {})
        data, _status_code, _headers = import_from_url_with_http_info(import_from_url_input, opts)
        data
      end

      # Import file from URL
      # Asynchronously imports the file at the given URL into the file manager.
      # @param import_from_url_input [ImportFromUrlInput] 
      # @param [Hash] opts the optional parameters
      # @return [Array<(ImportFromUrlTaskLocator, Integer, Hash)>] ImportFromUrlTaskLocator data, response status code and response headers
      def import_from_url_with_http_info(import_from_url_input, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.import_from_url ...'
        end
        # verify the required parameter 'import_from_url_input' is set
        if @api_client.config.client_side_validation && import_from_url_input.nil?
          fail ArgumentError, "Missing the required parameter 'import_from_url_input' when calling FilesApi.import_from_url"
        end
        # resource path
        local_var_path = '/files/v3/files/import-from-url/async'

        # query parameters
        query_params = opts[:query_params] || {}

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
        # HTTP header 'Content-Type'
        content_type = @api_client.select_header_content_type(['application/json'])
        if !content_type.nil?
            header_params['Content-Type'] = content_type
        end

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body] || @api_client.object_to_http_body(import_from_url_input)

        # return_type
        return_type = opts[:debug_return_type] || 'ImportFromUrlTaskLocator'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.import_from_url",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#import_from_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Replace file
      # Replace existing file data with new file data. Can be used to change image content without having to upload a new file and update all references.
      # @param file_id [String] ID of the desired file.
      # @param [Hash] opts the optional parameters
      # @option opts [File] :file File data that will replace existing file in the file manager.
      # @option opts [String] :charset_hunch Character set of given file data.
      # @option opts [String] :options JSON string representing FileReplaceOptions. Includes options to set the access and expiresAt properties, which will automatically update when the file is replaced.
      # @return [File]
      def replace(file_id, opts = {})
        data, _status_code, _headers = replace_with_http_info(file_id, opts)
        data
      end

      # Replace file
      # Replace existing file data with new file data. Can be used to change image content without having to upload a new file and update all references.
      # @param file_id [String] ID of the desired file.
      # @param [Hash] opts the optional parameters
      # @option opts [File] :file File data that will replace existing file in the file manager.
      # @option opts [String] :charset_hunch Character set of given file data.
      # @option opts [String] :options JSON string representing FileReplaceOptions. Includes options to set the access and expiresAt properties, which will automatically update when the file is replaced.
      # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
      def replace_with_http_info(file_id, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.replace ...'
        end
        # verify the required parameter 'file_id' is set
        if @api_client.config.client_side_validation && file_id.nil?
          fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.replace"
        end
        pattern = Regexp.new(/\d+/)
        if @api_client.config.client_side_validation && file_id !~ pattern
          fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.replace, must conform to the pattern #{pattern}."
        end

        # resource path
        local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

        # query parameters
        query_params = opts[:query_params] || {}

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
        # HTTP header 'Content-Type'
        content_type = @api_client.select_header_content_type(['multipart/form-data'])
        if !content_type.nil?
            header_params['Content-Type'] = content_type
        end

        # form parameters
        form_params = opts[:form_params] || {}
        form_params['file'] = opts[:'file'] if !opts[:'file'].nil?
        form_params['charsetHunch'] = opts[:'charset_hunch'] if !opts[:'charset_hunch'].nil?
        form_params['options'] = opts[:'options'] if !opts[:'options'].nil?

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type] || 'File'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.replace",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#replace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Update file properties
      # Update properties of file by ID.
      # @param file_id [String] ID of file to update
      # @param file_update_input [FileUpdateInput] 
      # @param [Hash] opts the optional parameters
      # @return [File]
      def update_properties(file_id, file_update_input, opts = {})
        data, _status_code, _headers = update_properties_with_http_info(file_id, file_update_input, opts)
        data
      end

      # Update file properties
      # Update properties of file by ID.
      # @param file_id [String] ID of file to update
      # @param file_update_input [FileUpdateInput] 
      # @param [Hash] opts the optional parameters
      # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
      def update_properties_with_http_info(file_id, file_update_input, opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.update_properties ...'
        end
        # verify the required parameter 'file_id' is set
        if @api_client.config.client_side_validation && file_id.nil?
          fail ArgumentError, "Missing the required parameter 'file_id' when calling FilesApi.update_properties"
        end
        pattern = Regexp.new(/\d+/)
        if @api_client.config.client_side_validation && file_id !~ pattern
          fail ArgumentError, "invalid value for 'file_id' when calling FilesApi.update_properties, must conform to the pattern #{pattern}."
        end

        # verify the required parameter 'file_update_input' is set
        if @api_client.config.client_side_validation && file_update_input.nil?
          fail ArgumentError, "Missing the required parameter 'file_update_input' when calling FilesApi.update_properties"
        end
        # resource path
        local_var_path = '/files/v3/files/{fileId}'.sub('{' + 'fileId' + '}', CGI.escape(file_id.to_s))

        # query parameters
        query_params = opts[:query_params] || {}

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
        # HTTP header 'Content-Type'
        content_type = @api_client.select_header_content_type(['application/json'])
        if !content_type.nil?
            header_params['Content-Type'] = content_type
        end

        # form parameters
        form_params = opts[:form_params] || {}

        # http body (model)
        post_body = opts[:debug_body] || @api_client.object_to_http_body(file_update_input)

        # return_type
        return_type = opts[:debug_return_type] || 'File'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.update_properties",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#update_properties\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end

      # Upload file
      # Upload a single file with content specified in request body.
      # @param [Hash] opts the optional parameters
      # @option opts [File] :file File to be uploaded.
      # @option opts [String] :folder_id Either &#39;folderId&#39; or &#39;folderPath&#39; is required. folderId is the ID of the folder the file will be uploaded to.
      # @option opts [String] :folder_path Either &#39;folderPath&#39; or &#39;folderId&#39; is required. This field represents the destination folder path for the uploaded file. If a path doesn&#39;t exist, the system will try to create one.
      # @option opts [String] :file_name Desired name for the uploaded file.
      # @option opts [String] :charset_hunch Character set of the uploaded file.
      # @option opts [String] :options JSON string representing FileUploadOptions.
      # @return [File]
      def upload(opts = {})
        data, _status_code, _headers = upload_with_http_info(opts)
        data
      end

      # Upload file
      # Upload a single file with content specified in request body.
      # @param [Hash] opts the optional parameters
      # @option opts [File] :file File to be uploaded.
      # @option opts [String] :folder_id Either &#39;folderId&#39; or &#39;folderPath&#39; is required. folderId is the ID of the folder the file will be uploaded to.
      # @option opts [String] :folder_path Either &#39;folderPath&#39; or &#39;folderId&#39; is required. This field represents the destination folder path for the uploaded file. If a path doesn&#39;t exist, the system will try to create one.
      # @option opts [String] :file_name Desired name for the uploaded file.
      # @option opts [String] :charset_hunch Character set of the uploaded file.
      # @option opts [String] :options JSON string representing FileUploadOptions.
      # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers
      def upload_with_http_info(opts = {})
        if @api_client.config.debugging
          @api_client.config.logger.debug 'Calling API: FilesApi.upload ...'
        end
        # resource path
        local_var_path = '/files/v3/files'

        # query parameters
        query_params = opts[:query_params] || {}

        # header parameters
        header_params = opts[:header_params] || {}
        # HTTP header 'Accept' (if needed)
        header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])
        # HTTP header 'Content-Type'
        content_type = @api_client.select_header_content_type(['multipart/form-data'])
        if !content_type.nil?
            header_params['Content-Type'] = content_type
        end

        # form parameters
        form_params = opts[:form_params] || {}
        form_params['file'] = opts[:'file'] if !opts[:'file'].nil?
        form_params['folderId'] = opts[:'folder_id'] if !opts[:'folder_id'].nil?
        form_params['folderPath'] = opts[:'folder_path'] if !opts[:'folder_path'].nil?
        form_params['fileName'] = opts[:'file_name'] if !opts[:'file_name'].nil?
        form_params['charsetHunch'] = opts[:'charset_hunch'] if !opts[:'charset_hunch'].nil?
        form_params['options'] = opts[:'options'] if !opts[:'options'].nil?

        # http body (model)
        post_body = opts[:debug_body]

        # return_type
        return_type = opts[:debug_return_type] || 'File'

        # auth_names
        auth_names = opts[:debug_auth_names] || ['oauth2']

        new_options = opts.merge(
          :operation => :"FilesApi.upload",
          :header_params => header_params,
          :query_params => query_params,
          :form_params => form_params,
          :body => post_body,
          :auth_names => auth_names,
          :return_type => return_type
        )

        data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
        if @api_client.config.debugging
          @api_client.config.logger.debug "API called: FilesApi#upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
        end
        return data, status_code, headers
      end
    end
  end
end
