Sha256: 05ddb45b349b5874eeddcb381f02bc7068c9f5a716cdc00a310165e087552b88

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

module Vzaar
  module Request
    class ProcessVideo < Base
      endpoint '/api/v1.1/videos'
      authenticated true
      http_verb :post
      resource "ProcessedVideo"

      private

      def json_body
        get_opts.to_json
      end

      def xml_body
        request_xml = %{
          <?xml version="1.0" encoding="UTF-8"?>
          #{hash_to_xml(get_opts)}
        }

        request_xml
      end

      def get_opts
        raise Vzaar::Error, "Guid required to process video." unless options[:guid]

        h = options.dup.delete_if { |k,v| v.nil? }
        [:description, :title, :labels].each do|k|
          sanitized_val = sanitize_str(h[k])
          h[k] = sanitized_val unless blank?(sanitized_val)
        end

        if include_encoding_options?
          width = h.delete(:width)
          bitrate = h.delete(:bitrate)

          h[:encoding] = {width: width, bitrate: bitrate}
        end

        { vzaar_api: {
            video: h
          }
        }
      end

      def include_encoding_options?
        options[:profile] == 6 && options[:width] && options[:bitrate]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vzaar-1.6.2 lib/vzaar/request/process_video.rb
vzaar-1.6.1 lib/vzaar/request/process_video.rb
vzaar-1.6.0 lib/vzaar/request/process_video.rb