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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de47785dc4e54740f84889c72eea0c4e544cd9cd
4
- data.tar.gz: 996bd90a549b975e9b30e113e6eb18d05f7fab97
3
+ metadata.gz: 08d53fcc4e3d29112a29bfa4702d031a823496a2
4
+ data.tar.gz: 144b0ef60e32d2bcca2ceec3bfe9f3d1de5e0cf6
5
5
  SHA512:
6
- metadata.gz: 5b5843892980ba32c1d0b4836b26d79db92069242686576532d373be6f78790ab40ce5b82628fa0a45531c2832f8ce3d6ab4b588c0afbea52282f67435cf4d19
7
- data.tar.gz: 2b7d9ef6c35334a507e51ef9f37083ba2bf900ce52292f1ee28e74655c8d2358a2dfbeffddc79be68947be8a69327900a3e9f1e856744a75852989a187d31027
6
+ metadata.gz: 684918b0a427019856bfe0cf393b35162cc1b6304dd1ecd32f0208f92e94cb3986a1268580ba6a278f5cdc35278762cd00992115e757e172bdd381dde3f1909a
7
+ data.tar.gz: b45e72d87183ed9f9efa34bed3b663c360bb44c90e248f89e4e393e99b51d653e70367251d49f932ba4f72d77444c42faf9d9f200ad20686007498b0247d5377
@@ -6,13 +6,14 @@ require 'akami'
6
6
 
7
7
  module Ipiranga
8
8
  class Client
9
- attr_reader :wsdl, :soap, :wsdl_url
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(:wsdl, wsdl_url))
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
- yield request.body if block_given?
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).body_hash
55
+ soap.response(request, http_response.body)
49
56
  end
50
57
 
51
58
  def has_credentials?
@@ -3,13 +3,21 @@ require 'ipiranga/client'
3
3
  module Ipiranga
4
4
  class PF < Client
5
5
  def wsdl_url
6
- "https://b2bdv.ipiranga.com.br/csp/ensb2cws/cbpi.bs.participantePF.Service.CLS?WSDL=1"
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
- "https://b2bdv.ipiranga.com.br/csp/ensb2cws/cbpi.bs.km.pedido.Service.CLS?WSDL=1"
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
@@ -4,7 +4,7 @@ module Ipiranga
4
4
  # Minor version number
5
5
  MINOR = 0
6
6
  # Tiny version number
7
- TINY = 1
7
+ TINY = 2
8
8
 
9
9
  # Joins the version numbers
10
10
  VERSION = [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipiranga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amadeus Folego