Module: FlowChat::PhoneNumberUtil

Defined in:
lib/flow_chat/phone_number_util.rb

Class Method Summary collapse

Class Method Details

.to_e164(phone_number) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/flow_chat/phone_number_util.rb', line 4

def to_e164(phone_number)
  return "" if phone_number.nil? || phone_number.empty?

  begin
    # Try to load phonelib without Rails dependency
    require_phonelib_safely
    Phonelib.parse(phone_number).e164
  rescue => e
    FlowChat.logger.warn { "PhoneNumberUtil: Failed to parse phone number '#{phone_number}': #{e.message}" }
    # Fallback to simple formatting if phonelib fails
    fallback_e164_format(phone_number)
  end
end