Class: Vianettsms::Sms
- Inherits:
-
Object
- Object
- Vianettsms::Sms
- Defined in:
- lib/vianettsms/sms.rb
Instance Attribute Summary collapse
-
#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.
8 9 10 11 12 13 14 15 16 |
# File 'lib/vianettsms/sms.rb', line 8 def initialize(params={}) @to = params[:to] = params[:message] @msgid = params[:msgid] @response = nil @response_hash= {} @status = nil @delivered = false end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/vianettsms/sms.rb', line 4 def end |
#msgid ⇒ Object
Returns the value of attribute msgid.
4 5 6 |
# File 'lib/vianettsms/sms.rb', line 4 def msgid @msgid end |
#response_hash ⇒ Object (readonly)
Returns the value of attribute response_hash.
6 7 8 |
# File 'lib/vianettsms/sms.rb', line 6 def response_hash @response_hash end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/vianettsms/sms.rb', line 6 def status @status end |
#to ⇒ Object
Returns the value of attribute to.
4 5 6 |
# File 'lib/vianettsms/sms.rb', line 4 def to @to end |
Instance Method Details
#deliver ⇒ Object
18 19 20 21 22 23 |
# File 'lib/vianettsms/sms.rb', line 18 def deliver if valid? handle_response(Net::HTTP.post_form(URI.parse(Vianettsms.url), params_hash)) end delivered? end |
#delivered? ⇒ Boolean
25 26 27 |
# File 'lib/vianettsms/sms.rb', line 25 def delivered? @delivered end |
#valid? ⇒ Boolean
29 30 31 32 33 34 |
# File 'lib/vianettsms/sms.rb', line 29 def valid? raise(ArgumentError, ":to is required") if @to.nil? or @to.empty? raise(ArgumentError, ":message is required") if .nil? or .empty? raise(ArgumentError, ":msgid is required") if @msgid.nil? or @msgid.empty? not (@to.nil? or @to.empty? or .nil? or .empty? or @msgid.nil? or @msgid.empty?) end |