Class: Infobip::SmsApi::Message
- Inherits:
-
Object
- Object
- Infobip::SmsApi::Message
- Defined in:
- lib/infobip/sms_api/message.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#text ⇒ Object
Returns the value of attribute text.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Message
constructor
A new instance of Message.
- #send_text ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Message
Returns a new instance of Message.
10 11 12 13 14 |
# File 'lib/infobip/sms_api/message.rb', line 10 def initialize(attributes) self.from = attributes[:from] self.to = attributes[:to] self.text = attributes[:text] end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
8 9 10 |
# File 'lib/infobip/sms_api/message.rb', line 8 def from @from end |
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/infobip/sms_api/message.rb', line 8 def text @text end |
#to ⇒ Object
Returns the value of attribute to.
8 9 10 |
# File 'lib/infobip/sms_api/message.rb', line 8 def to @to end |
Instance Method Details
#send_text ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/infobip/sms_api/message.rb', line 24 def send_text response = Infobip::SmsApi.configuration.connection.post do |req| req.url '/sms/1/text/single' req.body = self.to_hash.to_json req.headers['Accept'] = 'application/json' req.headers['Content-Type'] = 'application/json' end Infobip::SmsApi::Response::Base.new(response.status, JSON.parse(response.body)) end |
#to_hash ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/infobip/sms_api/message.rb', line 16 def to_hash hash = {} self.instance_variables.each do |var| hash[var.to_s.delete('@')] = self.instance_variable_get(var) end hash end |