Sha256: 737ded1fb1792451f69c67ce538e138deafe798711d3122ba46951dea96f2fbc

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

module Applicants
  module ScreencastOMatic
    class UrlBuilder
      include Applicants::Engine.routes.url_helpers

      attr_reader :applicant, :host

      def initialize applicant, host, port
        @applicant = applicant
        @host = host
        @port = port
      end

      def descriptor_file_url
        uri = URI::HTTPS.build({
                                host: host,
                                path: "/screen_recorder/applicants/#{applicant.id}/file/#{applicant.video_handle}",
                                query: {
                                  upload_callback_url: upload_callback_url,
                                  thank_you_page_url: thank_you_page_url,
                                  screen_recorder_callback_url: callback_url
                                }.to_query,
                              })
        uri.scheme = "usertesting"
        uri.to_s
      end

      def callback_url
        screen_recorder_callbacks_applicant_url(applicant, url_params)
      end

      def thank_you_page_url
        next_steps_applicant_url(applicant, url_params)
      end

      def upload_callback_url
        video_server_callback_applicant_url(applicant, url_params)
      end

      private

      def url_params
        {
          host: host,
          port: port,
        }
      end

      def port
        if @port == 80 || @port == 443
          nil
        else
          @port
        end
      end



      def amazon_chunked_upload_url
        Rails.application.config.amazon_chunked_upload_url.tap do |setting|
          return setting.call if setting.respond_to? :call
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
applicants-0.11.0 app/lib/applicants/screencast_o_matic/url_builder.rb