Class: VoipfoneClient::SMS
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#message ⇒ Object
Returns the value of attribute message.
-
#to ⇒ Object
Returns the value of attribute to.
Attributes inherited from Client
Instance Method Summary collapse
-
#initialize(to: nil, from: nil, message: nil) ⇒ SMS
constructor
Constructor to create an SMS - optionally pass in to, from and message.
-
#send ⇒ Object
Send an sms from your account.
Methods inherited from Client
#account_balance, #account_details, #parse_response, #phone_numbers, #voicemail
Constructor Details
#initialize(to: nil, from: nil, message: nil) ⇒ SMS
Constructor to create an SMS - optionally pass in to, from and message
9 10 11 12 13 14 |
# File 'lib/voipfone_client/sms.rb', line 9 def initialize(to: nil, from: nil, message: nil) @to = to @from = from @message = super() end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
3 4 5 |
# File 'lib/voipfone_client/sms.rb', line 3 def from @from end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/voipfone_client/sms.rb', line 3 def @message end |
#to ⇒ Object
Returns the value of attribute to.
3 4 5 |
# File 'lib/voipfone_client/sms.rb', line 3 def to @to end |
Instance Method Details
#send ⇒ Object
Send an sms from your account.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/voipfone_client/sms.rb', line 17 def send if @to.nil? || @from.nil? || @message.nil? raise ArgumentError, "You need to include 'to' and 'from' numbers and a message to send an SMS" end to = @to.gsub(" ","") from = @from.gsub(" ","") parameters = { "sms-send-to" => to, "sms-send-from" => from, "sms-message" => @message[0..159] } request = @browser.post("#{VoipfoneClient::API_POST_URL}?smsSend", parameters) response = parse_response(request) if response == "ok" return true else raise VoipfoneAPIError, response end end |