moip 1.0.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +0 -0
 - data/Gemfile.lock +0 -3
 - data/LICENSE +0 -0
 - data/README.markdown +3 -9
 - data/Rakefile +8 -4
 - data/VERSION +1 -1
 - data/lib/{moip/direct_payment.rb → direct_payment.rb} +5 -20
 - data/lib/moip.rb +61 -31
 - data/moip.gemspec +11 -6
 - data/spec/moip_spec.rb +59 -198
 - metadata +42 -13
 - data/lib/moip/client.rb +0 -62
 
    
        data/Gemfile
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/LICENSE
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/README.markdown
    CHANGED
    
    | 
         @@ -65,19 +65,13 @@ Após realizar os testes na SandBox, você poderá fazer a mudança para o ambie 
     | 
|
| 
       65 
65 
     | 
    
         
             
            ###Checkout
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
67 
     | 
    
         
             
                def checkout
         
     | 
| 
       68 
     | 
    
         
            -
                  response = MoIP 
     | 
| 
      
 68 
     | 
    
         
            +
                  response = MoIP.checkout(boleto)
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
70 
     | 
    
         
             
                  # exibe o boleto para impressão
         
     | 
| 
       71 
     | 
    
         
            -
                  redirect_to MoIP 
     | 
| 
      
 71 
     | 
    
         
            +
                  redirect_to MoIP.moip_page(response["Token"])
         
     | 
| 
       72 
72 
     | 
    
         
             
                end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
            ### 
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             - MoIP::MissingPaymentTypeError - Quando falta a razão do pagamento na requisição.
         
     | 
| 
       77 
     | 
    
         
            -
             - MoIP::MissingPayerError - Quando falta as informações do pagador na requisição.
         
     | 
| 
       78 
     | 
    
         
            -
             - MoIP::WebServerResponseError - Quando há algum erro ao se enviar a solicitação ao servidor. Normalmente a razão do erro vem como resposta da mensagem.
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
            ## Futuras implementações
         
     | 
| 
      
 74 
     | 
    
         
            +
            ### Futuras implementações
         
     | 
| 
       81 
75 
     | 
    
         | 
| 
       82 
76 
     | 
    
         
             
            * Pagamento Simples
         
     | 
| 
       83 
77 
     | 
    
         
             
            * Pagamento Recorrente
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -2,8 +2,6 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'rake'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            require 'rspec/core/rake_task'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
5 
     | 
    
         
             
            begin
         
     | 
| 
       8 
6 
     | 
    
         
             
              require 'jeweler'
         
     | 
| 
       9 
7 
     | 
    
         
             
              Jeweler::Tasks.new do |gem|
         
     | 
| 
         @@ -15,7 +13,7 @@ begin 
     | 
|
| 
       15 
13 
     | 
    
         
             
                gem.authors = ["Guilherme Nascimento"]
         
     | 
| 
       16 
14 
     | 
    
         
             
                gem.add_development_dependency "rspec", "~> 2.1.0"
         
     | 
| 
       17 
15 
     | 
    
         
             
                gem.add_dependency "nokogiri", "~> 1.4.3"
         
     | 
| 
       18 
     | 
    
         
            -
                gem.add_dependency "httparty", "~> 0. 
     | 
| 
      
 16 
     | 
    
         
            +
                gem.add_dependency "httparty", "~> 0.6.1"
         
     | 
| 
       19 
17 
     | 
    
         
             
                gem.add_dependency "activesupport", '>= 2.3.2'
         
     | 
| 
       20 
18 
     | 
    
         
             
              end
         
     | 
| 
       21 
19 
     | 
    
         
             
              Jeweler::GemcutterTasks.new
         
     | 
| 
         @@ -23,9 +21,15 @@ rescue LoadError 
     | 
|
| 
       23 
21 
     | 
    
         
             
              puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
         
     | 
| 
       24 
22 
     | 
    
         
             
            end
         
     | 
| 
       25 
23 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            desc "Run all examples"
         
     | 
| 
       27 
27 
     | 
    
         
             
            RSpec::Core::RakeTask.new
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
            task :spec => :check_dependencies
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            task :default => :spec
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       29 
33 
     | 
    
         
             
            require 'rake/rdoctask'
         
     | 
| 
       30 
34 
     | 
    
         
             
            Rake::RDocTask.new do |rdoc|
         
     | 
| 
       31 
35 
     | 
    
         
             
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            2.0.0
         
     | 
| 
         @@ -1,29 +1,20 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
            require "nokogiri"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
2 
     | 
    
         
             
            module MoIP
         
     | 
| 
       5 
3 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
              class MissingPaymentTypeError < StandardError ; end
         
     | 
| 
       7 
     | 
    
         
            -
              class MissingPayerError < StandardError ; end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
4 
     | 
    
         
             
              class DirectPayment
         
     | 
| 
       10 
5 
     | 
    
         | 
| 
       11 
6 
     | 
    
         
             
                class << self
         
     | 
| 
       12 
7 
     | 
    
         | 
| 
       13 
8 
     | 
    
         
             
                  # Cria uma instrução de pagamento direto
         
     | 
| 
       14 
9 
     | 
    
         
             
                  def body(attributes = {})
         
     | 
| 
       15 
     | 
    
         
            -
                    raise(MissinPaymentTypeError, "É necessário informar a razão do pagamento") if attributes[:razao].nil?
         
     | 
| 
       16 
     | 
    
         
            -
                    raise(MissingPayerError, "É obrigatório passar as informações do pagador") if attributes[:pagador].nil?
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
10 
     | 
    
         
             
                    builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml|
         
     | 
| 
       19 
11 
     | 
    
         | 
| 
       20 
12 
     | 
    
         
             
                      # Identificador do tipo de instrução
         
     | 
| 
       21 
