Sha256: 52bfac43d871bb0065e85ff9335d6470ec191563d4a8e79a8c1221704c4e80b3

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Uploadcare
  module Entity
    module Conversion
      # This serializer lets a user convert uploaded documents
      # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/documentConvert
      class BaseConverter < Entity
        class << self
          # Converts files
          #
          # @param doc_params [Array] of hashes with params or [Hash]
          # @option options [Boolean] :store whether to store file on servers.
          def convert(params, options = {})
            files_params = params.is_a?(Hash) ? [params] : params
            conversion_client.new.convert_many(files_params, options)
          end

          # Returns a status of a conversion job
          #
          # @param token [Integer, String] token obtained from a server in convert method
          def status(token)
            conversion_client.new.get_conversion_status(token)
          end

          private

          def conversion_client
            clients[:base]
          end
        end
      end
    end
  end
  include Conversion
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
uploadcare-ruby-4.4.0 lib/uploadcare/entity/conversion/base_converter.rb
uploadcare-ruby-4.3.6 lib/uploadcare/entity/conversion/base_converter.rb
uploadcare-ruby-4.3.5 lib/uploadcare/entity/conversion/base_converter.rb
uploadcare-ruby-4.3.4 lib/uploadcare/entity/conversion/base_converter.rb