Class: SwiftSmsGateway::Message
- Inherits:
-
Object
- Object
- SwiftSmsGateway::Message
- Defined in:
- lib/swift_sms_gateway/message.rb
Constant Summary collapse
- BASE_URL =
"https://secure.smsgateway.ca/services"
Instance Method Summary collapse
- #create(params) ⇒ Object
-
#initialize(account_key) ⇒ Message
constructor
A new instance of Message.
- #send_response ⇒ Object
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) @account_key = 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_response ⇒ Object
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 |