Class: PSWinLinkMobilitySmsApi::Sms
- Inherits:
-
Object
- Object
- PSWinLinkMobilitySmsApi::Sms
- Defined in:
- lib/PSWinLinkMobilitySmsApi/sms.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#message ⇒ Object
Returns the value of attribute message.
-
#msgid ⇒ Object
Returns the value of attribute msgid.
-
#response_hash ⇒ Object
readonly
Returns the value of attribute response_hash.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #deliver ⇒ Object
- #delivered? ⇒ Boolean
-
#initialize(params = {}) ⇒ Sms
constructor
A new instance of Sms.
- #valid? ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ Sms
Returns a new instance of Sms.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 10 def initialize(params = {}) @to = params[:to] @message = params[:message].to_s.encode('ISO-8859-1') @msgid = params[:msgid] @from = params[:from] @response = nil @response_hash = {} @status = nil @delivered = false end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
6 7 8 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 6 def from @from end |
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 6 def @message end |
#msgid ⇒ Object
Returns the value of attribute msgid.
6 7 8 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 6 def msgid @msgid end |
#response_hash ⇒ Object (readonly)
Returns the value of attribute response_hash.
8 9 10 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 8 def response_hash @response_hash end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 8 def status @status end |
#to ⇒ Object
Returns the value of attribute to.
6 7 8 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 6 def to @to end |
Instance Method Details
#deliver ⇒ Object
21 22 23 24 25 26 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 21 def deliver if valid? handle_response(Net::HTTP.post_form(URI.parse(PSWinLinkMobilitySmsApi.url), params_hash)) end delivered? end |
#delivered? ⇒ Boolean
28 29 30 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 28 def delivered? @delivered end |
#valid? ⇒ Boolean
32 33 34 35 36 37 |
# File 'lib/PSWinLinkMobilitySmsApi/sms.rb', line 32 def valid? raise(ArgumentError, ":to is required") if @to.nil? or @to.empty? raise(ArgumentError, ":message is required") if @message.nil? or @message.empty? raise(ArgumentError, ":msgid is required") if @msgid.nil? or @msgid.empty? not (@to.nil? or @to.empty? or @message.nil? or @message.empty? or @msgid.nil? or @msgid.empty?) end |