require "sipgate-callerid/version"
require "sipgate-callerid/database"

module Sipgate
  
  module CallerId
    
    def self.sanitize_number(number)
      default_country_code = '49'
      
      # If the number starts with a single zero, replace that with the default country code
      number.gsub! /^0([^0])/, "#{default_country_code}\\1"
      
      # If the number starts with two zeroes, remove them
      number.gsub! /^00/, ''
      
      # If the number starts with a +, remove it
      number.gsub! /^\+/, ''
      
      # Remove all characters that are not a number from zero to nine
      number.gsub! /[^0-9]/, ''
      
      number
    end
    
  end
  
end