13 
     | 
    
         
             
                      xml.EnviarInstrucao {
         
     | 
| 
       22 
14 
     | 
    
         
             
                        xml.InstrucaoUnica {
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
15 
     | 
    
         
             
                          # Dados da transação
         
     | 
| 
       25 
16 
     | 
    
         
             
                          xml.Razao {
         
     | 
| 
       26 
     | 
    
         
            -
                            xml.text  
     | 
| 
      
 17 
     | 
    
         
            +
                            xml.text "Pagamento"
         
     | 
| 
       27 
18 
     | 
    
         
             
                          }
         
     | 
| 
       28 
19 
     | 
    
         
             
                          xml.Valores {
         
     | 
| 
       29 
20 
     | 
    
         
             
                            xml.Valor(:moeda => "BRL") {
         
     | 
| 
         @@ -52,6 +43,7 @@ module MoIP 
     | 
|
| 
       52 
43 
     | 
    
         
             
                              xml.Instituicao {
         
     | 
| 
       53 
44 
     | 
    
         
             
                                xml.text attributes[:instituicao]
         
     | 
| 
       54 
45 
     | 
    
         
             
                              }
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
       55 
47 
     | 
    
         
             
                              xml.CartaoCredito {
         
     | 
| 
       56 
48 
     | 
    
         
             
                                xml.Numero {
         
     | 
| 
       57 
49 
     | 
    
         
             
                                  xml.text attributes[:numero]
         
     | 
| 
         @@ -89,6 +81,7 @@ module MoIP 
     | 
|
| 
       89 
81 
     | 
    
         
             
                          }
         
     | 
| 
       90 
82 
     | 
    
         | 
| 
       91 
83 
     | 
    
         
             
                          # Dados do pagador
         
     | 
| 
      
 84 
     | 
    
         
            +
                          raise(StandardError, "É obrigatório passar as informações do pagador") if attributes[:pagador].nil?
         
     | 
| 
       92 
85 
     | 
    
         
             
                          xml.Pagador {
         
     | 
| 
       93 
86 
     | 
    
         
             
                            xml.Nome { xml.text attributes[:pagador][:nome] }
         
     | 
| 
       94 
87 
     | 
    
         
             
                            xml.LoginMoIP { xml.text attributes[:pagador][:login_moip] }
         
     | 
| 
         @@ -124,23 +117,15 @@ module MoIP 
     | 
|
| 
       124 
117 
     | 
    
         
             
                              }
         
     | 
| 
       125 
118 
     | 
    
         
             
                            }
         
     | 
| 
       126 
119 
     | 
    
         
             
                          end
         
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
                          if attributes[:url_retorno]
         
     | 
| 
       129 
     | 
    
         
            -
                            # URL de retorno
         
     | 
| 
       130 
     | 
    
         
            -
                            xml.URLRetorno {
         
     | 
| 
       131 
     | 
    
         
            -
                              xml.text attributes[:url_retorno]
         
     | 
| 
       132 
     | 
    
         
            -
                            }
         
     | 
| 
       133 
     | 
    
         
            -
                          end
         
     | 
| 
       134 
     | 
    
         
            -
                            
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
       135 
121 
     | 
    
         
             
                        }
         
     | 
| 
       136 
122 
     | 
    
         
             
                      }
         
     | 
| 
       137 
123 
     | 
    
         
             
                    end
         
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
124 
     | 
    
         
             
                    builder.to_xml
         
     | 
| 
       140 
125 
     | 
    
         
             
                  end
         
     | 
| 
       141 
126 
     | 
    
         | 
| 
       142 
127 
     | 
    
         
             
                end
         
     | 
| 
       143 
128 
     | 
    
         | 
| 
       144 
129 
     | 
    
         
             
              end
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
      
 130 
     | 
    
         
            +
              
         
     | 
| 
       146 
131 
     | 
    
         
             
            end
         
     | 
    
        data/lib/moip.rb
    CHANGED
    
    | 
         @@ -1,47 +1,77 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         
             
            require "rubygems"
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'active_support/core_ext/module/attribute_accessors'
         
     | 
| 
       4 
     | 
    
         
            -
            require ' 
     | 
| 
      
 4 
     | 
    
         
            +
            require 'httparty'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "nokogiri"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require "direct_payment"
         
     | 
| 
       5 
8 
     | 
    
         | 
| 
       6 
9 
     | 
    
         
             
            module MoIP
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              autoload :Client,        'moip/client'
         
     | 
| 
      
 10 
     | 
    
         
            +
                include HTTParty
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
                # URI para acessar o serviço
         
     | 
| 
      
 13 
     | 
    
         
            +
                mattr_accessor :uri
         
     | 
| 
      
 14 
     | 
    
         
            +
                @@uri = 'https://www.moip.com.br'
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
                # Token de autenticação
         
     | 
| 
      
 17 
     | 
    
         
            +
                mattr_accessor :token
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
                # Chave de acesso ao serviço
         
     | 
| 
      
 20 
     | 
    
         
            +
                mattr_accessor :key
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
                def self.setup
         
     | 
| 
      
 23 
     | 
    
         
            +
                  yield self
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
                STATUS = { 1 => "authorized", 2 => "started", 3 => "printed", 4 => "completed", 5 => "canceled", 6 => "analysing" }
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                 
     | 
| 
       28 
     | 
    
         
            -
                  ActiveSupport::Deprecation.warn("MoIP.checkout has been deprecated. Use MoIP::Client.checkout instead", caller)
         
     | 
| 
       29 
     | 
    
         
            -
                  MoIP::Client.checkout(attributes)
         
     | 
| 
       30 
     | 
    
         
            -
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
                base_uri "#{self.uri}/ws/alpha"
         
     | 
| 
      
 29 
     | 
    
         
            +
                basic_auth self.token, self.key
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
                 
     | 
| 
       33 
     | 
    
         
            -
                   
     | 
| 
       34 
     | 
    
         
            -
                   
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 32 
     | 
    
         
            +
                  # Envia uma instrução para pagamento único
         
     | 
| 
      
 33 
     | 
    
         
            +
                  def checkout(attributes = {})
         
     | 
| 
      
 34 
     | 
    
         
            +
                    full_data = peform_action!(:post, 'EnviarInstrucao/Unica', :body => DirectPayment.body(attributes))
         
     | 
| 
       36 
35 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                   
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                    get_response!(full_data["EnviarInstrucaoUnicaResponse"]["Resposta"])
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  # Consulta dos dados das autorizações e pagamentos associados à Instrução
         
     | 
| 
      
 40 
     | 
    
         
            +
                  def query(token)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    full_data = peform_action!(:get, "ConsultarInstrucao/#{token}")
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    get_response!(full_data["ConsultarTokenResponse"]["RespostaConsultar"])
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  # Retorna a URL de acesso ao MoIP
         
     | 
| 
      
 47 
     | 
    
         
            +
                  def moip_page(token)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    raise(StandardError, "É necessário informar um token para retornar os dados da transação") if token.nil?
         
     | 
| 
      
 49 
     | 
    
         
            +
                    "#{self.uri}/Instrucao.do?token=#{token}"
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  # Monta o NASP
         
     | 
| 
      
 53 
     | 
    
         
            +
                  def notification(params)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    notification = {}
         
     | 
| 
      
 55 
     | 
    
         
            +
                    notification[:transaction_id] = params["id_transacao"]
         
     | 
| 
      
 56 
     | 
    
         
            +
                    notification[:amount]         = params["valor"]
         
     | 
| 
      
 57 
     | 
    
         
            +
                    notification[:status]         = STATUS[params["status_pagamento"].to_i]
         
     | 
| 
      
 58 
     | 
    
         
            +
                    notification[:code]           = params["cod_moip"]
         
     | 
| 
      
 59 
     | 
    
         
            +
                    notification[:payment_type]   = params["tipo_pagamento"]
         
     | 
| 
      
 60 
     | 
    
         
            +
                    notification[:email]          = params["email_consumidor"]
         
     | 
| 
      
 61 
     | 
    
         
            +
                    notification
         
     | 
| 
      
 62 
     | 
    
         
            +
                  end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                  private
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                  def peform_action!(action_name, url, options = {})
         
     | 
| 
      
 67 
     | 
    
         
            +
                    response = self.send(action_name, url, options)
         
     | 
| 
      
 68 
     | 
    
         
            +
                    raise(StandardError, "Ocorreu um erro ao chamar o webservice") if response.nil?
         
     | 
| 
      
 69 
     | 
    
         
            +
                    response
         
     | 
| 
      
 70 
     | 
    
         
            +
                  end
         
     | 
| 
       41 
71 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 72 
     | 
    
         
            +
                  def get_response!(data)
         
     | 
| 
      
 73 
     | 
    
         
            +
                    raise(StandardError, data["Erro"]) if data["Status"] == "Falha"
         
     | 
| 
      
 74 
     | 
    
         
            +
                    data
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
       45 
76 
     | 
    
         
             
                end
         
     | 
| 
       46 
     | 
    
         
            -
              end
         
     | 
| 
       47 
77 
     | 
    
         
             
            end
         
     | 
    
        data/moip.gemspec
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{moip}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = " 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "2.0.0"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Guilherme Nascimento"]
         
     | 
| 
         @@ -24,9 +24,8 @@ Gem::Specification.new do |s| 
     | 
|
| 
       24 
24 
     | 
    
         
             
                "README.markdown",
         
     | 
| 
       25 
25 
     | 
    
         
             
                "Rakefile",
         
     | 
| 
       26 
26 
     | 
    
         
             
                "VERSION",
         
     | 
| 
      
 27 
     | 
    
         
            +
                "lib/direct_payment.rb",
         
     | 
| 
       27 
28 
     | 
    
         
             
                "lib/moip.rb",
         
     | 
| 
       28 
     | 
    
         
            -
                "lib/moip/client.rb",
         
     | 
| 
       29 
     | 
    
         
            -
                "lib/moip/direct_payment.rb",
         
     | 
| 
       30 
29 
     | 
    
         
             
                "moip.gemspec",
         
     | 
| 
       31 
30 
     | 
    
         
             
                "spec/moip_spec.rb"
         
     | 
| 
       32 
31 
     | 
    
         
             
              ]
         
     | 
