ipiranga 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ipiranga.rb +2 -1
- data/lib/ipiranga/client.rb +4 -0
- data/lib/ipiranga/clients/km.rb +23 -0
- data/lib/ipiranga/{clients.rb → clients/pf.rb} +10 -7
- data/lib/ipiranga/error.rb +1 -11
- data/lib/ipiranga/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ba581b8afe71d12ded58bfea512196e1684cbd6
|
4
|
+
data.tar.gz: 41d7b838b54c7720f726327d56184bd9a7eee037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd523ead6de24192b77a2eb7e983f455d0ebbbeaa176aa56a3a5c925be7c0f93ea0f3bbd165a1ed72f4feee3f9aad13f9afd7254bc5342fee326bfd011b92180
|
7
|
+
data.tar.gz: dbea4913f2c2eaede45650b48f31ea1f88e1c72895f7a1e030d7f57567109b2d9a2caa9f6b3e9bd3a70bd097e945095a625f491f33ad1671b1b0430411a818fe
|
data/lib/ipiranga.rb
CHANGED
data/lib/ipiranga/client.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'ipiranga/client'
|
2
|
+
|
3
|
+
module Ipiranga
|
4
|
+
class KM < Client
|
5
|
+
def wsdl_url
|
6
|
+
if defined?(RAILS_ENV) && RAILS_ENV == "production"
|
7
|
+
"https://b2b.ipiranga.com.br/csp/ensb2cws/cbpi.bs.km.pedido.Service.CLS?WSDL=1"
|
8
|
+
else
|
9
|
+
"https://b2bdv.ipiranga.com.br/csp/ensb2cws/cbpi.bs.km.pedido.Service.CLS?WSDL=1"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def gerarPedidoAcumulo(&block)
|
14
|
+
result = post_gerarPedidoAcumulo(&block).
|
15
|
+
body_hash["gerarPedidoAcumuloResult"]
|
16
|
+
|
17
|
+
raise RequestAlreadyExists.new(result) if result["codigoRetorno"] == "2"
|
18
|
+
raise ::Exception.new(result) if result["codigoRetorno"] != "0"
|
19
|
+
|
20
|
+
return result["codigoRequisicao"].to_i
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -13,7 +13,7 @@ module Ipiranga
|
|
13
13
|
def cadastrar(&block)
|
14
14
|
result = post_cadastrar(&block).body_hash["cadastrarResult"]
|
15
15
|
|
16
|
-
|
16
|
+
raise_exception(result) if result["status"].nil? || result["status"] == "false"
|
17
17
|
|
18
18
|
if result["status"] == "true" && result["statusMimetica"] == "2"
|
19
19
|
raise UserAlreadyExists.new(result)
|
@@ -21,14 +21,17 @@ module Ipiranga
|
|
21
21
|
|
22
22
|
return result["statusMimetica"] == "0"
|
23
23
|
end
|
24
|
-
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.raise_exception(result)
|
28
|
+
case result["msgErro"]
|
29
|
+
when "Usuario/Password Inválido"
|
30
|
+
raise InvalidCredentials.new(result)
|
31
|
+
when "Erro interno"
|
32
|
+
raise InternalError.new(result)
|
30
33
|
else
|
31
|
-
|
34
|
+
raise ::Exception.new(result)
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
data/lib/ipiranga/error.rb
CHANGED
@@ -20,18 +20,8 @@ module Ipiranga
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
class RequestAlreadyExists < ::Exception; end
|
23
24
|
class UserAlreadyExists < ::Exception; end
|
24
25
|
class InvalidCredentials < ::Exception; end
|
25
26
|
class InternalError < ::Exception; end
|
26
|
-
|
27
|
-
def self.raise_exception(result)
|
28
|
-
case result["msgErro"]
|
29
|
-
when "Usuario/Password Inválido"
|
30
|
-
raise InvalidCredentials.new(result)
|
31
|
-
when "Erro interno"
|
32
|
-
raise InternalError.new(result)
|
33
|
-
else
|
34
|
-
raise ::Exception.new(result)
|
35
|
-
end
|
36
|
-
end
|
37
27
|
end
|
data/lib/ipiranga/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amadeus Folego
|
@@ -73,10 +73,11 @@ extensions: []
|
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
75
|
- lib/ipiranga.rb
|
76
|
+
- lib/ipiranga/clients/km.rb
|
77
|
+
- lib/ipiranga/clients/pf.rb
|
76
78
|
- lib/ipiranga/version.rb
|
77
79
|
- lib/ipiranga/client.rb
|
78
80
|
- lib/ipiranga/error.rb
|
79
|
-
- lib/ipiranga/clients.rb
|
80
81
|
homepage: https://github.com/badosu/Ipiranga
|
81
82
|
licenses:
|
82
83
|
- MIT
|