gus_bir1 1.3.0 → 1.4.0
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/.github/workflows/ci.yml +1 -1
- data/README.md +4 -0
- data/gus_bir1.gemspec +2 -2
- data/lib/gus_bir1/client.rb +28 -24
- data/lib/gus_bir1/version.rb +1 -1
- metadata +5 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e150cc608515def79527b5145c7d97acf9327c4fbb6fb94e164bb4a81d2d3ca0
|
|
4
|
+
data.tar.gz: 4f9fdb5c6997aef43a11726a0e745f5dc76ed4d273e8043da68ef90279a9cb4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5babed383a6565f4ade0d8b6cc1ee94df17ff8db43958a28d39e4029b71ae04bc00faa90cfc01fbadfb65765ebb26b5fad6749db8d353cd925956d0c7986bf13
|
|
7
|
+
data.tar.gz: 37eee6c052217ebe11b5ef965bee6da2490241c26fdd90057efe0299e3eeeb4dc6671c67f88d2cf3aee2fa1b84bb86e187ff2682031480d5d35c3a7030a8df7e
|
data/.github/workflows/ci.yml
CHANGED
data/README.md
CHANGED
|
@@ -35,6 +35,10 @@ Or install it yourself as:
|
|
|
35
35
|
# TEST CONF
|
|
36
36
|
GusBir1.production = false
|
|
37
37
|
GusBir1.client_key = 'abcde12345abcde12345'
|
|
38
|
+
|
|
39
|
+
# Optional, disabled by default. Enable Savon/HTTPI debug logging:
|
|
40
|
+
GusBir1.logging = true
|
|
41
|
+
GusBir1.log_level = :debug
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
### General info
|
data/gus_bir1.gemspec
CHANGED
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.summary = 'Rails GUS API library based on official REGON SOAP api.'
|
|
14
14
|
spec.homepage = 'https://github.com/espago/gus_bir1'
|
|
15
15
|
spec.license = 'MIT'
|
|
16
|
+
spec.required_ruby_version = '>= 3.2.0'
|
|
16
17
|
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
19
|
f.match(%r{^(test|spec|features)/})
|
|
@@ -27,6 +28,5 @@ Gem::Specification.new do |spec|
|
|
|
27
28
|
spec.add_development_dependency 'rubocop'
|
|
28
29
|
spec.add_development_dependency 'simplecov'
|
|
29
30
|
|
|
30
|
-
spec.add_dependency 'savon', '~> 2.
|
|
31
|
-
spec.add_dependency 'savon-multipart'
|
|
31
|
+
spec.add_dependency 'savon', '~> 2.17.4'
|
|
32
32
|
end
|
data/lib/gus_bir1/client.rb
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'savon'
|
|
4
|
+
|
|
3
5
|
module GusBir1
|
|
4
6
|
class Client
|
|
5
7
|
SESSION_TIMEOUT = 3600
|
|
8
|
+
PUBL_OPERATIONS = %i[
|
|
9
|
+
wyloguj
|
|
10
|
+
dane_szukaj_podmioty
|
|
11
|
+
dane_pobierz_pelny_raport
|
|
12
|
+
dane_komunikat
|
|
13
|
+
zaloguj
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
6
16
|
attr_accessor :production, :client_key, :log_level, :logging
|
|
7
17
|
|
|
18
|
+
def initialize
|
|
19
|
+
@logging = false
|
|
20
|
+
end
|
|
21
|
+
|
|
8
22
|
def service_status
|
|
9
23
|
v = get_value(Constants::PARAM_PARAM_NAME => Constants::PARAM_SERVICE_STATUS)
|
|
10
24
|
Response::Simple.new(v, Constants::PARAM_SERVICE_STATUS)
|
|
@@ -25,6 +39,7 @@ module GusBir1
|
|
|
25
39
|
types = [nip, regon, krs, nips, krss, regons14, regons9].compact
|
|
26
40
|
raise TooMuchTypesSelected if types.size > 1
|
|
27
41
|
raise NoOneTypeSelected if types.empty?
|
|
42
|
+
|
|
28
43
|
if nip
|
|
29
44
|
search_by Constants::SEARCH_TYPE_NIP, nip
|
|
30
45
|
elsif regon
|
|
@@ -73,13 +88,14 @@ module GusBir1
|
|
|
73
88
|
|
|
74
89
|
def namespaces(publ: true)
|
|
75
90
|
{
|
|
76
|
-
'xmlns:ns' =>
|
|
91
|
+
'xmlns:ns' => publ ? Constants::WSDL_NS_PUBL : Constants::WSDL_NS,
|
|
77
92
|
'xmlns:dat' => Constants::WSDL_NS_DATA_CONTRACT
|
|
78
93
|
}
|
|
79
94
|
end
|
|
80
95
|
|
|
81
96
|
def endpoint
|
|
82
97
|
return Constants::WSDL_ADDRESS if @production
|
|
98
|
+
|
|
83
99
|
Constants::WSDL_ADDRESS_TEST
|
|
84
100
|
end
|
|
85
101
|
|
|
@@ -93,21 +109,13 @@ module GusBir1
|
|
|
93
109
|
end
|
|
94
110
|
|
|
95
111
|
def call(method, message)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
:wyloguj,
|
|
99
|
-
:dane_szukaj_podmioty,
|
|
100
|
-
:dane_pobierz_pelny_raport,
|
|
101
|
-
:dane_komunikat,
|
|
102
|
-
:zaloguj
|
|
103
|
-
savon_client_publ.call(method, message: message)
|
|
104
|
-
else
|
|
105
|
-
savon_client.call(method, message: message)
|
|
106
|
-
end
|
|
112
|
+
client = PUBL_OPERATIONS.include?(method) ? savon_client_publ : savon_client
|
|
113
|
+
client.call(method, message: message)
|
|
107
114
|
end
|
|
108
115
|
|
|
109
116
|
def set_session_id
|
|
110
117
|
return @sid if sid_active
|
|
118
|
+
|
|
111
119
|
@sid_exp = Time.now + SESSION_TIMEOUT
|
|
112
120
|
@sid = zaloguj(Constants::PARAM_USER_KEY => @client_key)
|
|
113
121
|
clear_savon_clients
|
|
@@ -126,15 +134,20 @@ module GusBir1
|
|
|
126
134
|
|
|
127
135
|
def logout
|
|
128
136
|
return unless sid_active
|
|
137
|
+
|
|
129
138
|
wyloguj(Constants::PARAM_SESSION_ID => @sid)
|
|
130
139
|
end
|
|
131
140
|
|
|
132
141
|
def savon_client_publ
|
|
133
|
-
@savon_client_publ ||=
|
|
142
|
+
@savon_client_publ ||= build_savon_client(publ: true)
|
|
134
143
|
end
|
|
135
144
|
|
|
136
145
|
def savon_client
|
|
137
|
-
@savon_client ||=
|
|
146
|
+
@savon_client ||= build_savon_client(publ: false)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def build_savon_client(publ: false)
|
|
150
|
+
Savon.client(savon_options(publ: publ))
|
|
138
151
|
end
|
|
139
152
|
|
|
140
153
|
def savon_options(publ: false)
|
|
@@ -146,14 +159,11 @@ module GusBir1
|
|
|
146
159
|
soap_version: 2,
|
|
147
160
|
namespace_identifier: :ns,
|
|
148
161
|
element_form_default: :qualified,
|
|
149
|
-
multipart: true,
|
|
150
162
|
log_level: @log_level,
|
|
151
163
|
log: @logging,
|
|
152
164
|
proxy: ENV['GUS_BIR_PROXY_URL']
|
|
153
165
|
}
|
|
154
|
-
if defined?(@sid) && @sid.nil? == false
|
|
155
|
-
params.merge!({headers: { sid: @sid } })
|
|
156
|
-
end
|
|
166
|
+
params.merge!({ headers: { sid: @sid } }) if defined?(@sid) && @sid.nil? == false
|
|
157
167
|
params
|
|
158
168
|
end
|
|
159
169
|
|
|
@@ -161,11 +171,5 @@ module GusBir1
|
|
|
161
171
|
@savon_client = nil
|
|
162
172
|
@savon_client_publ = nil
|
|
163
173
|
end
|
|
164
|
-
|
|
165
|
-
def savon_api_client
|
|
166
|
-
@savon_api_client ||= GusBir1::SavonApiClient.new
|
|
167
|
-
end
|
|
168
174
|
end
|
|
169
175
|
end
|
|
170
|
-
require 'savon'
|
|
171
|
-
require 'savon-multipart'
|
data/lib/gus_bir1/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gus_bir1
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Waclaw Luczak
|
|
@@ -85,28 +85,14 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version:
|
|
88
|
+
version: 2.17.4
|
|
89
89
|
type: :runtime
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version:
|
|
96
|
-
- !ruby/object:Gem::Dependency
|
|
97
|
-
name: savon-multipart
|
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - ">="
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '0'
|
|
103
|
-
type: :runtime
|
|
104
|
-
prerelease: false
|
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - ">="
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: '0'
|
|
95
|
+
version: 2.17.4
|
|
110
96
|
email:
|
|
111
97
|
- waclaw@luczak.it
|
|
112
98
|
executables: []
|
|
@@ -146,14 +132,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
146
132
|
requirements:
|
|
147
133
|
- - ">="
|
|
148
134
|
- !ruby/object:Gem::Version
|
|
149
|
-
version:
|
|
135
|
+
version: 3.2.0
|
|
150
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
137
|
requirements:
|
|
152
138
|
- - ">="
|
|
153
139
|
- !ruby/object:Gem::Version
|
|
154
140
|
version: '0'
|
|
155
141
|
requirements: []
|
|
156
|
-
rubygems_version: 3.6.
|
|
142
|
+
rubygems_version: 3.6.9
|
|
157
143
|
specification_version: 4
|
|
158
144
|
summary: Rails GUS API library based on official REGON SOAP api.
|
|
159
145
|
test_files: []
|