<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/payments/manual_charge.html.erb</filename>
    </added>
    <added>
      <filename>db/test.sqlite3</filename>
    </added>
    <added>
      <filename>lib/tasks/rspec.rake</filename>
    </added>
    <added>
      <filename>script/autospec</filename>
    </added>
    <added>
      <filename>script/spec</filename>
    </added>
    <added>
      <filename>script/spec_server</filename>
    </added>
    <added>
      <filename>spec/lib/moip_spec.rb</filename>
    </added>
    <added>
      <filename>spec/rcov.opts</filename>
    </added>
    <added>
      <filename>spec/spec.opts</filename>
    </added>
    <added>
      <filename>spec/spec_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,12 +1,12 @@
 class PaymentsController &lt; ApplicationController
 
   def direct_charge
-    response = Moip.authorize(:reason=&gt;&quot;Teste&quot;,:id=&gt;&quot;15&quot;, :value=&gt;1)
+    response = Moip.authorize(:reason=&gt;&quot;Mensalidade&quot;,:id=&gt;&quot;62&quot;, :value=&gt;1)
     redirect_to Moip.charge_url(response)
   end
 
   def manual_charge
-    @response = Moip.authorize(:reason=&gt;&quot;Teste&quot;,:id=&gt;&quot;14&quot;, :value=&gt;1)
+    @response = Moip.authorize(:reason=&gt;&quot;Mensalidade&quot;,:id=&gt;&quot;60&quot;, :value=&gt;1)
   end
 
-end
\ No newline at end of file
+end</diff>
      <filename>app/controllers/payments_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+config.gem &quot;rspec&quot;, :version =&gt; '1.2.9'
+
 # Settings specified here will take precedence over those in config/environment.rb
 
 # The test environment is used exclusively to run your application's</diff>
      <filename>config/environments/test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,11 @@
 # you can find your token and api in https://desenvolvedor.moip.com.br/sandbox/AdmAPI.do?method=keys
-test:
-  uri: https://desenvolvedor.moip.com.br/sandbox/ws/alpha  
+development:
+  uri: https://desenvolvedor.moip.com.br/sandbox
   token: YOUR TOKEN
   key: YOUR KEY
 
-development:
-  uri: https://desenvolvedor.moip.com.br/sandbox/ws/alpha  
+test:
+  uri: https://desenvolvedor.moip.com.br/sandbox
   token: YOUR TOKEN
   key: YOUR KEY
 </diff>
      <filename>config/sample.gateway.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,42 +1,40 @@
 class Moip
   include HTTParty
-  CONFIG      = YAML.load_file(File.join(RAILS_ROOT, 'config', 'gateway.yml'))[RAILS_ENV]
+  CONFIG = YAML.load_file(File.join(RAILS_ROOT, 'config', 'gateway.yml'))[RAILS_ENV]
 
-  base_uri CONFIG[&quot;uri&quot;]
+  base_uri &quot;#{CONFIG[&quot;uri&quot;]}/ws/alpha&quot;
   basic_auth CONFIG[&quot;token&quot;], CONFIG[&quot;key&quot;]
 
-  cattr_accessor :test_url
-  self.test_url = 'https://desenvolvedor.moip.com.br/sandbox'
-
-  cattr_accessor :production_url
-  self.production_url = 'https://moip.com.br'
+  class &lt;&lt; self
+    def authorize(attributes = {})
+      xml = mount_request(attributes)
+      response = post('/EnviarInstrucao/Unica', :body =&gt; xml)
+      raise(StandardError, &quot;Webservice can't be reached&quot;) if response.nil?
+      response = response[&quot;ns1:EnviarInstrucaoUnicaResponse&quot;]
+      raise(StandardError, response[&quot;Resposta&quot;][&quot;Erro&quot;]) if response[&quot;Resposta&quot;][&quot;Status&quot;] == &quot;Falha&quot;
+      response
+    end
 
-  def self.authorize(attributes = {})
-    reason,id,value = attributes[:reason], attributes[:id], attributes[:value]
+    def charge_url(response)
+      &quot;#{CONFIG[&quot;uri&quot;]}/Instrucao.do?token=#{response[&quot;Resposta&quot;][&quot;Token&quot;]}&quot;
+    end
 
-    xml = Builder::XmlMarkup.new.EnviarInstrucao do |e|
-      e.InstrucaoUnica do |i|
-        i.Razao reason
-        i.IdProprio id
-        i.Valores {|v| v.Valor(value, :moeda=&gt;&quot;BRL&quot;)}
-        i.FormasPagamento do |p|
-          p.FormaPagamento &quot;BoletoBancario&quot;
-          p.FormaPagamento &quot;CartaoCredito&quot;
+  protected
+    def mount_request(attributes)
+      reason, id, value = attributes[:reason], attributes[:id], attributes[:value]
+      xml = Builder::XmlMarkup.new.EnviarInstrucao do |e|
+        e.InstrucaoUnica do |i|
+          i.Razao reason
+          i.IdProprio id
+          i.Valores {|v| v.Valor(value, :moeda=&gt;&quot;BRL&quot;)}
+          i.FormasPagamento { |p|
+            p.FormaPagamento &quot;BoletoBancario&quot;
+            p.FormaPagamento &quot;CartaoCredito&quot;
+          }
         end
       end
     end
 
-    response = post('/EnviarInstrucao/Unica', :body =&gt; xml)[&quot;ns1:EnviarInstrucaoUnicaResponse&quot;]
-    raise(StandardError, &quot;Webservice can't be reached&quot;) if response.nil?
-    (response[&quot;Resposta&quot;][&quot;Status&quot;] == &quot;Falha&quot;) ? raise(StandardError, response[&quot;Resposta&quot;][&quot;Erro&quot;]) : response
-  end
-
-  def self.charge_url(response)
-    if [RAILS_ENV] != &quot;production&quot;
-      &quot;#{self.test_url}/Instrucao.do?token=#{response[&quot;Resposta&quot;][&quot;Token&quot;]}&quot;
-    else
-      &quot;#{self.production_url}/Instrucao.do?token=#{response[&quot;Resposta&quot;][&quot;Token&quot;]}&quot;
-    end
   end
 
 end
\ No newline at end of file</diff>
      <filename>lib/moip.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>22862e80ab30edf1f548471e21f78eb0d139b5b0</id>
    </parent>
  </parents>
  <author>
    <name>Daniel Lopes</name>
    <email>danielvlopes@gmail.com</email>
  </author>
  <url>http://github.com/danielvlopes/moip_usage/commit/0899d29d22100585b6509c01d1e0ff16b578be3c</url>
  <id>0899d29d22100585b6509c01d1e0ff16b578be3c</id>
  <committed-date>2009-11-02T09:51:43-08:00</committed-date>
  <authored-date>2009-11-02T09:51:43-08:00</authored-date>
  <message>add specs and made a little refactoring in moip class</message>
  <tree>971dff5548538ef7eba61d0e84ead31d62dc1bb5</tree>
  <committer>
    <name>Daniel Lopes</name>
    <email>danielvlopes@gmail.com</email>
  </committer>
</commit>