| 
         @@ -45,8 +44,10 @@ Gem::Specification.new do |s| 
     | 
|
| 
       45 
44 
     | 
    
         
             
                  s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       46 
45 
     | 
    
         
             
                  s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       47 
46 
     | 
    
         
             
                  s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
      
 47 
     | 
    
         
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
      
 48 
     | 
    
         
            +
                  s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       48 
49 
     | 
    
         
             
                  s.add_runtime_dependency(%q<nokogiri>, ["~> 1.4.3"])
         
     | 
| 
       49 
     | 
    
         
            -
                  s.add_runtime_dependency(%q<httparty>, ["~> 0. 
     | 
| 
      
 50 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<httparty>, ["~> 0.6.1"])
         
     | 
| 
       50 
51 
     | 
    
         
             
                  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
         
     | 
| 
       51 
52 
     | 
    
         
             
                else
         
     | 
| 
       52 
53 
     | 
    
         
             
                  s.add_dependency(%q<moip>, [">= 0"])
         
     | 
| 
         @@ -54,8 +55,10 @@ Gem::Specification.new do |s| 
     | 
|
| 
       54 
55 
     | 
    
         
             
                  s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       55 
56 
     | 
    
         
             
                  s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       56 
57 
     | 
    
         
             
                  s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
      
 58 
     | 
    
         
            +
                  s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
      
 59 
     | 
    
         
            +
                  s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       57 
60 
     | 
    
         
             
                  s.add_dependency(%q<nokogiri>, ["~> 1.4.3"])
         
     | 
| 
       58 
     | 
    
         
            -
                  s.add_dependency(%q<httparty>, ["~> 0. 
     | 
| 
      
 61 
     | 
    
         
            +
                  s.add_dependency(%q<httparty>, ["~> 0.6.1"])
         
     | 
| 
       59 
62 
     | 
    
         
             
                  s.add_dependency(%q<activesupport>, [">= 2.3.2"])
         
     | 
| 
       60 
63 
     | 
    
         
             
                end
         
     | 
| 
       61 
64 
     | 
    
         
             
              else
         
     | 
| 
         @@ -64,8 +67,10 @@ Gem::Specification.new do |s| 
     | 
|
| 
       64 
67 
     | 
    
         
             
                s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       65 
68 
     | 
    
         
             
                s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       66 
69 
     | 
    
         
             
                s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
      
 70 
     | 
    
         
            +
                s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
      
 71 
     | 
    
         
            +
                s.add_dependency(%q<rspec>, ["~> 2.1.0"])
         
     | 
| 
       67 
72 
     | 
    
         
             
                s.add_dependency(%q<nokogiri>, ["~> 1.4.3"])
         
     | 
| 
       68 
     | 
    
         
            -
                s.add_dependency(%q<httparty>, ["~> 0. 
     | 
| 
      
 73 
     | 
    
         
            +
                s.add_dependency(%q<httparty>, ["~> 0.6.1"])
         
     | 
| 
       69 
74 
     | 
    
         
             
                s.add_dependency(%q<activesupport>, [">= 2.3.2"])
         
     | 
| 
       70 
75 
     | 
    
         
             
              end
         
     | 
| 
       71 
76 
     | 
    
         
             
            end
         
     | 
    
        data/spec/moip_spec.rb
    CHANGED
    
    | 
         @@ -1,8 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         
             
            require "moip"
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            require "digest/sha1"
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
4 
     | 
    
         
             
            describe "Make payments with the MoIP API" do
         
     | 
| 
       7 
5 
     | 
    
         | 
| 
       8 
6 
     | 
    
         
             
              before :all do
         
     | 
| 
         @@ -28,233 +26,107 @@ describe "Make payments with the MoIP API" do 
     | 
|
| 
       28 
26 
     | 
    
         
             
                            :cep => "70100-000",
         
     | 
| 
       29 
27 
     | 
    
         
             
                            :tel_fixo => "(61)3211-1221" }
         
     | 
| 
       30 
28 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                @ 
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                @ 
     | 
| 
       34 
     | 
    
         
            -
                            :forma => "BoletoBancario", :pagador => @pagador ,
         
     | 
| 
       35 
     | 
    
         
            -
                            :razao=> "Pagamento" }
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                @debit = { :value => "8.90", :id_proprio => id, :forma => "DebitoBancario",
         
     | 
| 
       38 
     | 
    
         
            -
                           :instituicao => "BancoDoBrasil", :pagador => @pagador,
         
     | 
| 
       39 
     | 
    
         
            -
                           :razao => "Pagamento"}
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                @credit = { :value => "8.90", :id_proprio => id, :forma => "CartaoCredito",
         
     | 
| 
       42 
     | 
    
         
            -
                            :instituicao => "AmericanExpress",:numero => "345678901234564",
         
     | 
| 
       43 
     | 
    
         
            -
                            :expiracao => "08/11", :codigo_seguranca => "1234",
         
     | 
| 
       44 
     | 
    
         
            -
                            :nome => "João Silva", :identidade => "134.277.017.00",
         
     | 
| 
       45 
     | 
    
         
            -
                            :telefone => "(21)9208-0547", :data_nascimento => "25/10/1980",
         
     | 
| 
       46 
     | 
    
         
            -
                            :parcelas => "2", :recebimento => "AVista",
         
     | 
| 
       47 
     | 
    
         
            -
                            :pagador => @pagador, :razao => "Pagamento"}
         
     | 
| 
      
 29 
     | 
    
         
            +
                @billet = { :value => "8.90", :id_proprio => id, :forma => "BoletoBancario", :pagador => @pagador }
         
     | 
| 
      
 30 
     | 
    
         
            +
                @debit = { :value => "8.90", :id_proprio => id, :forma => "DebitoBancario", :instituicao => "BancoDoBrasil", :pagador => @pagador }
         
     | 
| 
      
 31 
     | 
    
         
            +
                @credit = { :value => "8.90", :id_proprio => id, :forma => "CartaoCredito", :instituicao => "AmericanExpress", :numero => "345678901234564", :expiracao => "08/11", :codigo_seguranca => "1234", :nome => "João Silva", :identidade => "134.277.017.00", :telefone => "(21)9208-0547", :data_nascimento => "25/10/1980", :parcelas => "2", :recebimento => "AVista", :pagador => @pagador }
         
     | 
| 
       48 
32 
     | 
    
         
             
              end
         
     | 
| 
       49 
33 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
              context "checkout" do
         
     | 
| 
       51 
     | 
    
         
            -
                 
     | 
| 
       52 
     | 
    
         
            -
                  MoIP 
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                                    { "ID"=>Time.now.strftime("%y%m%d%H%M%S"),
         
     | 
| 
       56 
     | 
    
         
            -
                                      "Status"=>"Sucesso",
         
     | 
| 
       57 
     | 
    
         
            -
                                      "Token" => "T2N0L0X8E0S71217U2H3W1T4F4S4G4K731D010V0S0V0S080M010E0Q082X2"
         
     | 
| 
       58 
     | 
    
         
            -
                                    }
         
     | 
| 
       59 
     | 
    
         
            -
                                 })
         
     | 
| 
      
 34 
     | 
    
         
            +
              context "make a billet checkout" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                it "should have status Sucesso" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                  MoIP.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>{ "Resposta"=>{ "ID"=>Time.now.strftime("%y%m%d%H%M%S"), "Status"=>"Sucesso", "Token" => "T2N0L0X8E0S71217U2H3W1T4F4S4G4K731D010V0S0V0S080M010E0Q082X2" }})
         
     | 
