ipiranga 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/ipiranga/client.rb +12 -5
- data/lib/ipiranga/clients.rb +10 -2
- data/lib/ipiranga/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 08d53fcc4e3d29112a29bfa4702d031a823496a2
         | 
| 4 | 
            +
              data.tar.gz: 144b0ef60e32d2bcca2ceec3bfe9f3d1de5e0cf6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 684918b0a427019856bfe0cf393b35162cc1b6304dd1ecd32f0208f92e94cb3986a1268580ba6a278f5cdc35278762cd00992115e757e172bdd381dde3f1909a
         | 
| 7 | 
            +
              data.tar.gz: b45e72d87183ed9f9efa34bed3b663c360bb44c90e248f89e4e393e99b51d653e70367251d49f932ba4f72d77444c42faf9d9f200ad20686007498b0247d5377
         | 
    
        data/lib/ipiranga/client.rb
    CHANGED
    
    | @@ -6,13 +6,14 @@ require 'akami' | |
| 6 6 |  | 
| 7 7 | 
             
            module Ipiranga
         | 
| 8 8 | 
             
              class Client
         | 
| 9 | 
            -
                attr_reader : | 
| 10 | 
            -
                attr_accessor :username, :password
         | 
| 9 | 
            +
                attr_reader :soap, :wsdl_url
         | 
| 10 | 
            +
                attr_accessor :wsdl, :username, :password
         | 
| 11 11 |  | 
| 12 12 | 
             
                def initialize(opts = {})
         | 
| 13 | 
            -
                  @wsdl_url = URI(opts.fetch(: | 
| 13 | 
            +
                  @wsdl_url = URI(opts.fetch(:wsdl_url, wsdl_url))
         | 
| 14 14 | 
             
                  @username = opts[:username]
         | 
| 15 15 | 
             
                  @password = opts[:password]
         | 
| 16 | 
            +
                  @wsdl = opts[:wsdl]
         | 
| 16 17 |  | 
| 17 18 | 
             
                  operations.each do |operation|
         | 
| 18 19 | 
             
                    define_singleton_method(operation) do |&block|
         | 
| @@ -33,10 +34,16 @@ module Ipiranga | |
| 33 34 | 
             
                  soap.wsdl.operations.keys
         | 
| 34 35 | 
             
                end
         | 
| 35 36 |  | 
| 37 | 
            +
                def operation(key)
         | 
| 38 | 
            +
                  soap.wsdl.operations[key]
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 36 41 | 
             
                def post(operation)
         | 
| 37 42 | 
             
                  request = soap.request(operation)
         | 
| 38 43 |  | 
| 39 | 
            -
                   | 
| 44 | 
            +
                  pRequest = request.body.pRequest
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                  yield pRequest if block_given?
         | 
| 40 47 |  | 
| 41 48 | 
             
                  append_wsse(request) if has_credentials?
         | 
| 42 49 |  | 
| @@ -45,7 +52,7 @@ module Ipiranga | |
| 45 52 | 
             
                  http.use_ssl = true
         | 
| 46 53 | 
             
                  http_response = http.post(uri.path.gsub(".cls", ".CLS"), request.content, request.headers)
         | 
| 47 54 |  | 
| 48 | 
            -
                  soap.response(request, http_response.body) | 
| 55 | 
            +
                  soap.response(request, http_response.body)
         | 
| 49 56 | 
             
                end
         | 
| 50 57 |  | 
| 51 58 | 
             
                def has_credentials?
         | 
    
        data/lib/ipiranga/clients.rb
    CHANGED
    
    | @@ -3,13 +3,21 @@ require 'ipiranga/client' | |
| 3 3 | 
             
            module Ipiranga
         | 
| 4 4 | 
             
              class PF < Client
         | 
| 5 5 | 
             
                def wsdl_url
         | 
| 6 | 
            -
                   | 
| 6 | 
            +
                  if defined?(RAILS_ENV) && RAILS_ENV == "production"
         | 
| 7 | 
            +
                    "https://b2b.ipiranga.com.br/csp/ensb2cws/cbpi.bs.participantePF.Service.CLS?WSDL=1"
         | 
| 8 | 
            +
                  else
         | 
| 9 | 
            +
                    "https://b2bdv.ipiranga.com.br/csp/ensb2cws/cbpi.bs.participantePF.Service.CLS?WSDL=1"
         | 
| 10 | 
            +
                  end
         | 
| 7 11 | 
             
                end
         | 
| 8 12 | 
             
              end
         | 
| 9 13 |  | 
| 10 14 | 
             
              class KM < Client
         | 
| 11 15 | 
             
                def wsdl_url
         | 
| 12 | 
            -
                   | 
| 16 | 
            +
                  if defined?(RAILS_ENV) && RAILS_ENV == "production"
         | 
| 17 | 
            +
                    "https://b2b.ipiranga.com.br/csp/ensb2cws/cbpi.bs.km.pedido.Service.CLS?WSDL=1"
         | 
| 18 | 
            +
                  else
         | 
| 19 | 
            +
                    "https://b2bdv.ipiranga.com.br/csp/ensb2cws/cbpi.bs.km.pedido.Service.CLS?WSDL=1"
         | 
| 20 | 
            +
                  end
         | 
| 13 21 | 
             
                end
         | 
| 14 22 | 
             
              end
         | 
| 15 23 | 
             
            end
         | 
    
        data/lib/ipiranga/version.rb
    CHANGED