Module: Cardboardfish
- Defined in:
- lib/cardboardfish.rb
Defined Under Namespace
Classes: AuthenticationError
Constant Summary
collapse
- HOST =
'sms1.cardboardfish.com'
- PORT =
'9001'
- PATH =
'HTTPSMS'
- @@username =
nil
- @@password =
nil
Class Method Summary
collapse
Class Method Details
.authenticate(username, password) ⇒ Object
19
20
21
22
|
# File 'lib/cardboardfish.rb', line 19
def self.authenticate(username, password)
@@username = username
@@password = password
end
|
.parse(receipt) ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'lib/cardboardfish.rb', line 38
def self.parse(receipt)
parts = receipt.split("#")
count = parts.shift
receipts = []
parts.each do |p|
receipts << self.parse_fragment(p)
end
return receipts
end
|
.sms(options) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/cardboardfish.rb', line 24
def self.sms(options)
raise AuthenticationError.new("must provide login details first Cardboardfish.authenticate(username, password)") unless @@username && @@password
http = Net::HTTP.new(HOST, PORT)
options = defaults.merge!(options)
options.each_pair do |k,v|
options[k] = CGI::escape(v)
end
uri = "/#{PATH}?S=#{options[:system_type]}&UN=#{@@username}&P=#{@@password}&DR=#{options[:receipt]}&DA=#{options[:destination]}&SA=#{options[:source]}&M=#{options[:message]}&V=#{options[:validity_period]}";
STDERR.puts uri
response = http.start do |http|
http.get(uri)
end
end
|