| 
      
 37 
     | 
    
         
            +
                  response = MoIP.checkout(@billet)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  response["Status"].should == "Sucesso"
         
     | 
| 
       60 
39 
     | 
    
         
             
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
       61 
41 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                   
     | 
| 
       66 
     | 
    
         
            -
                   
     | 
| 
      
 42 
     | 
    
         
            +
              context "make a debit checkout" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                it "should have status Sucesso" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  MoIP.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>{ "Resposta"=>{ "ID"=>Time.now.strftime("%y%m%d%H%M%S"), "Status"=>"Sucesso", "Token" => "T2N0L0X8E0S71217U2H3W1T4F4S4G4K731D010V0S0V0S080M010E0Q082X2" }})
         
     | 
| 
      
 45 
     | 
    
         
            +
                  response = MoIP.checkout(@debit)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  response["Status"].should == "Sucesso"
         
     | 
| 
       67 
47 
     | 
    
         
             
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
       68 
49 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                    raise_error(MoIP::MissingPaymentTypeError,error)
         
     | 
| 
       75 
     | 
    
         
            -
                  end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                  it "should have status 'Sucesso'" do
         
     | 
| 
       78 
     | 
    
         
            -
                    response = MoIP::Client.checkout(@billet)
         
     | 
| 
       79 
     | 
    
         
            -
                    response["Status"].should == "Sucesso"
         
     | 
| 
       80 
     | 
    
         
            -
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
              context "make a debit checkout without pass a institution" do
         
     | 
| 
      
 51 
     | 
    
         
            +
                it "should have status Falha" do
         
     | 
| 
      
 52 
     | 
    
         
            +
                  @incorrect_debit = { :value => "37.90", :id_proprio => id, :forma => "DebitoBancario", :pagador => @pagador }
         
     | 
| 
      
 53 
     | 
    
         
            +
                  MoIP.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>{ "Resposta"=>{"Status"=>"Falha", "Erro"=>"Pagamento direto não é possível com a instituição de pagamento enviada" }})
         
     | 
| 
      
 54 
     | 
    
         
            +
                  lambda { MoIP.checkout(@incorrect_debit) }.should raise_error(StandardError, "Pagamento direto não é possível com a instituição de pagamento enviada")
         
     | 
| 
       81 
55 
     | 
    
         
             
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
       82 
57 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
                  end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                  it "should have status 'Falha' when a instituition is not passed as argument" do
         
     | 
| 
       90 
     | 
    
         
            -
                    @incorrect_debit = { :value => "37.90", :id_proprio => id,
         
     | 
| 
       91 
     | 
    
         
            -
                                         :forma => "DebitoBancario", :pagador => @pagador,
         
     | 
| 
       92 
     | 
    
         
            -
                                         :razao => "Pagamento"}
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                    error = "Pagamento direto não é possível com a instituição de pagamento enviada"
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                    MoIP::Client.stub!(:post)
         
     | 
| 
       97 
     | 
    
         
            -
                        .and_return("ns1:EnviarInstrucaoUnicaResponse"=>
         
     | 
| 
       98 
     | 
    
         
            -
                                        { "Resposta"=>
         
     | 
| 
       99 
     | 
    
         
            -
                                            {
         
     | 
| 
       100 
     | 
    
         
            -
                                             "Status"=>"Falha",
         
     | 
| 
       101 
     | 
    
         
            -
                                             "Erro"=>error
         
     | 
| 
       102 
     | 
    
         
            -
                                            }
         
     | 
| 
       103 
     | 
    
         
            -
                                        })
         
     | 
| 
       104 
     | 
    
         
            -
                    error = "Pagamento direto não é possível com a instituição de pagamento enviada"
         
     | 
| 
       105 
     | 
    
         
            -
                    lambda { MoIP::Client.checkout(@incorrect_debit) }.should
         
     | 
| 
       106 
     | 
    
         
            -
                        raise_error(MoIP::WebServerResponseError, error)
         
     | 
| 
       107 
     | 
    
         
            -
                  end
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
                  it "should raise an exception if payer informations were not passed" do
         
     | 
| 
       110 
     | 
    
         
            -
                    @incorrect_debit = { :value => "37.90", :id_proprio => id,
         
     | 
| 
       111 
     | 
    
         
            -
                                         :forma => "DebitoBancario",
         
     | 
| 
       112 
     | 
    
         
            -
                                         :instituicao => "BancoDoBrasil",
         
     | 
| 
       113 
     | 
    
         
            -
                                         :razao => "Pagamento"
         
     | 
| 
       114 
     | 
    
         
            -
                                       }
         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
                    lambda { MoIP::Client.checkout(@incorrect_debit) }.should
         
     | 
