Class: Simplesms::Text
- Inherits:
-
Object
- Object
- Simplesms::Text
- Defined in:
- lib/simplesms.rb
Instance Method Summary collapse
-
#initialize(to: to_number_in, message: message_to_send_in) ⇒ Text
constructor
A new instance of Text.
- #send ⇒ Object
Constructor Details
#initialize(to: to_number_in, message: message_to_send_in) ⇒ Text
Returns a new instance of Text.
5 6 7 8 |
# File 'lib/simplesms.rb', line 5 def initialize(to: to_number_in, message: ) @to = to = end |
Instance Method Details
#send ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/simplesms.rb', line 10 def send begin url = ENV["SIMPLESMSIO_URL"] body = { "to" => @to, "message" => } uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(body) response = http.request(request) rescue response = {"success": false, "message": "Error establishing http connection"} end response end |