class SwiftSmsGateway::Message

Constants

BASE_URL

Public Class Methods

new(account_key) click to toggle source
# File lib/swift_sms_gateway/message.rb, line 9
def initialize(account_key)
  @account_key = account_key
end

Public Instance Methods

create(params) click to toggle source
# File lib/swift_sms_gateway/message.rb, line 13
def create(params)
  url = "#{BASE_URL}/message.svc/#{@account_key}/#{params[:to]}"
  @response = HTTP.post(url, { json: {MessageBody: params[:body]} } )
  send_response
end
send_response() click to toggle source
# File lib/swift_sms_gateway/message.rb, line 19
def send_response
  case @response.code
  when 200, 201, 204
    JSON.parse(@response)
  else
    raise SwiftSmsGatewayError, @response
  end
end