| 
       117 
     | 
    
         
            -
                        raise_error(MoIP::MissingPayerError, "É obrigatório passar as informações do pagador")
         
     | 
| 
       118 
     | 
    
         
            -
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
              context "make a debit checkout without pass the payer informations" do
         
     | 
| 
      
 59 
     | 
    
         
            +
                it "should raise an exception" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                  @incorrect_debit = { :value => "37.90", :id_proprio => id, :forma => "DebitoBancario", :instituicao => "BancoDoBrasil" }
         
     | 
| 
      
 61 
     | 
    
         
            +
                  lambda { MoIP.checkout(@incorrect_debit) }.should raise_error(StandardError, "É obrigatório passar as informações do pagador")
         
     | 
| 
       119 
62 
     | 
    
         
             
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
       120 
64 
     | 
    
         | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                   
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                  it "should have status 'Falha' when the card informations were not passed as argument" do
         
     | 
| 
       128 
     | 
    
         
            -
                    @incorrect_credit = { :value => "8.90", :id_proprio => id,
         
     | 
| 
       129 
     | 
    
         
            -
                                          :forma => "CartaoCredito", :pagador => @pagador,
         
     | 
| 
       130 
     | 
    
         
            -
                                          :razao => "Pagamento"
         
     | 
| 
       131 
     | 
    
         
            -
                                        }
         
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
                    error = "Pagamento direto não é possível com a instituição de pagamento enviada"
         
     | 
| 
       134 
     | 
    
         
            -
                    MoIP::Client.stub!(:post)
         
     | 
| 
       135 
     | 
    
         
            -
                        .and_return("ns1:EnviarInstrucaoUnicaResponse"=>
         
     | 
| 
       136 
     | 
    
         
            -
                                    {
         
     | 
| 
       137 
     | 
    
         
            -
                                    "Resposta"=>
         
     | 
| 
       138 
     | 
    
         
            -
                                        {
         
     | 
| 
       139 
     | 
    
         
            -
                                         "Status"=>"Falha",
         
     | 
| 
       140 
     | 
    
         
            -
                                         "Erro"=>error
         
     | 
| 
       141 
     | 
    
         
            -
                                        }
         
     | 
| 
       142 
     | 
    
         
            -
                                    })
         
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
                    error = "Pagamento direto não é possível com a instituição de pagamento enviada"
         
     | 
| 
       145 
     | 
    
         
            -
                    lambda { MoIP::Client.checkout(@incorrect_credit) }.should
         
     | 
| 
       146 
     | 
    
         
            -
                        raise_error(MoIP::WebServerResponseError, error)
         
     | 
| 
       147 
     | 
    
         
            -
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
              context "make a credit card checkout" do
         
     | 
| 
      
 66 
     | 
    
         
            +
                it "should have status Sucesso" do
         
     | 
| 
      
 67 
     | 
    
         
            +
                  MoIP.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>{ "Resposta"=>{ "ID"=>Time.now.strftime("%y%m%d%H%M%S"), "Status"=>"Sucesso", "Token" => "T2N0L0X8E0S71217U2H3W1T4F4S4G4K731D010V0S0V0S080M010E0Q082X2" }})
         
     | 
| 
      
 68 
     | 
    
         
            +
                  response = MoIP.checkout(@credit)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  response["Status"].should == "Sucesso"
         
     | 
| 
       148 
70 
     | 
    
         
             
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
       149 
72 
     | 
    
         | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
                  end
         
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
                  it "should raise an exception if status is fail" do
         
     | 
| 
       158 
     | 
    
         
            -
                    MoIP::Client.stub!(:post)
         
     | 
| 
       159 
     | 
    
         
            -
                        .and_return("ns1:EnviarInstrucaoUnicaResponse"=>
         
     | 
| 
       160 
     | 
    
         
            -
                                    { "Resposta"=>
         
     | 
| 
       161 
     | 
    
         
            -
                                        {"Status"=>"Falha",
         
     | 
| 
       162 
     | 
    
         
            -
                                         "Erro"=>"O status da resposta é Falha"
         
     | 
| 
       163 
     | 
    
         
            -
                                        }
         
     | 
| 
       164 
     | 
    
         
            -
                                    })
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
                    lambda { MoIP::Client.checkout(@billet) }.should raise_error(StandardError, "O status da resposta é Falha")
         
     | 
| 
       167 
     | 
    
         
            -
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
              context "make a credit card checkout without pass card informations" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                it "should have status Falha" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                  @incorrect_credit = { :value => "8.90", :id_proprio => id, :forma => "CartaoCredito", :pagador => @pagador }
         
     | 
| 
      
 76 
     | 
    
         
            +
                  MoIP.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>{ "Resposta"=>{"Status"=>"Falha", "Erro"=>"Pagamento direto não é possível com a instituição de pagamento enviada" }})
         
     | 
| 
      
 77 
     | 
    
         
            +
                  lambda { MoIP.checkout(@incorrect_credit) }.should raise_error(StandardError, "Pagamento direto não é possível com a instituição de pagamento enviada")
         
     | 
| 
       168 
78 
     | 
    
         
             
                end
         
     | 
| 
       169 
79 
     | 
    
         
             
              end
         
     | 
| 
       170 
80 
     | 
    
         | 
| 
       171 
     | 
    
         
            -
              context " 
     | 
| 
       172 
     | 
    
         
            -
                 
     | 
| 
       173 
     | 
    
         
            -
                  MoIP 
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
                                { "RespostaConsultar"=>
         
     | 
| 
       176 
     | 
    
         
            -
                                    {"Status"=>"Sucesso",
         
     | 
| 
       177 
     | 
    
         
            -
                                     "ID"=>"201010291031001210000000046760"
         
     | 
| 
       178 
     | 
    
         
            -
                                    }
         
     | 
| 
       179 
     | 
    
         
            -
                                })
         
     | 
| 
      
 81 
     | 
    
         
            +
              context "in error scenario" do
         
     | 
| 
      
 82 
     | 
    
         
            +
                it "should raise an exception if response is nil" do
         
     | 
| 
      
 83 
     | 
    
         
            +
                  MoIP.stub!(:post).and_return(nil)
         
     | 
| 
      
 84 
     | 
    
         
            +
                  lambda { MoIP.checkout(@billet) }.should raise_error(StandardError, "Ocorreu um erro ao chamar o webservice")
         
     | 
| 
       180 
85 
     | 
    
         
             
                end
         
     | 
| 
       181 
86 
     | 
    
         | 
| 
       182 
     | 
    
         
            -
                it " 
     | 
| 
       183 
     | 
    
         
            -
                   
     | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
                  deprecations.should_not be_empty
         
     | 
| 
       186 
     | 
    
         
            -
                  deprecations.any? {|w| w =~ /MoIP.query has been deprecated/ }.should be_true
         
     | 
