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