Sha256: b027f8ef4ddd613d4f9a06b500ad06cd8a39eebcf073ba9ae06d5ab8a832ef60

Contents?: true

Size: 798 Bytes

Versions: 3

Compression:

Stored size: 798 Bytes

Contents

require 'httparty'

module Cellular
  module Backends
    class CoolSMS

      # Documentation: http://www.coolsms.com/support/dokumentation/http-gateway.sms
      GATEWAY_URL = 'https://sms.coolsmsc.dk/'

      def self.deliver(options = {})
        query = {
          username: Cellular.config.username,
          password: Cellular.config.password,
          from: options[:sender],
          to: options[:recipient],
          message: options[:message],
          charset: 'utf-8',
          resulttype: 'xml',
          lang: 'en'
        }

        result = HTTParty.get(GATEWAY_URL, query: query)
        response = result.parsed_response['smsc']

        [
          response['status'],
          response['result'] || response['message']['result']
        ]
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cellular-1.3.0 lib/cellular/backends/cool_sms.rb
cellular-1.2.0 lib/cellular/backends/cool_sms.rb
cellular-1.1.0 lib/cellular/backends/cool_sms.rb