| 
      
 87 
     | 
    
         
            +
                it "should raise an exception if status is fail" do
         
     | 
| 
      
 88 
     | 
    
         
            +
                  MoIP.stub!(:post).and_return("ns1:EnviarInstrucaoUnicaResponse"=>{ "Resposta"=>{"Status"=>"Falha", "Erro"=>"O status da resposta é Falha" }})
         
     | 
| 
      
 89 
     | 
    
         
            +
                  lambda { MoIP.checkout(@billet) }.should raise_error(StandardError, "O status da resposta é Falha")
         
     | 
| 
       187 
90 
     | 
    
         
             
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
       188 
92 
     | 
    
         | 
| 
      
 93 
     | 
    
         
            +
              context "query a transaction token" do
         
     | 
| 
       189 
94 
     | 
    
         
             
                it "should retrieve the transaction" do
         
     | 
| 
       190 
     | 
    
         
            -
                   
     | 
| 
      
 95 
     | 
    
         
            +
                  MoIP.stub!(:get).and_return("ns1:ConsultarTokenResponse"=>{ "RespostaConsultar"=>{"Status"=>"Sucesso", "ID"=>"201010291031001210000000046760" }})
         
     | 
| 
      
 96 
     | 
    
         
            +
                  response = MoIP.query(token)
         
     | 
| 
       191 
97 
     | 
    
         
             
                  response["Status"].should == "Sucesso"
         
     | 
| 
       192 
98 
     | 
    
         
             
                end
         
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
       193 
100 
     | 
    
         | 
| 
       194 
     | 
    
         
            -
             
     | 
| 
       195 
     | 
    
         
            -
             
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
                                    { "RespostaConsultar"=>
         
     | 
| 
       199 
     | 
    
         
            -
                                        {"Status"=>"Falha",
         
     | 
| 
       200 
     | 
    
         
            -
                                         "Erro"=>"Instrução não encontrada",
         
     | 
| 
       201 
     | 
    
         
            -
                                         "ID"=>"201010291102522860000000046768"
         
     | 
| 
       202 
     | 
    
         
            -
                                        }
         
     | 
| 
       203 
     | 
    
         
            -
                                    })
         
     | 
| 
       204 
     | 
    
         
            -
                    query = "000000000000000000000000000000000000000000000000000000000000"
         
     | 
| 
       205 
     | 
    
         
            -
                    lambda { MoIP::Client.query(query) }.should raise_error(StandardError, "Instrução não encontrada")
         
     | 
| 
       206 
     | 
    
         
            -
                  end
         
     | 
| 
      
 101 
     | 
    
         
            +
              context "query a transaction token in a error scenario" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                it "should retrieve status Falha" do
         
     | 
| 
      
 103 
     | 
    
         
            +
                  MoIP.stub!(:get).and_return("ns1:ConsultarTokenResponse"=>{ "RespostaConsultar"=>{"Status"=>"Falha", "Erro"=>"Instrução não encontrada", "ID"=>"201010291102522860000000046768"}})
         
     | 
| 
      
 104 
     | 
    
         
            +
                  lambda { MoIP.query("000000000000000000000000000000000000000000000000000000000000") }.should raise_error(StandardError, "Instrução não encontrada")
         
     | 
| 
       207 
105 
     | 
    
         
             
                end
         
     | 
| 
       208 
106 
     | 
    
         
             
              end
         
     | 
| 
       209 
107 
     | 
    
         | 
| 
       210 
108 
     | 
    
         
             
              context "build the MoIP URL" do
         
     | 
| 
       211 
     | 
    
         
            -
                it "with old api should be deprecated" do
         
     | 
| 
       212 
     | 
    
         
            -
                  deprecations = collect_deprecations{ MoIP.moip_page(token) }
         
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
       214 
     | 
    
         
            -
                  deprecations.should_not be_empty
         
     | 
| 
       215 
     | 
    
         
            -
                  deprecations.any? {|w| w =~ /MoIP.moip_page has been deprecated/ }.should be_true
         
     | 
| 
       216 
     | 
    
         
            -
                end
         
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
109 
     | 
    
         
             
                it "should build the correct URL" do
         
     | 
| 
       219 
     | 
    
         
            -
                   
     | 
| 
       220 
     | 
    
         
            -
                  MoIP::Client.moip_page(token).should ==  page
         
     | 
| 
      
 110 
     | 
    
         
            +
                  MoIP.moip_page(token).should == "https://desenvolvedor.moip.com.br/sandbox/Instrucao.do?token=#{token}"
         
     | 
| 
       221 
111 
     | 
    
         
             
                end
         
     | 
| 
       222 
112 
     | 
    
         | 
| 
       223 
113 
     | 
    
         
             
                it "should raise an error if the token is not informed" do
         
     | 
| 
       224 
     | 
    
         
            -
                   
     | 
| 
       225 
     | 
    
         
            -
                  lambda { MoIP::Client.moip_page("").should
         
     | 
| 
       226 
     | 
    
         
            -
                      raise_error(ArgumentError, error) }
         
     | 
| 
      
 114 
     | 
    
         
            +
                  lambda { MoIP.moip_page("").should raise_error(ArgumentError, "É necessário informar um token para retornar os dados da transação") }
         
     | 
| 
       227 
115 
     | 
    
         
             
                end
         
     | 
| 
       228 
116 
     | 
    
         | 
| 
       229 
117 
     | 
    
         
             
                it "should raise an error if nil is passed as the token" do
         
     | 
| 
       230 
     | 
    
         
            -
                   
     | 
| 
       231 
     | 
    
         
            -
                  lambda { MoIP::Client.moip_page(nil).should
         
     | 
| 
       232 
     | 
    
         
            -
                      raise_error(ArgumentError, error) }
         
     | 
| 
      
 118 
     | 
    
         
            +
                  lambda { MoIP.moip_page(nil).should raise_error(ArgumentError, "É necessário informar um token para retornar os dados da transação") }
         
     | 
| 
       233 
119 
     | 
    
         
             
                end
         
     | 
| 
       234 
120 
     | 
    
         
             
              end
         
     | 
| 
       235 
121 
     | 
    
         | 
| 
       236 
122 
     | 
    
         
             
              context "when receive notification" do
         
     | 
| 
       237 
123 
     | 
    
         
             
                before(:each) do
         
     | 
| 
       238 
     | 
    
         
            -
                  @params = { "id_transacao" => "Pag62", "valor" => "8.90",
         
     | 
| 
       239 
     | 
    
         
            -
                              "status_pagamento" => "3", "cod_moip" => "001",
         
     | 
| 
       240 
     | 
    
         
            -
                              "forma_pagamento" => "73", "tipo_pagamento" => "BoletoBancario",
         
     | 
| 
       241 
     | 
    
         
            -
                              "email_consumidor" => "presidente@planalto.gov.br" }
         
     | 
| 
       242 
     | 
    
         
            -
                end
         
     | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
       244 
     | 
    
         
            -
                it "with old api should be deprecated" do
         
     | 
