class Twilreapi::ActiveCallRouter::UnicefIO::CallRouter
Attributes
caller_id[RW]
gateway[RW]
Private Class Methods
configuration(key)
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 96 def self.configuration(key) ENV["TWILREAPI_ACTIVE_CALL_ROUTER_UNICEF_IO_#{key.to_s.upcase}"] end
Public Instance Methods
routing_instructions()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 7 def routing_instructions @routing_instructions ||= generate_routing_instructions end
Private Instance Methods
default_caller_id()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 92 def default_caller_id self.class.configuration("default_caller_id") end
default_gateway()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 68 def default_gateway gateways["default"] end
destination()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 21 def destination phone_call.to end
destination_torasup_number()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 84 def destination_torasup_number @destination_torasup_number ||= Torasup::PhoneNumber.new(normalized_destination) end
fallback_gateway()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 64 def fallback_gateway gateways["fallback"] || other_gateways.first end
gateways()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 76 def gateways operator.gateways || {} end
generate_routing_instructions()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 25 def generate_routing_instructions set_routing_variables gateway_configuration = gateway || fallback_gateway || {} gateway_name = gateway_configuration["name"] gateway_host = gateway_configuration["host"] address = normalized_destination if gateway_configuration["prefix"] == false address = Phony.format( address, format: :national, spaces: "" ) end if gateway_name dial_string_path = "gateway/#{gateway_name}/#{address}" elsif gateway_host dial_string_path = "external/#{address}@#{gateway_host}" end routing_instructions = { "source" => caller_id, "destination" => normalized_destination } if dial_string_path routing_instructions["dial_string_path"] = dial_string_path else routing_instructions["disable_originate"] = "1" end routing_instructions end
normalized_destination()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 88 def normalized_destination @normalized_destination ||= Phony.normalize(destination) end
operator()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 80 def operator destination_torasup_number.operator end
other_gateways()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 72 def other_gateways gateways["others"] || [] end
phone_call()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 13 def phone_call options[:phone_call] end
set_routing_variables()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 59 def set_routing_variables self.caller_id = default_caller_id || source self.gateway = default_gateway end
source()
click to toggle source
# File lib/twilreapi/active_call_router/unicef_io/call_router.rb, line 17 def source phone_call.from end