Module: Sms

Defined in:
lib/smshuman.rb

Class Method Summary collapse

Class Method Details

.individual(from, to, msg, account, code, id = nil, schedule = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/smshuman.rb', line 29

def self.individual(from,to,msg,,code,id=nil,schedule=nil)
  begin
    a = RestClient.post 'http://system.human.com.br/GatewayIntegration/msgSms.do',
      :content_type   => 'multipart/form-data',
      :dispatch       => 'send',
      :account        => ,
      :code           => code,
      :msg            =>  msg,
      :from           => from,
      :to             => to
   

     if RAILS_ENV
       log = Log.new
       log.message(msg(a))
     else
       puts msg(a)
     end
      rescue Exception => e
        raise e
      end
    return status(a)
end

.msg(retorno) ⇒ Object

Retorno em Mensagem



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/smshuman.rb', line 55

def self.msg(retorno)   
 if retorno.include? "000"
         mensagem=("#{retorno} -Mensagem Enviada")
        elsif retorno.include? "010"
          mensagem="#{retorno} - Erro em Sua Chamada"
        elsif retorno.include? "200"
          mensagem=("#{retorno} - Todas as mensagens foram  enviadas")
         elsif retorno.include? "011"
          mensagem="#{retorno} - Erro em Sua Chamada"
         elsif retorno.include? "012"
          mensagem="#{retorno} - Erro em Sua Chamada"
         elsif retorno.include? "013"
          mensagem="#{retorno} - Erro em Sua Chamada"
         elsif retorno.include? "014"
          mensagem="#{retorno} - Erro em Sua Chamada"
         elsif retorno.include? "015"
          mensagem="#{retorno} - Erro em Sua Chamada"
         elsif retorno.include? "016"
          mensagem="#{retorno} - Erro em Sua Chamada"
         elsif retorno.include? "017"
          mensagem="#{retorno} - Erro em Sua Chamada"
         elsif retorno.include? "080"
          mensagem="#{retorno} - Mensagem já enviada com o mesmo ID"
         elsif retorno.include? "900"
          mensagem="#{retorno} - Erro de Autenticação"
        end
  return mensagem
end

.multiplo(account, code, filename, callbackOption = '0', type = 'C') ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/smshuman.rb', line 5

def self.multiplo(,code,filename,callbackOption='0',type='C')
      begin
        a = RestClient.post 'http://system.human.com.br/GatewayIntegration/msgSms.do',
          :content_type   => 'multipart/form-data',
          :dispatch       => 'sendMultiple',
          :account        => ,
          :code           => code,
          :type           => type,
          :callbackOption => callbackOption,
          :list           => File.read(filename)  
           
         if RAILS_ENV
           log = Log.new
           log.message(msg(a))
         else
           puts msg(a)
         end
          rescue Exception => e
            raise e
       end

        return status(a)
end

.status(retorno) ⇒ Object

status do retorno



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/smshuman.rb', line 86

def self.status(retorno)   
        if retorno.include? "000"
          resultado=true
        elsif retorno.include? "200"
          resultado=true
        elsif retorno.include? "010"
          resultado=false
         elsif retorno.include? "011"
          resultado=false
         elsif retorno.include? "012"
          resultado=false
         elsif retorno.include? "013"
          resultado=false
         elsif retorno.include? "014"
          resultado=false
         elsif retorno.include? "015"
          resultado=false
         elsif retorno.include? "016"
          resultado=false
         elsif retorno.include? "017"
          resultado=false
         elsif retorno.include? "080"
          resultado=false
         elsif retorno.include? "900"
          resultado=false         
        end
  return resultado
end