ipiranga 0.0.3 → 0.0.4
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.rb +1 -0
- data/lib/ipiranga/client.rb +2 -2
- data/lib/ipiranga/clients.rb +12 -0
- data/lib/ipiranga/error.rb +37 -0
- data/lib/ipiranga/version.rb +1 -8
- metadata +30 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9d4546ea3d7360b5f7d3eec0fb9204a1d606241
|
4
|
+
data.tar.gz: f288c690eb211d14154b291c89f9e0c954412607
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285fe5be93c5767b47a56cc2cccca98092b64ec9a595e39229c2dadafc4a4f2980616a655db51d807cc390f3e8afa96fda56c288e8d81cb780433bf56d4fd712
|
7
|
+
data.tar.gz: b9a547b0ac2f5d10ad248428c19a3dc7e0195867adf8146dd65e1f7e50d4bc18e9bc1bbb6ad910d3236ab62f2467fd805122804086954fd7da45cbedfa56fefc
|
data/lib/ipiranga.rb
CHANGED
data/lib/ipiranga/client.rb
CHANGED
@@ -16,7 +16,7 @@ module Ipiranga
|
|
16
16
|
@wsdl = opts[:wsdl]
|
17
17
|
|
18
18
|
operations.each do |operation|
|
19
|
-
define_singleton_method(operation) do |&block|
|
19
|
+
define_singleton_method("post_#{operation}") do |&block|
|
20
20
|
post(operation, &block)
|
21
21
|
end
|
22
22
|
end
|
@@ -52,7 +52,7 @@ module Ipiranga
|
|
52
52
|
http.use_ssl = true
|
53
53
|
http_response = http.post(uri.path.gsub(".cls", ".CLS"), request.content, request.headers)
|
54
54
|
|
55
|
-
soap.response(request, http_response.body)
|
55
|
+
soap.response(request, http_response.body)
|
56
56
|
end
|
57
57
|
|
58
58
|
def has_credentials?
|
data/lib/ipiranga/clients.rb
CHANGED
@@ -9,6 +9,18 @@ module Ipiranga
|
|
9
9
|
"https://b2bdv.ipiranga.com.br/csp/ensb2cws/cbpi.bs.participantePF.Service.CLS?WSDL=1"
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def cadastrar(&block)
|
14
|
+
result = post_cadastrar(&block).body_hash["cadastrarResult"]
|
15
|
+
|
16
|
+
Ipiranga.raise_exception(result) if result["status"].nil? || result["status"] == "false"
|
17
|
+
|
18
|
+
if result["status"] == "true" && result["statusMimetica"] == "2"
|
19
|
+
raise UserAlreadyExists.new(result)
|
20
|
+
end
|
21
|
+
|
22
|
+
return result["statusMimetica"] == "0"
|
23
|
+
end
|
12
24
|
end
|
13
25
|
|
14
26
|
class KM < Client
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Ipiranga
|
2
|
+
class Exception < StandardError
|
3
|
+
attr_accessor :result
|
4
|
+
|
5
|
+
def initialize(error)
|
6
|
+
if error.kind_of?(String)
|
7
|
+
super(error)
|
8
|
+
else
|
9
|
+
@result = error
|
10
|
+
super(error["msgErro"])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect
|
15
|
+
"#{message}#{" - response: #{result.inspect}" unless result.nil?}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
inspect
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class UserAlreadyExists < ::Exception; end
|
24
|
+
class InvalidCredentials < ::Exception; end
|
25
|
+
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
|
+
end
|
data/lib/ipiranga/version.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
module Ipiranga
|
2
|
-
# Major version number
|
3
|
-
MAJOR = 0
|
4
|
-
# Minor version number
|
5
|
-
MINOR = 0
|
6
|
-
# Tiny version number
|
7
|
-
TINY = 3
|
8
|
-
|
9
2
|
# Joins the version numbers
|
10
|
-
VERSION = [
|
3
|
+
VERSION = [0, 0, 4].join('.')
|
11
4
|
|
12
5
|
# Returns {VERSION}
|
13
6
|
# @return [String]
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amadeus Folego
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.5
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.5
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-meta
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.5
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.5
|
41
69
|
description: A simple Ipiranga Web Services Client
|
42
70
|
email: amadeusfolego@gmail.com
|
43
71
|
executables: []
|
@@ -47,6 +75,7 @@ files:
|
|
47
75
|
- lib/ipiranga.rb
|
48
76
|
- lib/ipiranga/version.rb
|
49
77
|
- lib/ipiranga/client.rb
|
78
|
+
- lib/ipiranga/error.rb
|
50
79
|
- lib/ipiranga/clients.rb
|
51
80
|
homepage: https://github.com/badosu/Ipiranga
|
52
81
|
licenses:
|