| 
       245 
     | 
    
         
            -
                  deprecations = collect_deprecations{ MoIP.notification(@param) }
         
     | 
| 
       246 
     | 
    
         
            -
             
     | 
| 
       247 
     | 
    
         
            -
                  deprecations.should_not be_empty
         
     | 
| 
       248 
     | 
    
         
            -
                  deprecations.any? {|w| w =~ /MoIP.notification has been deprecated/ }.should be_true
         
     | 
| 
      
 124 
     | 
    
         
            +
                  @params = { "id_transacao" => "Pag62", "valor" => "8.90", "status_pagamento" => "3", "cod_moip" => "001", "forma_pagamento" => "73", "tipo_pagamento" => "BoletoBancario", "email_consumidor" => "presidente@planalto.gov.br" }
         
     | 
| 
       249 
125 
     | 
    
         
             
                end
         
     | 
| 
       250 
126 
     | 
    
         | 
| 
       251 
127 
     | 
    
         
             
                it "should return a hash with the params extracted from NASP" do
         
     | 
| 
       252 
     | 
    
         
            -
                  response = { :transaction_id => "Pag62", :amount => "8.90",
         
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
                               :payment_type => "BoletoBancario",
         
     | 
| 
       255 
     | 
    
         
            -
                               :email => "presidente@planalto.gov.br" }
         
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
                  MoIP::Client.notification(@params).should == response
         
     | 
| 
      
 128 
     | 
    
         
            +
                  response = { :transaction_id => "Pag62", :amount => "8.90", :status => "printed", :code => "001", :payment_type => "BoletoBancario", :email => "presidente@planalto.gov.br" }
         
     | 
| 
      
 129 
     | 
    
         
            +
                  MoIP.notification(@params).should == response
         
     | 
| 
       258 
130 
     | 
    
         
             
                end
         
     | 
| 
       259 
131 
     | 
    
         | 
| 
       260 
132 
     | 
    
         
             
                it "should return valid status based on status code" do
         
     | 
| 
         @@ -275,15 +147,4 @@ describe "Make payments with the MoIP API" do 
     | 
|
| 
       275 
147 
     | 
    
         
             
                "T2X0Q1N021E0B2S9U1P0V3Y0G1F570Y2P4M0P000M0Z0F0J0G0U4N6C7W5T9"
         
     | 
| 
       276 
148 
     | 
    
         
             
              end
         
     | 
| 
       277 
149 
     | 
    
         | 
| 
       278 
     | 
    
         
            -
              def collect_deprecations
         
     | 
| 
       279 
     | 
    
         
            -
                old_behavior = ActiveSupport::Deprecation.behavior
         
     | 
| 
       280 
     | 
    
         
            -
                deprecations = []
         
     | 
| 
       281 
     | 
    
         
            -
                ActiveSupport::Deprecation.behavior = Proc.new do |message, callstack|
         
     | 
| 
       282 
     | 
    
         
            -
                  deprecations << message
         
     | 
| 
       283 
     | 
    
         
            -
                end
         
     | 
| 
       284 
     | 
    
         
            -
                result = yield
         
     | 
| 
       285 
     | 
    
         
            -
                deprecations
         
     | 
| 
       286 
     | 
    
         
            -
              ensure
         
     | 
| 
       287 
     | 
    
         
            -
                ActiveSupport::Deprecation.behavior = old_behavior
         
     | 
| 
       288 
     | 
    
         
            -
              end
         
     | 
| 
       289 
150 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -3,11 +3,11 @@ name: moip 
     | 
|
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
4 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
     | 
    
         
            -
              -  
     | 
| 
      
 6 
     | 
    
         
            +
              - 2
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 0
         
     | 
| 
       7 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              - 4
         
     | 
| 
       9 
9 
     | 
    
         
             
              segments_generated: true
         
     | 
| 
       10 
     | 
    
         
            -
              version:  
     | 
| 
      
 10 
     | 
    
         
            +
              version: 2.0.0
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Guilherme Nascimento
         
     | 
| 
         @@ -91,11 +91,41 @@ dependencies: 
     | 
|
| 
       91 
91 
     | 
    
         
             
                    segments_generated: true
         
     | 
| 
       92 
92 
     | 
    
         
             
                    version: 2.1.0
         
     | 
| 
       93 
93 
     | 
    
         
             
              requirement: *id005
         
     | 
| 
      
 94 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 95 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 96 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 97 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 98 
     | 
    
         
            +
              version_requirements: &id006 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 99 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 100 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 101 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 102 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 103 
     | 
    
         
            +
                    - 2
         
     | 
| 
      
 104 
     | 
    
         
            +
                    - 1
         
     | 
| 
      
 105 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 106 
     | 
    
         
            +
                    segments_generated: true
         
     | 
| 
      
 107 
     | 
    
         
            +
                    version: 2.1.0
         
     | 
| 
      
 108 
     | 
    
         
            +
              requirement: *id006
         
     | 
| 
      
 109 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 110 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 111 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 112 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 113 
     | 
    
         
            +
              version_requirements: &id007 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 114 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 115 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 116 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 117 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 118 
     | 
    
         
            +
                    - 2
         
     | 
| 
      
 119 
     | 
    
         
            +
                    - 1
         
     | 
| 
      
 120 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 121 
     | 
    
         
            +
                    segments_generated: true
         
     | 
| 
      
 122 
     | 
    
         
            +
                    version: 2.1.0
         
     | 
| 
      
 123 
     | 
    
         
            +
              requirement: *id007
         
     | 
| 
       94 
124 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       95 
125 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       96 
126 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       97 
127 
     | 
    
         
             
              name: nokogiri
         
     | 
| 
       98 
     | 
    
         
            -
              version_requirements: & 
     | 
| 
      
 128 
     | 
    
         
            +
              version_requirements: &id008 !ruby/object:Gem::Requirement 
         
     | 
| 
       99 
129 
     | 
    
         
             
                requirements: 
         
     | 
| 
       100 
130 
     | 
    
         
             
                - - ~>
         
     | 
| 
       101 
131 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
         @@ -105,27 +135,27 @@ dependencies: 
     | 
|
| 
       105 
135 
     | 
    
         
             
                    - 3
         
     | 
| 
       106 
136 
     | 
    
         
             
                    segments_generated: true
         
     | 
| 
       107 
137 
     | 
    
         
             
                    version: 1.4.3
         
     | 
| 
       108 
     | 
    
         
            -
              requirement: * 
     | 
| 
      
 138 
     | 
    
         
            +
              requirement: *id008
         
     | 
| 
       109 
139 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       110 
140 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       111 
141 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       112 
142 
     | 
    
         
             
              name: httparty
         
     | 
| 
       113 
     | 
    
         
            -
              version_requirements: & 
     | 
| 
      
 143 
     | 
    
         
            +
              version_requirements: &id009 !ruby/object:Gem::Requirement 
         
     | 
| 
       114 
144 
     | 
    
         
             
                requirements: 
         
     | 
| 
       115 
145 
     | 
    
         
             
                - - ~>
         
     | 
