Sha256: b4421be4de8bf02f616329d096f0c37466da8ffd68f07fb8515b9b755569b632

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module Vzaar
  module Request
    class Signature < Base
      endpoint "/api/v1.1/videos/signature"
      authenticated true
      resource :signature

      private

      def ensure_valid_params!
        if !options.has_key?(:path) && !options.has_key?(:url)
          raise Vzaar::Error, "Path or url parameter required to generate signature."
        end
      end

      def url_params
        ensure_valid_params!
        _params = { multipart: 'true' }

        if options[:path]
          _params[:filename] = File.basename(options[:path])
          _params[:filesize] = File::Stat.new(options[:path]).size
          _params[:uploader] = "Ruby #{VERSION}"
        end
        if options[:success_action_redirect]
          _params[:success_action_redirect] = options[:success_action_redirect]
        end
        if options[:include_metadata]
          _params[:include_metadata] = 'yes'
        end
        if options[:flash_request]
          _params[:flash_request] = 'yes'
        end

        super.merge(_params)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vzaar-1.6.2 lib/vzaar/request/signature.rb