summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrendan G. Lim2008-03-31 17:37:02 -0400
committerBrendan G. Lim2008-03-31 17:37:02 -0400
commit7813e59c8535f6180852a534fd0bfd7ba6085ace (patch)
tree7f3cf9d193531e473929c4a065330e109c6e055f
parent5393cc834ce85da8856ed8869e7b5e66b004239f (diff)
downloadsms-fu-7813e59c8535f6180852a534fd0bfd7ba6085ace.tar.bz2
Adding in international support and externalizing carrier list into sms_fu.yml
-rw-r--r--lib/sms_fu.rb23
-rw-r--r--templates/sms_fu.yml44
2 files changed, 53 insertions, 14 deletions
diff --git a/lib/sms_fu.rb b/lib/sms_fu.rb
index 86810ed..c87da82 100644
--- a/lib/sms_fu.rb
+++ b/lib/sms_fu.rb
@@ -1,3 +1,4 @@
+require 'yaml'
# Copyright (c) 2008 Brendan G. Lim (brendangl@gmail.com)
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -20,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module SMSFu
- class SMSFuException < StandardError; end
+ @@config = YAML::load(File.open("#{RAILS_ROOT}/config/sms_fu.yml"))
def deliver_sms(number,carrier,message,options={})
number = format_number(number)
@@ -30,7 +31,6 @@ module SMSFu
message = message[0..options[:limit]-1]
sms_email = determine_sms_email(format_number(number),carrier)
SmsNotifier.deliver_sms_message(sms_email,message)
-
rescue SMSFuException => exception
raise exception
end
@@ -53,16 +53,13 @@ module SMSFu
return (number.length == 10 && number[/^\d+$/]) ? true : false
end
- def determine_sms_email(phone_number, phone_carrier)
- case phone_carrier.downcase
- when "alltel": "#{phone_number}@message.alltell.com"
- when "at&t": "#{phone_number}@txt.att.net"
- when "boost": "#{phone_number}@myboostmobile.com"
- when "sprint": "#{phone_number}@messaging.sprintpcs.com"
- when "t-mobile": "#{phone_number}@tmomail.net"
- when "virgin": "#{phone_number}@vmobl.net"
- when "verizon": "#{phone_number}@vtext.com"
- else raise SMSFuException.new("Specified carrier, #{phone_carrier} is not supported.")
+ def determine_sms_email(phone_number, carrier)
+ if @@config[:carriers].has_key?(carrier.downcase)
+ "#{phone_number}#{@@config[:carriers][carrier.downcase]}"
+ else
+ raise SMSFuException.new("Specified carrier, #{carrier} is not supported.")
end
- end
+ end
+
+ class SMSFuException < StandardError; end
end \ No newline at end of file
diff --git a/templates/sms_fu.yml b/templates/sms_fu.yml
index 0940493..35c7695 100644
--- a/templates/sms_fu.yml
+++ b/templates/sms_fu.yml
@@ -1 +1,43 @@
-from_address: noreply@domain.com \ No newline at end of file
+from_address: noreply@domain.com
+
+carriers:
+ # US Carriers
+ alltell: @message.alltell.com
+ ameritech: @paging.acswireless.com
+ at&t: @txt.att.net
+ bellsouthmobility: @blsdcs.net
+ blueskyfrog: @blueskyfrog.com
+ boost: @myboostmobile.com
+ cellularsouth: @csouth1.com
+ metropcs: @mymetropcs.com
+ powertel: @ptel.net
+ pscwireless: @sms.pscel.com
+ qwest: @qwestmp.com
+ southernlink: @page.southernlinc.com
+ sprint: @messaging.sprintpcs.com
+ suncom: @tms.suncom.com
+ t-mobile: @tmomail.net
+ virgin: @vmobl.net
+ verizon: @vtext.com
+ # International Carriers
+ fido-canada: @fido.ca
+ t-mobile-germany: @t-d1-sms.de
+ t-mobile-uk: @t-mobile.uk.net
+ vodafone-uk: @sms.vodafone.net
+ vodafone-italy: @sms.vodafone.it
+ vodafone-jp-chuugoku: @n.vodafone.ne.jp
+ vodafone-jp-hokkaido: @d.vodafone.ne.jp
+ vodafone-jp-hokuriko: @r.vodafone.ne.jp
+ vodafone-jp-kansai: @k.vodafone.ne.jp
+ vodafone-jp-osaka: @k.vodafone.ne.jp
+ vodafone-jp-kanto: @k.vodafone.ne.jp
+ vodafone-jp-koushin: @k.vodafone.ne.jp
+ vodafone-jp-tokyo: @k.vodafone.ne.jp
+ vodafone-jp-kyuushu: @q.vodafone.ne.jp
+ vodafone-jp-okinawa: @q.vodafone.ne.jp
+ vodafone-jp-shikoku: @s.vodafone.ne.jp
+ vodafone-jp-touhoku: @h.vodafone.ne.jp
+ vodafone-jp-niigata: @h.vodafone.ne.jp
+ vodafone-jp-toukai: @h.vodafone.ne.jp
+
+ \ No newline at end of file