Class: SwiftSmsGateway::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/swift_sms_gateway/message.rb

Constant Summary collapse

BASE_URL =
"https://secure.smsgateway.ca/services"

Instance Method Summary collapse

Constructor Details

#initialize(account_key) ⇒ Message

Returns a new instance of Message.



9
10
11
# File 'lib/swift_sms_gateway/message.rb', line 9

def initialize()
  @account_key = 
end

Instance Method Details

#create(params) ⇒ Object



13
14
15
16
17
# 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_responseObject



19
20
21
22
23
24
25
26
# File 'lib/swift_sms_gateway/message.rb', line 19

def send_response
  case @response.code
  when 200, 201, 204
    @response.parse
  else
    raise SwiftSmsGatewayError, @response
  end
end