| 
       116 
146 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       117 
147 
     | 
    
         
             
                    segments: 
         
     | 
| 
       118 
148 
     | 
    
         
             
                    - 0
         
     | 
| 
       119 
     | 
    
         
            -
                    -  
     | 
| 
      
 149 
     | 
    
         
            +
                    - 6
         
     | 
| 
       120 
150 
     | 
    
         
             
                    - 1
         
     | 
| 
       121 
151 
     | 
    
         
             
                    segments_generated: true
         
     | 
| 
       122 
     | 
    
         
            -
                    version: 0. 
     | 
| 
       123 
     | 
    
         
            -
              requirement: * 
     | 
| 
      
 152 
     | 
    
         
            +
                    version: 0.6.1
         
     | 
| 
      
 153 
     | 
    
         
            +
              requirement: *id009
         
     | 
| 
       124 
154 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       125 
155 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       126 
156 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       127 
157 
     | 
    
         
             
              name: activesupport
         
     | 
| 
       128 
     | 
    
         
            -
              version_requirements: & 
     | 
| 
      
 158 
     | 
    
         
            +
              version_requirements: &id010 !ruby/object:Gem::Requirement 
         
     | 
| 
       129 
159 
     | 
    
         
             
                requirements: 
         
     | 
| 
       130 
160 
     | 
    
         
             
                - - ">="
         
     | 
| 
       131 
161 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
         @@ -135,7 +165,7 @@ dependencies: 
     | 
|
| 
       135 
165 
     | 
    
         
             
                    - 2
         
     | 
| 
       136 
166 
     | 
    
         
             
                    segments_generated: true
         
     | 
| 
       137 
167 
     | 
    
         
             
                    version: 2.3.2
         
     | 
| 
       138 
     | 
    
         
            -
              requirement: * 
     | 
| 
      
 168 
     | 
    
         
            +
              requirement: *id010
         
     | 
| 
       139 
169 
     | 
    
         
             
            description: "Gem para utiliza\xC3\xA7\xC3\xA3o da API MoIP"
         
     | 
| 
       140 
170 
     | 
    
         
             
            email: guilherme.ruby@gmail.com
         
     | 
| 
       141 
171 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -153,9 +183,8 @@ files: 
     | 
|
| 
       153 
183 
     | 
    
         
             
            - README.markdown
         
     | 
| 
       154 
184 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       155 
185 
     | 
    
         
             
            - VERSION
         
     | 
| 
      
 186 
     | 
    
         
            +
            - lib/direct_payment.rb
         
     | 
| 
       156 
187 
     | 
    
         
             
            - lib/moip.rb
         
     | 
| 
       157 
     | 
    
         
            -
            - lib/moip/client.rb
         
     | 
| 
       158 
     | 
    
         
            -
            - lib/moip/direct_payment.rb
         
     | 
| 
       159 
188 
     | 
    
         
             
            - moip.gemspec
         
     | 
| 
       160 
189 
     | 
    
         
             
            - spec/moip_spec.rb
         
     | 
| 
       161 
190 
     | 
    
         
             
            has_rdoc: true
         
     | 
    
        data/lib/moip/client.rb
    DELETED
    
    | 
         @@ -1,62 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
            require 'httparty'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module MoIP
         
     | 
| 
       5 
     | 
    
         
            -
              class WebServerResponseError < StandardError ; end
         
     | 
| 
       6 
     | 
    
         
            -
              class MissingTokenError < StandardError ; end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              class Client
         
     | 
| 
       9 
     | 
    
         
            -
                include HTTParty
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                base_uri "#{MoIP.uri}/ws/alpha"
         
     | 
| 
       12 
     | 
    
         
            -
                basic_auth MoIP.token, MoIP.key
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                class << self
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  # Envia uma instrução para pagamento único
         
     | 
| 
       17 
     | 
    
         
            -
                  def checkout(attributes = {})
         
     | 
| 
       18 
     | 
    
         
            -
                    full_data = peform_action!(:post, 'EnviarInstrucao/Unica', :body => DirectPayment.body(attributes))
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                    get_response!(full_data["ns1:EnviarInstrucaoUnicaResponse"]["Resposta"])
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  # Consulta dos dados das autorizações e pagamentos associados à Instrução
         
     | 
| 
       24 
     | 
    
         
            -
                  def query(token)
         
     | 
| 
       25 
     | 
    
         
            -
                    full_data = peform_action!(:get, "ConsultarInstrucao/#{token}")
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                    get_response!(full_data["ns1:ConsultarTokenResponse"]["RespostaConsultar"])
         
     | 
| 
       28 
     | 
    
         
            -
                  end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                  # Retorna a URL de acesso ao MoIP
         
     | 
| 
       31 
     | 
    
         
            -
                  def moip_page(token)
         
     | 
| 
       32 
     | 
    
         
            -
                    raise(MissingTokenError, "É necessário informar um token para retornar os dados da transação") if token.nil?
         
     | 
| 
       33 
     | 
    
         
            -
                    "#{MoIP.uri}/Instrucao.do?token=#{token}"
         
     | 
| 
       34 
     | 
    
         
            -
                  end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                  # Monta o NASP
         
     | 
| 
       37 
     | 
    
         
            -
                  def notification(params)
         
     | 
| 
       38 
     | 
    
         
            -
                    notification = {}
         
     | 
| 
       39 
     | 
    
         
            -
                    notification[:transaction_id] = params["id_transacao"]
         
     | 
| 
       40 
     | 
    
         
            -
                    notification[:amount]         = params["valor"]
         
     | 
| 
       41 
     | 
    
         
            -
                    notification[:status]         = MoIP::STATUS[params["status_pagamento"].to_i]
         
     | 
| 
       42 
     | 
    
         
            -
                    notification[:code]           = params["cod_moip"]
         
     | 
| 
       43 
     | 
    
         
            -
                    notification[:payment_type]   = params["tipo_pagamento"]
         
     | 
| 
       44 
     | 
    
         
            -
                    notification[:email]          = params["email_consumidor"]
         
     | 
| 
       45 
     | 
    
         
            -
                    notification
         
     | 
| 
       46 
     | 
    
         
            -
                  end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                  private
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                  def peform_action!(action_name, url, options = {})
         
     | 
| 
       51 
     | 
    
         
            -
                    response = self.send(action_name, url, options)
         
     | 
| 
       52 
     | 
    
         
            -
                    raise(WebServerResponseError, "Ocorreu um erro ao chamar o webservice") if response.nil?
         
     | 
| 
       53 
     | 
    
         
            -
                    response
         
     | 
| 
       54 
     | 
    
         
            -
                  end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                  def get_response!(data)
         
     | 
| 
       57 
     | 
    
         
            -
                    raise(WebServerResponseError, data["Erro"]) if data["Status"] == "Falha"
         
     | 
| 
       58 
     | 
    
         
            -
                    data
         
     | 
| 
       59 
     | 
    
         
            -
                  end
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
              end
         
     | 
| 
       62 
     | 
    
         
            -
            end
         
     |