class SmsGatewayTo::Client
Attributes
product_token[R]
Public Class Methods
new(product_token)
click to toggle source
# File lib/sms_gateway_to/client.rb, line 7 def initialize(product_token) @product_token = product_token end
Public Instance Methods
send_message(from, to, message)
click to toggle source
# File lib/sms_gateway_to/client.rb, line 11 def send_message(from, to, message) self.class.post("/json/gateway.ashx", { body: { messages: { authentication: { producttoken: @product_token }, msg: [{ from: from, to: [{ number: to }], body: { type: "AUTO", content: message } }] } }.to_json, headers: { 'Content-Type' => 'application/json' } } ) end
send_message!(from, to, message)
click to toggle source
# File lib/sms_gateway_to/client.rb, line 36 def send_message!(from, to, message) response = send_message(from, to, message) unless response.nil? || response.empty? handle_error(response) end end
Private Instance Methods
handle_error(response)
click to toggle source
# File lib/sms_gateway_to/client.rb, line 45 def handle_error(response) SmsGatewayTo::ErrorHandler.new(response).response end