ws_cee_client 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5f9989013894cd92b1e75cbc22ffb8ac563bcf09
4
+ data.tar.gz: d5068a55b06d2565d45c58418962aba7f31ffa1d
5
+ SHA512:
6
+ metadata.gz: 31a6fcce10b082bde4d453e18b258f5fb88e395ce57509c2d5f45cd12f258cc89f57b3171db49794e3aab4497eab671254346fab176d64b0d848c4b4cc45940e
7
+ data.tar.gz: b9ae362e930dbba422b9d1261bbc09268f3f8910609d7ed2dae687e317e937722ccfa323b2daa22f19699c307378def451531fb45b1df432ee3b1ce380fc0ae3
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'savon', '~> 2.0'
4
+ gem 'rubyntlm'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jaromír Červenka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # WsCeeClient
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'ws_cee_client'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ws_cee_client
18
+
19
+ ## Usage
20
+
21
+ You need to obtain username and password from Bisnode first.
22
+
23
+ ### Find causes for company
24
+
25
+ ```ruby
26
+ ws_client = WsCee::Client.new username: WS_CEE_USERNAME, password: WS_CEE_PASSWORD
27
+ causes = ws_client.find_by_company registration_number: 123456789
28
+ ```
29
+
30
+ ### Find causes for person
31
+
32
+ ```ruby
33
+ ws_client = WsCee::Client.new username: WS_CEE_USERNAME, password: WS_CEE_PASSWORD
34
+ causes = ws_client.find_by_person name: 'John Doe', date_of_birth: '1969-03-14'
35
+ ```
36
+
37
+ The result for both cases is array of WsCee::CauseInfo objects with following attributes.
38
+
39
+ Example:
40
+
41
+ ```ruby
42
+ # WsCee::CauseInfo
43
+ causes.first.code => "144 EX 150/10"
44
+ causes.first.document_type => "Nařízení exekuce"
45
+ causes.first.registration_date => 2013-04-10
46
+ causes.first.subject => instance of WsCee::Subject class
47
+
48
+ # WsCee::Subject
49
+ subject = causes.first.subject
50
+ subject.name => "Company s.r.o."
51
+ subject.address => "Bořivojova 1/10, Praha 1, 110 00"
52
+ subject.registration_id => 123456789
53
+ subject.date_of_birth => nil in case of companies
54
+ ```
55
+
56
+ ### Details of one cause
57
+
58
+ ```ruby
59
+ cause_detail = ws_client.cause_detail cause_code: "144 EX 150/10"
60
+ ```
61
+
62
+ The result is instance of WsCee::CauseDetail.
63
+
64
+
65
+ ```ruby
66
+ # WsCee::CauseDetail
67
+ cause_detail.code => "144 EX 150/10"
68
+ cause_detail.description => "peněžité plnění:15018,00"
69
+ cause_detail.documents => array of WsCee::Document objects
70
+
71
+ # WsCee::Document
72
+ document = cause_detail.documents.first
73
+ document.type => "Nařízení exekuce"
74
+ document.description => ""
75
+ document.executor_company => "Košina Kamil Mgr."
76
+ document.court => "OS Mělník"
77
+ document.reference_number => "14EXE5105/2011-12"
78
+ document.issue_date => 2010-09-27
79
+ document.one_time_price => "15018.00"
80
+ document.regular_price => "15018.00"
81
+ document.non_monetary => nil
82
+ document.subjects => array of WsCee::Subject objects. See previous example
83
+ ```
84
+
85
+ Please refer to the WS CEE API documentation for more info about meaning of these attributes.
86
+
87
+ ## Development
88
+
89
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests.
90
+
91
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
92
+
93
+ ## Contributing
94
+
95
+ Bug reports and pull requests are welcome on GitHub at https://github.com/enrian/ws_cee_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
96
+
97
+
98
+ ## License
99
+
100
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
101
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,27 @@
1
+ module WsCee
2
+ class CauseDetail
3
+ attr_reader :code
4
+ attr_reader :description
5
+ attr_reader :documents
6
+
7
+ def initialize(cause_detail_hash)
8
+ @code = cause_detail_hash[:code]
9
+ @description = cause_detail_hash[:description]
10
+
11
+ @documents = []
12
+ parse_document cause_detail_hash[:document]
13
+ rescue NoMethodError
14
+ raise WsCee::ParsingError
15
+ end
16
+
17
+ private
18
+
19
+ def parse_document(document_hash)
20
+ if document_hash.is_a? Array
21
+ @documents = document_hash.collect { |document| Document.new document }
22
+ else
23
+ @documents << Document.new(document_hash)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ module WsCee
2
+ class CauseInfo
3
+ attr_reader :code
4
+ attr_reader :document_type
5
+ attr_reader :registration_date
6
+ attr_reader :subject
7
+
8
+ def initialize(cause_hash)
9
+ @code = cause_hash[:code]
10
+ @document_type = cause_hash[:document_type]
11
+ @registration_date = cause_hash[:registration_date]
12
+ @subject = Subject.new cause_hash[:subject_info]
13
+ rescue NoMethodError
14
+ raise WsCee::ParsingError
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,41 @@
1
+ module WsCee
2
+ class Document
3
+ attr_reader :type
4
+ attr_reader :description
5
+ attr_reader :executor_company
6
+ attr_reader :court
7
+ attr_reader :reference_number
8
+ attr_reader :issue_date
9
+ attr_reader :one_time_price
10
+ attr_reader :regular_price
11
+ attr_reader :non_monetary
12
+ attr_reader :subjects
13
+
14
+ def initialize(document_hash)
15
+ @type = document_hash[:type]
16
+ @description = document_hash[:description]
17
+ @executor_company = document_hash[:executor_company]
18
+ @court = document_hash[:court]
19
+ @reference_number = document_hash[:reference_number]
20
+ @issue_date = document_hash[:issue_date]
21
+ @one_time_price = document_hash[:one_time_price]
22
+ @regular_price = document_hash[:regular_price]
23
+ @non_monetary = document_hash[:non_monetary]
24
+
25
+ @subjects = []
26
+ parse_subject document_hash[:subject]
27
+ rescue NoMethodError
28
+ raise WsCee::ParsingError
29
+ end
30
+
31
+ private
32
+
33
+ def parse_subject(subject_hash)
34
+ if subject_hash.is_a? Array
35
+ @subjects = subject_hash.collect { |subject| Subject.new subject }
36
+ else
37
+ @subjects << Subject.new(subject_hash)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ module WsCee
2
+ SAVON_ERRORS = [Savon::Error, Errno::ECONNREFUSED, SocketError]
3
+
4
+ class Error < StandardError
5
+ end
6
+
7
+ class ParsingError < Error
8
+ end
9
+
10
+ class ConnectionError < Error
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module WsCee
2
+ class Subject
3
+ attr_reader :name
4
+ attr_reader :address
5
+ attr_reader :registration_id
6
+ attr_reader :date_of_birth
7
+
8
+ def initialize(subject_info_hash)
9
+ @name = subject_info_hash[:name]
10
+ @address = subject_info_hash[:address]
11
+ @registration_id = subject_info_hash[:registration_id]
12
+ @date_of_birth = subject_info_hash[:date_of_birth]
13
+ rescue NoMethodError
14
+ raise WsCee::ParsingError
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module WsCee
2
+ VERSION = '0.1.1'
3
+ end
@@ -0,0 +1,92 @@
1
+ require 'rubygems'
2
+ require 'savon'
3
+
4
+ require 'ws_cee_client/errors'
5
+ require 'ws_cee_client/cause_detail'
6
+ require 'ws_cee_client/cause_info'
7
+ require 'ws_cee_client/document'
8
+ require 'ws_cee_client/subject'
9
+
10
+ module WsCee
11
+ class Client
12
+ WS_CEE_TESTING_URL = 'https://source.bisnode.cz/services/cee_fix/v001/soap?wsdl'
13
+ WS_CEE_PRODUCTION_URL = 'https://source.bisnode.cz/services/cee_fix/v001/soap?wsdl' # FIXME
14
+
15
+ def initialize(options)
16
+ @savon = Savon.client wsdl: options[:testing] ? WS_CEE_PRODUCTION_URL : WS_CEE_TESTING_URL
17
+ @username = options[:username]
18
+ @password = options[:password]
19
+ rescue *SAVON_ERRORS
20
+ raise WsCee::ConnectionError
21
+ end
22
+
23
+ def find_by_company(company_details)
24
+ company_indication company_details
25
+ end
26
+
27
+ def find_by_person(person_details)
28
+ person_indication person_details
29
+ end
30
+
31
+ def cause_detail(options)
32
+ detail options[:cause_code]
33
+ end
34
+
35
+ private
36
+
37
+ def company_indication(company_details)
38
+ response = @savon.call :indication, message: company_query(company_details)
39
+ parse_indication_response response.hash
40
+ rescue *SAVON_ERRORS
41
+ raise WsCee::ConnectionError
42
+ end
43
+
44
+ def person_indication(person_details)
45
+ response = @savon.call :indication, message: person_query(person_details)
46
+ parse_indication_response response.hash
47
+ rescue *SAVON_ERRORS
48
+ raise WsCee::ConnectionError
49
+ end
50
+
51
+ def parse_indication_response(hash)
52
+ result = hash[:envelope][:body][:indication_result]
53
+ return [] if result.nil?
54
+
55
+ cause_info = result[:cause_info]
56
+ if cause_info.is_a? Array
57
+ cause_info.collect { |cause| WsCee::CauseInfo.new cause }
58
+ else
59
+ [WsCee::CauseInfo.new(cause_info)]
60
+ end
61
+ end
62
+
63
+ def detail(cause_code)
64
+ response = @savon.call :detail, message: detail_query(cause_code)
65
+ parse_detail_response response.hash
66
+ end
67
+
68
+ def parse_detail_response(hash)
69
+ result = hash[:envelope][:body][:detail_result]
70
+ return [] if result.nil?
71
+
72
+ CauseDetail.new result[:cause]
73
+ end
74
+
75
+ def company_query(company_details)
76
+ { 'LoginData' => login_data, 'SearchQuery' => { 'CompanyQuery' => { 'RegistrationID' => company_details[:registration_number] } } }
77
+ end
78
+
79
+ def person_query(person_details)
80
+ { 'LoginData' => login_data, 'SearchQuery' => { 'PersonQuery' =>
81
+ { 'Name' => person_details[:name], 'DateOfBirth' => person_details[:date_of_birth] } } }
82
+ end
83
+
84
+ def detail_query(cause_code)
85
+ { 'LoginData' => login_data, 'CauseCode' => cause_code }
86
+ end
87
+
88
+ def login_data
89
+ { 'UserName' => @username, 'Password' => @password }
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'ws_cee_client/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'ws_cee_client'
9
+ spec.version = WsCee::VERSION
10
+ spec.authors = ['Jaromír Červenka']
11
+ spec.email = ['jaromir@virt.io']
12
+
13
+ spec.summary = %q{Client for communication with Czech Database of Distraints. Connected to Bisnode WS CEE SOAP API.}
14
+ spec.homepage = 'https://github.com/enrian/ws_cee_client'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'savon', '~> 2.0'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'minitest'
25
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ws_cee_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jaromír Červenka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - jaromir@virt.io
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/ws_cee_client.rb
84
+ - lib/ws_cee_client/cause_detail.rb
85
+ - lib/ws_cee_client/cause_info.rb
86
+ - lib/ws_cee_client/document.rb
87
+ - lib/ws_cee_client/errors.rb
88
+ - lib/ws_cee_client/subject.rb
89
+ - lib/ws_cee_client/version.rb
90
+ - ws_cee_client.gemspec
91
+ homepage: https://github.com/enrian/ws_cee_client
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.5.1
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Client for communication with Czech Database of Distraints. Connected to
115
+ Bisnode WS CEE SOAP API.
116
+ test_files: []