Sha256: 816d3b8331f31c228486c30e5747d8fd49336fc04456b1dc0c2ee6964fb6b35b
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
require "sms_manager/error/sending_error" module SmsManager class Client # options should be { number: String, message: String } def send_message(options = {}) validate_send_message_options! options options = { username: SmsManager.instance_variable_get(:@username), password: SmsManager.instance_variable_get(:@hashed_password), number: options[:number], message: options[:message] } body = HTTPClient.get('http://http-api.smsmanager.cz/Send', options).body unless body =~ /^OK/ raise SendingError, "Sending text '#{options[:message]}' to phone '#{options[:number]}' failed" end nil end private def validate_send_message_options!(options) options.each do |option, value| unless value.is_a?(String) raise ArgumentError, "Invalid #{option} specified: #{value} must be a string." end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sms_manager-0.1.1 | lib/sms_manager/client.rb |
sms_manager-0.1.0 | lib/sms_manager/client.rb |