Sha256: a681a3bfd9af1f3ed5655fdeabd595cb7a863c3b920a31a01d19f2ab47dff640

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

module Moonshado
  class Sms
    class Keywords
      class << self
        def list
          response = sender.get(configuration.keywords_uri)

          parse(response.body)
        end

        def register_keywords
          raise MoonshadoSMSException.new("no keywords specified") unless valid_keywords?
          response = sender.send_to_moonshado({:keywords => configuration.keywords}, configuration.keywords_uri)

          parse(response.body)
        end

        # def self.destory(keyword)
        #   response = RestClient.delete("#{url}/#{keyword}")
        #   parse(response.body)
        # end

        def valid_keywords?
          configuration.keywords.is_a?(Hash) && (!configuration.keywords.empty?)
        end

        class MoonshadoSMSException < StandardError; end

        private
          def sender
            Moonshado::Sms.sender
          end

          def configuration
            Moonshado::Sms.configuration
          end

          def production_environment?
            configuration.production_environment
          end

          def parse(json)
            JSON.parse(json)
          end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moonshado-sms-1.1.1 lib/moonshado/keywords.rb
moonshado-sms-1.1.1.rc2 lib/moonshado/keywords.rb
moonshado-sms-1.1.1.rc1 lib/moonshado/keywords.rb