gus_bir1 1.1.0 → 1.3.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 +26 -0
- data/CHANGELOG.md +8 -0
- data/README.md +15 -13
- data/bin/test +3 -0
- data/gus_bir1.gemspec +4 -4
- data/lib/gus_bir1/client.rb +2 -2
- data/lib/gus_bir1/response/search.rb +28 -15
- data/lib/gus_bir1/version.rb +1 -1
- data/lib/gus_bir1.rb +0 -1
- metadata +12 -20
- data/.travis.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9680b3fb20b4b3c9e2709a6983408db4d0a7ae0c44a785e9091d6517565642d8
|
4
|
+
data.tar.gz: f546c8a9fcb50cc6be2347a55f4020e5099a480b91876013cb4eeae52bf58321
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eca81e9d55c9964f14579eab5dc36cabedbcf479a291a4ada75c4c8982ba9ac73daccf93bc3bc68e9470fe239047f84612df0497f58b6408664cdde9aed7b1b
|
7
|
+
data.tar.gz: 1dbe40541fa79eaff76e1a7719d1a3d90555e161120e9dbcf7f661b9faa182485bbc3d34f1789337041bb46492442545b824cbc35d1a4d19deb5cf508f8a5b65
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: CI Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ 'master', 'develop' ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ 'master', 'develop' ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
env:
|
13
|
+
CI: true
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby-version: ['3.2', '3.3', '3.4']
|
17
|
+
steps:
|
18
|
+
- name: Checkout code
|
19
|
+
uses: actions/checkout@v3
|
20
|
+
- name: Install Ruby and gems
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
25
|
+
- name: Run unit tests
|
26
|
+
run: bundle exec rake test
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.3.0
|
4
|
+
|
5
|
+
- Removed `ostruct` from codebase. Replaced data structures returned by the library with the `Struct` defined underneath. This might be a breaking change if you used OpenStruct and extended it by adding your own fields in your applications.
|
6
|
+
```rb
|
7
|
+
SearchResult = Struct.new(:name, :regon, :province, :district, :community, :city, :zip_code, :street, :street_number, :house_number, :street_address, :type, :silos_id, :type_desc, :silos_desc, :report :post_city)
|
8
|
+
```
|
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# GusBir1
|
2
|
-
[](LICENSE)
|
3
|
+
[](https://github.com/espago/gus_bir1/actions/workflows/ci.yml/badge.svg)
|
3
4
|
[](https://badge.fury.io/rb/gus_bir1)
|
4
5
|
[](https://codeclimate.com/github/espago/gus_bir1)
|
5
6
|
[](https://codeclimate.com/github/espago/gus_bir1)
|
6
7
|
|
7
|
-
Simple,
|
8
|
-
|
8
|
+
Simple, Ruby wrapper for REGON database (Baza Internetowa Regon (BIR))(web frontend is reachable at https://wyszukiwarkaregon.stat.gov.pl/appBIR/index.aspx). To access its SOAP API, one needs a USER_KEY issued by REGON administrators available at regon_bir@stat.gov.pl.
|
9
|
+
|
10
|
+
Official GUS docs: https://api.stat.gov.pl/Home/RegonApi
|
9
11
|
|
10
12
|
|
11
13
|
## Installation
|
@@ -74,47 +76,47 @@ To start querying the GUS database, You can use three methods `GusBir1.find_by`,
|
|
74
76
|
with `regon`
|
75
77
|
```ruby
|
76
78
|
response = GusBir1.find_by(regon: '00033150100000')
|
77
|
-
=> [#<
|
79
|
+
=> [#<struct GusBir1::Response::SearchResult name="GŁÓWNY URZĄD STATYSTYCZNY", regon="00033150100000", province="MAZOWIECKIE", district="m. st. Warszawa", community="Śródmieście", city="Warszawa", zip_code="00-925", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">]
|
78
80
|
response.class
|
79
81
|
=> Array
|
80
82
|
response.first
|
81
|
-
=> #<
|
83
|
+
=> #<struct GusBir1::Response::SearchResult name="GŁÓWNY URZĄD STATYSTYCZNY", regon="00033150100000", province="MAZOWIECKIE", district="m. st. Warszawa", community="Śródmieście", city="Warszawa", zip_code="00-925", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">
|
82
84
|
```
|
83
85
|
|
84
86
|
with `nip`
|
85
87
|
```ruby
|
86
88
|
response = GusBir1.find_by(nip: '8992689516')
|
87
|
-
=> [#<
|
89
|
+
=> [#<struct GusBir1::Response::SearchResult name="\"PSP POLSKA\" SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ", regon="02121583300000", province="DOLNOŚLĄSKIE", district="m. Wrocław", community="Wrocław-Stare Miasto", city="Wrocław", zip_code="53-505", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">]
|
88
90
|
```
|
89
91
|
|
90
92
|
with `krs`
|
91
93
|
```ruby
|
92
94
|
response = GusBir1.find_by(krs: '0000352235')
|
93
|
-
=> [#<
|
95
|
+
=> [#<struct GusBir1::Response::SearchResult name="\"PSP POLSKA\" SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ", regon="02121583300000", province="DOLNOŚLĄSKIE", district="m. Wrocław", community="Wrocław-Stare Miasto", city="Wrocław", zip_code="53-505", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">]
|
94
96
|
```
|
95
97
|
|
96
98
|
with `regons14` (up to 20 regons)
|
97
99
|
```ruby
|
98
100
|
response = GusBir1.find_by(regons14: '00033150100000,02121583300000')
|
99
|
-
=> [#<
|
101
|
+
=> [#<struct GusBir1::Response::SearchResult name="GŁÓWNY URZĄD STATYSTYCZNY", regon="00033150100000", province="MAZOWIECKIE", district="m. st. Warszawa", community="Śródmieście", city="Warszawa", zip_code="00-925", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">, #<struct GusBir1::Response::SearchResult name="\"PSP POLSKA\" SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ", regon="02121583300000", province="DOLNOŚLĄSKIE", district="m. Wrocław", community="Wrocław-Stare Miasto", city="Wrocław", zip_code="53-505", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">]
|
100
102
|
```
|
101
103
|
|
102
104
|
with `regons9` (up to 20 regons)
|
103
105
|
```ruby
|
104
106
|
response = GusBir1.find_by(regons9: '000331501,021215833')
|
105
|
-
=> [#<
|
107
|
+
=> [#<struct GusBir1::Response::SearchResult name="GŁÓWNY URZĄD STATYSTYCZNY", regon="00033150100000", province="MAZOWIECKIE", district="m. st. Warszawa", community="Śródmieście", city="Warszawa", zip_code="00-925", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">, #<struct GusBir1::Response::SearchResult name="\"PSP POLSKA\" SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ", regon="02121583300000", province="DOLNOŚLĄSKIE", district="m. Wrocław", community="Wrocław-Stare Miasto", city="Wrocław", zip_code="53-505", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">]
|
106
108
|
```
|
107
109
|
|
108
110
|
with `nips` (up to 20 nips)
|
109
111
|
```ruby
|
110
112
|
response = GusBir1.find_by(nips: '8992689516,5261040828')
|
111
|
-
=> [#<
|
113
|
+
=> [#<struct GusBir1::Response::SearchResult name="GŁÓWNY URZĄD STATYSTYCZNY", regon="00033150100000", province="MAZOWIECKIE", district="m. st. Warszawa", community="Śródmieście", city="Warszawa", zip_code="00-925", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">, #<struct GusBir1::Response::SearchResult name="\"PSP POLSKA\" SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ", regon="02121583300000", province="DOLNOŚLĄSKIE", district="m. Wrocław", community="Wrocław-Stare Miasto", city="Wrocław", zip_code="53-505", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">]
|
112
114
|
```
|
113
115
|
|
114
116
|
with `krss` (up to 20 krss)
|
115
117
|
```ruby
|
116
118
|
response = GusBir1.find_by(krss: '0000352235')
|
117
|
-
=> [#<
|
119
|
+
=> [#<struct GusBir1::Response::SearchResult name="\"PSP POLSKA\" SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ", regon="02121583300000", province="DOLNOŚLĄSKIE", district="m. Wrocław", community="Wrocław-Stare Miasto", city="Wrocław", zip_code="53-505", street="ul. Test-Krucza", type="P", silos_id="6", type_desc="Typ jednostki – jednostka prawna", silos_desc="Miejsce prowadzenia działalności jednostki prawnej", report="PublDaneRaportPrawna">]
|
118
120
|
```
|
119
121
|
|
120
122
|
#### get_full_data
|
@@ -144,7 +146,7 @@ response.first.class
|
|
144
146
|
## Example
|
145
147
|
|
146
148
|
```ruby
|
147
|
-
company =
|
149
|
+
company = struct GusBir1::Response::SearchResult.new
|
148
150
|
|
149
151
|
gus_response = GusBir1.find_and_get_full_data(nip: 5261040828)
|
150
152
|
if gus_response.first
|
@@ -164,7 +166,7 @@ if gus_response.first
|
|
164
166
|
end
|
165
167
|
|
166
168
|
company
|
167
|
-
=> #<
|
169
|
+
=> #<struct GusBir1::Response::SearchResult name="GUS", address="ul. Test-Krucza 208", zip="00-925", city="Warszawa", country="POLSKA", regon="00033150100000", nip="5261040828">
|
168
170
|
```
|
169
171
|
|
170
172
|
|
data/bin/test
ADDED
data/gus_bir1.gemspec
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require 'gus_bir1/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'gus_bir1'
|
9
9
|
spec.version = GusBir1::VERSION
|
10
|
-
spec.authors = ['
|
10
|
+
spec.authors = ['Waclaw Luczak']
|
11
11
|
spec.email = ['waclaw@luczak.it']
|
12
12
|
|
13
13
|
spec.summary = 'Rails GUS API library based on official REGON SOAP api.'
|
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'rubocop'
|
28
28
|
spec.add_development_dependency 'simplecov'
|
29
29
|
|
30
|
-
spec.add_dependency 'savon', '~> 2.
|
31
|
-
spec.add_dependency 'savon-multipart
|
30
|
+
spec.add_dependency 'savon', '~> 2.15'
|
31
|
+
spec.add_dependency 'savon-multipart'
|
32
32
|
end
|
data/lib/gus_bir1/client.rb
CHANGED
@@ -58,7 +58,7 @@ module GusBir1
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def find_and_get_full_data(hash)
|
61
|
-
r = find_by(hash)
|
61
|
+
r = find_by(**hash)
|
62
62
|
r.map { |h| get_full_data_from_response(h) }
|
63
63
|
end
|
64
64
|
|
@@ -85,7 +85,7 @@ module GusBir1
|
|
85
85
|
|
86
86
|
def method_missing(method, *args)
|
87
87
|
if savon_client.operations.include? method
|
88
|
-
response_hash = call(method, args[0]).
|
88
|
+
response_hash = call(method, args[0]).full_hash
|
89
89
|
response_hash.dig(:envelope, :body, "#{method}_response".to_sym, "#{method}_result".to_sym)
|
90
90
|
else
|
91
91
|
super
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
module GusBir1
|
4
4
|
module Response
|
5
|
+
SearchResult = Struct.new(:name, :regon, :province, :district, :community,
|
6
|
+
:city, :zip_code, :street, :street_number,
|
7
|
+
:house_number, :street_address, :type, :silos_id,
|
8
|
+
:type_desc, :silos_desc, :report, :post_city)
|
9
|
+
|
5
10
|
class Search
|
6
11
|
def initialize(body)
|
7
12
|
@body = body
|
@@ -17,21 +22,25 @@ module GusBir1
|
|
17
22
|
private
|
18
23
|
|
19
24
|
def parse_dane(hash)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
SearchResult.new.tap do |search_result|
|
26
|
+
search_result.name = hash['Nazwa']
|
27
|
+
search_result.regon = hash['Regon']
|
28
|
+
search_result.province = hash['Wojewodztwo']
|
29
|
+
search_result.district = hash['Powiat']
|
30
|
+
search_result.community = hash['Gmina']
|
31
|
+
search_result.city = hash['Miejscowosc']
|
32
|
+
search_result.zip_code = hash['KodPocztowy']
|
33
|
+
search_result.street = hash['Ulica']
|
34
|
+
search_result.street_number = hash['NrNieruchomosci']
|
35
|
+
search_result.house_number = hash['NrLokalu']
|
36
|
+
search_result.street_address = street_address_from(hash)
|
37
|
+
search_result.type = hash['Typ']
|
38
|
+
search_result.silos_id = hash['SilosID']
|
39
|
+
search_result.type_desc = type_info(search_result)
|
40
|
+
search_result.silos_desc = silos_info(search_result)
|
41
|
+
search_result.report = report_info(search_result)
|
42
|
+
search_result.post_city = hash['MiejscowoscPoczty']
|
43
|
+
end
|
35
44
|
end
|
36
45
|
|
37
46
|
def type_info(search_result)
|
@@ -47,6 +56,10 @@ module GusBir1
|
|
47
56
|
def report_info(search_result)
|
48
57
|
Report::TypeMapper.get_report_type(search_result)
|
49
58
|
end
|
59
|
+
|
60
|
+
def street_address_from(data)
|
61
|
+
[data['Ulica'], [data['NrNieruchomosci'], data['NrLokalu']].compact.join('/')].join(' ')
|
62
|
+
end
|
50
63
|
end
|
51
64
|
end
|
52
65
|
end
|
data/lib/gus_bir1/version.rb
CHANGED
data/lib/gus_bir1.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gus_bir1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Waclaw Luczak
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -86,49 +85,44 @@ dependencies:
|
|
86
85
|
requirements:
|
87
86
|
- - "~>"
|
88
87
|
- !ruby/object:Gem::Version
|
89
|
-
version: '2.
|
88
|
+
version: '2.15'
|
90
89
|
type: :runtime
|
91
90
|
prerelease: false
|
92
91
|
version_requirements: !ruby/object:Gem::Requirement
|
93
92
|
requirements:
|
94
93
|
- - "~>"
|
95
94
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2.
|
95
|
+
version: '2.15'
|
97
96
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: savon-multipart
|
97
|
+
name: savon-multipart
|
99
98
|
requirement: !ruby/object:Gem::Requirement
|
100
99
|
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '2.1'
|
104
100
|
- - ">="
|
105
101
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
102
|
+
version: '0'
|
107
103
|
type: :runtime
|
108
104
|
prerelease: false
|
109
105
|
version_requirements: !ruby/object:Gem::Requirement
|
110
106
|
requirements:
|
111
|
-
- - "~>"
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: '2.1'
|
114
107
|
- - ">="
|
115
108
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
117
|
-
description:
|
109
|
+
version: '0'
|
118
110
|
email:
|
119
111
|
- waclaw@luczak.it
|
120
112
|
executables: []
|
121
113
|
extensions: []
|
122
114
|
extra_rdoc_files: []
|
123
115
|
files:
|
116
|
+
- ".github/workflows/ci.yml"
|
124
117
|
- ".gitignore"
|
125
|
-
-
|
118
|
+
- CHANGELOG.md
|
126
119
|
- Gemfile
|
127
120
|
- LICENSE.txt
|
128
121
|
- README.md
|
129
122
|
- Rakefile
|
130
123
|
- bin/console
|
131
124
|
- bin/setup
|
125
|
+
- bin/test
|
132
126
|
- gus_bir1.gemspec
|
133
127
|
- lib/gus_bir1.rb
|
134
128
|
- lib/gus_bir1/client.rb
|
@@ -145,7 +139,6 @@ homepage: https://github.com/espago/gus_bir1
|
|
145
139
|
licenses:
|
146
140
|
- MIT
|
147
141
|
metadata: {}
|
148
|
-
post_install_message:
|
149
142
|
rdoc_options: []
|
150
143
|
require_paths:
|
151
144
|
- lib
|
@@ -160,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
153
|
- !ruby/object:Gem::Version
|
161
154
|
version: '0'
|
162
155
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
164
|
-
signing_key:
|
156
|
+
rubygems_version: 3.6.7
|
165
157
|
specification_version: 4
|
166
158
|
summary: Rails GUS API library based on official REGON SOAP api.
|
167
159
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
env:
|
2
|
-
global:
|
3
|
-
- CC_TEST_REPORTER_ID=21904179f670d8951ec18038872b42fbd37ad057a2342c30197dfebaae2ab27e
|
4
|
-
-
|
5
|
-
sudo: false
|
6
|
-
language: ruby
|
7
|
-
rvm:
|
8
|
-
- 2.4
|
9
|
-
- 2.6
|
10
|
-
before_install: gem install bundler
|
11
|
-
|
12
|
-
before_script:
|
13
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
-
- chmod +x ./cc-test-reporter
|
15
|
-
- ./cc-test-reporter before-build
|
16
|
-
script:
|
17
|
-
- COVERAGE=1 rake test
|
18
|
-
after_script:
|
19
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|