crefo 0.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 +7 -0
- data/.github/workflows/ci.yml +26 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +18 -0
- data/Gemfile +4 -0
- data/Guardfile +15 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/crefo.gemspec +36 -0
- data/lib/crefo/configuration.rb +52 -0
- data/lib/crefo/log.rb +16 -0
- data/lib/crefo/service/change_password/request.rb +16 -0
- data/lib/crefo/service/change_password/response.rb +13 -0
- data/lib/crefo/service/change_password.rb +9 -0
- data/lib/crefo/service/keylist/request.rb +14 -0
- data/lib/crefo/service/keylist/response.rb +13 -0
- data/lib/crefo/service/keylist.rb +9 -0
- data/lib/crefo/service/logon/request.rb +14 -0
- data/lib/crefo/service/logon/response.rb +13 -0
- data/lib/crefo/service/logon.rb +9 -0
- data/lib/crefo/service/report/request.rb +14 -0
- data/lib/crefo/service/report/response.rb +31 -0
- data/lib/crefo/service/report.rb +19 -0
- data/lib/crefo/service/request.rb +68 -0
- data/lib/crefo/service/response.rb +88 -0
- data/lib/crefo/service/search/request.rb +16 -0
- data/lib/crefo/service/search/response.rb +27 -0
- data/lib/crefo/service/search.rb +9 -0
- data/lib/crefo/service.rb +45 -0
- data/lib/crefo/version.rb +3 -0
- data/lib/crefo/xml/request/body.rb +13 -0
- data/lib/crefo/xml/request/envelope.rb +27 -0
- data/lib/crefo/xml/request/header.rb +25 -0
- data/lib/crefo/xml/request/namespaces.rb +10 -0
- data/lib/crefo/xml/utils/hash_to_nodes.rb +21 -0
- data/lib/crefo.rb +22 -0
- metadata +264 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 37a0db2cd8d2080542761554976e4c2dd27fdca4444b6f01949a21e163e15ead
|
4
|
+
data.tar.gz: e57a6d76dff38bac8f5ad9fb465a9b07b38a8c240d41442ab145e6f65656623f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7736601be890469343b5705881db988def723efcb18e9fd34f72e0d7d52b3d36a5e5c2f07d7f6fbdd8a7e29103df6b8e659e0393be42d36cb5b4432760ca8fd8
|
7
|
+
data.tar.gz: 72b8b095b8fe5eaad291ae92f2c997a5b395f8ecc0a67decdca94b47076a373c5605b8af390599395b66d7843faf0a4067f01a9321d95969fd65c9dc5d8df19f
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: push
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby-version }}
|
19
|
+
bundler-cache: true
|
20
|
+
- name: Run tests
|
21
|
+
run: bundle exec rake
|
22
|
+
env:
|
23
|
+
CREFO_USERACCOUNT: ${{ secrets.CREFO_USERACCOUNT }}
|
24
|
+
CREFO_GENERALPASSWORD: ${{ secrets.CREFO_GENERALPASSWORD }}
|
25
|
+
CREFO_INDIVIDUALPASSWORD: ${{ secrets.CREFO_INDIVIDUALPASSWORD }}
|
26
|
+
CREFO_CLIENTAPPLICATIONNAME: ${{ secrets.CREFO_CLIENTAPPLICATIONNAME }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.0
|
3
|
+
|
4
|
+
# Although it is a good idea to documentation at a class level, developers should
|
5
|
+
# not be forced to add a documentation. Because good naming or usefull conventions
|
6
|
+
# might make documentation redundant.
|
7
|
+
Documentation:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
# Because 80 would be too short and 99 fits perfectly into the code sections on
|
11
|
+
# GitHubs PR pages
|
12
|
+
Metrics/LineLength:
|
13
|
+
Max: 99
|
14
|
+
|
15
|
+
# We are way above the recommended maximum of 100 and this counter changes quite
|
16
|
+
# offen. Let's pin this to a unreasonable high number to avoid noise
|
17
|
+
Metrics/ClassLength:
|
18
|
+
Max: 512
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
guard :rspec, cmd: 'bundle exec rspec', all_after_pass: true do
|
2
|
+
require 'guard/rspec/dsl'
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# Feel free to open issues for suggestions and improvements
|
6
|
+
|
7
|
+
# RSpec files
|
8
|
+
rspec = dsl.rspec
|
9
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_files)
|
11
|
+
|
12
|
+
# Ruby files
|
13
|
+
ruby = dsl.ruby
|
14
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
15
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Crefo
|
2
|
+
|
3
|
+
Ruby client for the Creditreform API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'crefo'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install crefo
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
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).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/COMPEON/crefo.
|
34
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/crefo.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'crefo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'crefo'
|
8
|
+
spec.version = Crefo::VERSION
|
9
|
+
spec.authors = ['Timo Schilling', 'Lars Greiving']
|
10
|
+
spec.email = ['timo@schilling.io', 'lgreiving@compeon.de']
|
11
|
+
|
12
|
+
spec.summary = 'Ruby client for the Creditreform API.'
|
13
|
+
spec.homepage = 'https://github.com/COMPEON/crefo'
|
14
|
+
|
15
|
+
spec.required_ruby_version = '>= 3.0.5'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'nokogiri'
|
23
|
+
spec.add_runtime_dependency 'faraday'
|
24
|
+
spec.add_runtime_dependency 'faraday-multipart'
|
25
|
+
spec.add_runtime_dependency 'nori'
|
26
|
+
spec.add_runtime_dependency 'mail'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2.2'
|
29
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.12'
|
31
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.0'
|
32
|
+
spec.add_development_dependency 'timecop'
|
33
|
+
spec.add_development_dependency 'dotenv'
|
34
|
+
spec.add_development_dependency 'vcr'
|
35
|
+
spec.add_development_dependency 'pry'
|
36
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Crefo
|
2
|
+
class Configuration
|
3
|
+
CURRENT_KEYLISTVERSION = 21
|
4
|
+
ENDPOINTS = {
|
5
|
+
default: 'https://onlineservice.creditreform.de:443/webservice/0600-0021/soap12/messages.wsdl',
|
6
|
+
test: 'https://ktu.onlineservice.creditreform.de:443/webservice/0600-0021/soap12/messages.wsdl'
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
attr_accessor :communicationlanguage, :keylistversion, :transactionreference
|
10
|
+
attr_accessor :clientapplicationname, :clientapplicationversion
|
11
|
+
attr_accessor :useraccount, :generalpassword, :individualpassword, :connection_options
|
12
|
+
attr_writer :endpoint
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@keylistversion = CURRENT_KEYLISTVERSION
|
16
|
+
@communicationlanguage = 'de'
|
17
|
+
@clientapplicationversion = Crefo::VERSION.to_i
|
18
|
+
@connection_options = {}
|
19
|
+
@endpoint = :default
|
20
|
+
end
|
21
|
+
|
22
|
+
def endpoint
|
23
|
+
ENDPOINTS.fetch(@endpoint, @endpoint)
|
24
|
+
end
|
25
|
+
|
26
|
+
module Builder
|
27
|
+
def configure(&block)
|
28
|
+
config.tap(&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def config
|
32
|
+
@configuration ||= Crefo::Configuration.new
|
33
|
+
end
|
34
|
+
|
35
|
+
module TestHelper
|
36
|
+
def mock_config!(&block)
|
37
|
+
@old_configuration = @configuration
|
38
|
+
@configuration = @configuration.dup.tap(&block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def unmock_config!
|
42
|
+
@configuration = @old_configuration
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_time
|
46
|
+
Time.new(2014, 12, 20, 4, 44, 44, "+01:00")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
extend Configuration::Builder
|
52
|
+
end
|
data/lib/crefo/log.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Crefo
|
2
|
+
class Log
|
3
|
+
attr_reader :url, :request, :response, :error
|
4
|
+
|
5
|
+
def initialize(url, request, response, error)
|
6
|
+
@url = url
|
7
|
+
@request = request
|
8
|
+
@response = response
|
9
|
+
@error = error
|
10
|
+
end
|
11
|
+
|
12
|
+
def errored?
|
13
|
+
!error.nil?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Crefo
|
2
|
+
class Service
|
3
|
+
class ChangePassword
|
4
|
+
class Request < Service::Request
|
5
|
+
self.request_name = :changepassword
|
6
|
+
self.response_class = ChangePassword::Response
|
7
|
+
|
8
|
+
def body
|
9
|
+
{
|
10
|
+
newpassword: options[:newpassword]
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Crefo
|
2
|
+
class Service
|
3
|
+
class Report
|
4
|
+
class Response < Service::Response
|
5
|
+
self.response_name = :report
|
6
|
+
|
7
|
+
def result
|
8
|
+
if report_not_available?
|
9
|
+
false
|
10
|
+
else
|
11
|
+
document_body_hash
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def error?
|
18
|
+
return false unless document_fault_hash
|
19
|
+
return false if report_not_available?
|
20
|
+
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def report_not_available?
|
25
|
+
return false unless document_fault_hash
|
26
|
+
'ER-114' == document_fault_hash&.dig(:Detail, :servicefault, :body, :fault, :errorkey, :key)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Crefo
|
2
|
+
class Service
|
3
|
+
class Report < Crefo::Service
|
4
|
+
def initialize(options)
|
5
|
+
raise 'identificationnumber is missing' unless options[:identificationnumber]
|
6
|
+
raise 'legitimateinterest is missing' unless options[:legitimateinterest]
|
7
|
+
raise 'producttype is missing' unless options[:producttype] || options[:productid]
|
8
|
+
|
9
|
+
options[:reportlanguage] ||= Crefo.config.communicationlanguage
|
10
|
+
options[:producttype] ||= "PRTY-#{options.delete(:productid)}"
|
11
|
+
|
12
|
+
super(options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'crefo/service/report/response'
|
19
|
+
require 'crefo/service/report/request'
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'faraday/multipart'
|
3
|
+
|
4
|
+
module Crefo
|
5
|
+
class Service
|
6
|
+
class Request
|
7
|
+
attr_reader :request_id, :options
|
8
|
+
|
9
|
+
def initialize(request_id: nil, **options)
|
10
|
+
@request_id = request_id || Crefo.config.transactionreference || generate_request_id
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def envelope
|
15
|
+
@envelope ||= XML::Request::Envelope.new(request: self).build
|
16
|
+
end
|
17
|
+
|
18
|
+
def send(url)
|
19
|
+
connection.post url do |reqest|
|
20
|
+
reqest.headers[:content_type] = 'application/xop+xml'
|
21
|
+
reqest.body = envelope
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def connection
|
26
|
+
@connection ||= begin
|
27
|
+
options = Crefo.config.connection_options
|
28
|
+
Faraday.new(options) do |connection|
|
29
|
+
connection.headers[:user_agent] = user_agent
|
30
|
+
connection.request :multipart
|
31
|
+
connection.adapter :net_http
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def transmissiontimestamp
|
37
|
+
self.class.transmissiontimestamp || Time.now
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def user_agent
|
43
|
+
"#{Crefo.config.clientapplicationname} v#{Crefo.config.clientapplicationversion}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_request_id
|
47
|
+
SecureRandom.hex[0, 25]
|
48
|
+
end
|
49
|
+
|
50
|
+
class << self
|
51
|
+
attr_accessor :response_class
|
52
|
+
attr_accessor :request_name
|
53
|
+
|
54
|
+
@@transmissiontimestamp = nil
|
55
|
+
|
56
|
+
def transmissiontimestamp
|
57
|
+
@@transmissiontimestamp
|
58
|
+
end
|
59
|
+
|
60
|
+
def mock_transmissiontimestamp(time = Time.now, &block)
|
61
|
+
@@transmissiontimestamp = time
|
62
|
+
block.call
|
63
|
+
@@transmissiontimestamp = nil
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Crefo
|
2
|
+
class Service
|
3
|
+
class Response
|
4
|
+
class ParsingError < StandardError; end
|
5
|
+
class ResponseError < StandardError; end
|
6
|
+
|
7
|
+
attr_reader :body, :attachments, :document_hash
|
8
|
+
|
9
|
+
def initialize(response)
|
10
|
+
@response = response
|
11
|
+
@body = ''
|
12
|
+
@attachments = []
|
13
|
+
parse_body
|
14
|
+
parse_document
|
15
|
+
end
|
16
|
+
|
17
|
+
def document_body_hash
|
18
|
+
document_reponse_hash[:body]
|
19
|
+
end
|
20
|
+
|
21
|
+
def document_reponse_hash
|
22
|
+
document_hash[:Envelope][:Body][:"#{self.class.response_name}Response"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def document_fault_hash
|
26
|
+
document_hash.dig(:Envelope, :Body, :Fault)
|
27
|
+
end
|
28
|
+
|
29
|
+
def response_id
|
30
|
+
document_reponse_hash[:header][:responseid]
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def parse_document
|
36
|
+
@document_hash = begin
|
37
|
+
nori = Nori.new(strip_namespaces: true, convert_tags_to: ->(tag) { tag.to_sym })
|
38
|
+
nori.parse(body)
|
39
|
+
rescue
|
40
|
+
raise ParsingError, body
|
41
|
+
end
|
42
|
+
|
43
|
+
raise ResponseError, Nokogiri::XML(body).to_xml if error?
|
44
|
+
end
|
45
|
+
|
46
|
+
def error?
|
47
|
+
document_fault_hash
|
48
|
+
end
|
49
|
+
|
50
|
+
def multipart?
|
51
|
+
!(@response.headers['content-type'] =~ /^multipart/im).nil?
|
52
|
+
end
|
53
|
+
|
54
|
+
def boundary
|
55
|
+
return unless multipart?
|
56
|
+
@boundary ||= Mail::Field.new('content-type', @response.headers['content-type']).parameters['boundary']
|
57
|
+
end
|
58
|
+
|
59
|
+
def parse_body
|
60
|
+
if multipart?
|
61
|
+
body = @response.body
|
62
|
+
body.force_encoding(Encoding::BINARY)
|
63
|
+
|
64
|
+
parts = body.split(/(?:\A|\r\n)(?:--#{boundary}?(?:--)?)(?=\s*$)/)
|
65
|
+
parts = parts.map do |part|
|
66
|
+
part.gsub(/((\r\n)?Content-.*\r\n(\r\n)?)/, '')
|
67
|
+
end
|
68
|
+
parts.shift
|
69
|
+
|
70
|
+
@body = parts[0]
|
71
|
+
@attachments = parts[1..-1]
|
72
|
+
else
|
73
|
+
@body = @response.body
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class << self
|
78
|
+
def response_name
|
79
|
+
@response_name
|
80
|
+
end
|
81
|
+
|
82
|
+
def response_name=(response_name)
|
83
|
+
@response_name = response_name
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Crefo
|
2
|
+
class Service
|
3
|
+
class Search
|
4
|
+
class Response < Service::Response
|
5
|
+
self.response_name = :search
|
6
|
+
|
7
|
+
def result
|
8
|
+
hits
|
9
|
+
end
|
10
|
+
|
11
|
+
# ensure that the result is always a array
|
12
|
+
def hits
|
13
|
+
@hits ||= begin
|
14
|
+
object = document_body_hash[:hit]
|
15
|
+
if object.nil?
|
16
|
+
[]
|
17
|
+
elsif object.respond_to?(:to_ary)
|
18
|
+
object.to_ary || [object]
|
19
|
+
else
|
20
|
+
[object]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'crefo/service/request'
|
2
|
+
require 'crefo/service/response'
|
3
|
+
|
4
|
+
module Crefo
|
5
|
+
class Service
|
6
|
+
attr_reader :options, :log
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def process
|
13
|
+
begin
|
14
|
+
url = Crefo.config.endpoint
|
15
|
+
request = self.class::Request.new(**options)
|
16
|
+
response_data = request.send(url)
|
17
|
+
response = self.class::Response.new(response_data)
|
18
|
+
rescue Crefo::Service::Response::ResponseError => exception
|
19
|
+
error = true
|
20
|
+
rescue Exception => exception
|
21
|
+
error = %(#{exception.class}: #{exception.message}\n#{exception.backtrace.join("\n")})
|
22
|
+
raise exception
|
23
|
+
end
|
24
|
+
|
25
|
+
Crefo::Log.new(url, (request && request.envelope), (response && response.body), error)
|
26
|
+
Result.new(
|
27
|
+
result: (response && response.result),
|
28
|
+
body: (response && response.body),
|
29
|
+
attachments: (response && response.attachments),
|
30
|
+
error: error
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
class Result
|
35
|
+
attr_reader :result, :body, :attachments, :error
|
36
|
+
|
37
|
+
def initialize(result: raise(ArgumentError), body: raise(ArgumentError), attachments: raise(ArgumentError), error: raise(ArgumentError))
|
38
|
+
@result = result
|
39
|
+
@body = body
|
40
|
+
@attachments = attachments
|
41
|
+
@error = error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Crefo
|
2
|
+
module XML
|
3
|
+
class Request
|
4
|
+
class Envelope
|
5
|
+
attr_reader :request
|
6
|
+
|
7
|
+
def initialize(request: raise(ArgumentError))
|
8
|
+
@request = request
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
builder = Nokogiri::XML::Builder.new
|
13
|
+
builder['soap'].Envelope(XML::Request::NAMESPACES) do |envelope|
|
14
|
+
envelope.Header
|
15
|
+
envelope.Body do |body|
|
16
|
+
body['ns'].send("#{request.class.request_name}Request") do |xml|
|
17
|
+
XML::Request::Header.build(xml, request)
|
18
|
+
XML::Request::Body.build(xml, request.body)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
builder.to_xml
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Crefo
|
2
|
+
module XML
|
3
|
+
class Request
|
4
|
+
class Header
|
5
|
+
class << self
|
6
|
+
def build(xml, request)
|
7
|
+
nodes = {
|
8
|
+
communicationlanguage: Crefo.config.communicationlanguage,
|
9
|
+
transmissiontimestamp: request.transmissiontimestamp.iso8601,
|
10
|
+
keylistversion: Crefo.config.keylistversion,
|
11
|
+
clientapplicationname: Crefo.config.clientapplicationname,
|
12
|
+
clientapplicationversion: Crefo.config.clientapplicationversion,
|
13
|
+
transactionreference: request.request_id,
|
14
|
+
useraccount: Crefo.config.useraccount,
|
15
|
+
generalpassword: Crefo.config.generalpassword,
|
16
|
+
individualpassword: Crefo.config.individualpassword
|
17
|
+
}
|
18
|
+
|
19
|
+
Utils::HashToNodes.call(xml, :header, nodes)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Crefo
|
2
|
+
module XML
|
3
|
+
class Utils
|
4
|
+
module HashToNodes
|
5
|
+
def call(xml_builder, wrapper_node, nodes)
|
6
|
+
xml_builder.__send__ wrapper_node do |parent_node|
|
7
|
+
nodes.each_pair do |key, value|
|
8
|
+
case value
|
9
|
+
when Hash
|
10
|
+
HashToNodes.call(xml_builder, key, value)
|
11
|
+
else
|
12
|
+
parent_node.send key, value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
module_function :call
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/crefo.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'mail'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'nori'
|
5
|
+
|
6
|
+
require 'crefo/configuration'
|
7
|
+
require 'crefo/log'
|
8
|
+
require 'crefo/service'
|
9
|
+
require 'crefo/service/change_password'
|
10
|
+
require 'crefo/service/keylist'
|
11
|
+
require 'crefo/service/logon'
|
12
|
+
require 'crefo/service/report'
|
13
|
+
require 'crefo/service/search'
|
14
|
+
require 'crefo/xml/request/envelope'
|
15
|
+
require 'crefo/xml/request/body'
|
16
|
+
require 'crefo/xml/request/header'
|
17
|
+
require 'crefo/xml/request/namespaces'
|
18
|
+
require 'crefo/xml/utils/hash_to_nodes'
|
19
|
+
require 'crefo/version'
|
20
|
+
|
21
|
+
module Crefo
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crefo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Timo Schilling
|
8
|
+
- Lars Greiving
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2023-01-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: faraday-multipart
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: nori
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: mail
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: bundler
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.2'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.2'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rake
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '12.3'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '12.3'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rspec
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '3.12'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '3.12'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: guard-rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '4.0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '4.0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: timecop
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: dotenv
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: vcr
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: pry
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
description:
|
197
|
+
email:
|
198
|
+
- timo@schilling.io
|
199
|
+
- lgreiving@compeon.de
|
200
|
+
executables: []
|
201
|
+
extensions: []
|
202
|
+
extra_rdoc_files: []
|
203
|
+
files:
|
204
|
+
- ".github/workflows/ci.yml"
|
205
|
+
- ".gitignore"
|
206
|
+
- ".rspec"
|
207
|
+
- ".rubocop.yml"
|
208
|
+
- Gemfile
|
209
|
+
- Guardfile
|
210
|
+
- README.md
|
211
|
+
- Rakefile
|
212
|
+
- bin/console
|
213
|
+
- bin/setup
|
214
|
+
- crefo.gemspec
|
215
|
+
- lib/crefo.rb
|
216
|
+
- lib/crefo/configuration.rb
|
217
|
+
- lib/crefo/log.rb
|
218
|
+
- lib/crefo/service.rb
|
219
|
+
- lib/crefo/service/change_password.rb
|
220
|
+
- lib/crefo/service/change_password/request.rb
|
221
|
+
- lib/crefo/service/change_password/response.rb
|
222
|
+
- lib/crefo/service/keylist.rb
|
223
|
+
- lib/crefo/service/keylist/request.rb
|
224
|
+
- lib/crefo/service/keylist/response.rb
|
225
|
+
- lib/crefo/service/logon.rb
|
226
|
+
- lib/crefo/service/logon/request.rb
|
227
|
+
- lib/crefo/service/logon/response.rb
|
228
|
+
- lib/crefo/service/report.rb
|
229
|
+
- lib/crefo/service/report/request.rb
|
230
|
+
- lib/crefo/service/report/response.rb
|
231
|
+
- lib/crefo/service/request.rb
|
232
|
+
- lib/crefo/service/response.rb
|
233
|
+
- lib/crefo/service/search.rb
|
234
|
+
- lib/crefo/service/search/request.rb
|
235
|
+
- lib/crefo/service/search/response.rb
|
236
|
+
- lib/crefo/version.rb
|
237
|
+
- lib/crefo/xml/request/body.rb
|
238
|
+
- lib/crefo/xml/request/envelope.rb
|
239
|
+
- lib/crefo/xml/request/header.rb
|
240
|
+
- lib/crefo/xml/request/namespaces.rb
|
241
|
+
- lib/crefo/xml/utils/hash_to_nodes.rb
|
242
|
+
homepage: https://github.com/COMPEON/crefo
|
243
|
+
licenses: []
|
244
|
+
metadata: {}
|
245
|
+
post_install_message:
|
246
|
+
rdoc_options: []
|
247
|
+
require_paths:
|
248
|
+
- lib
|
249
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
250
|
+
requirements:
|
251
|
+
- - ">="
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: 3.0.5
|
254
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
255
|
+
requirements:
|
256
|
+
- - ">="
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: '0'
|
259
|
+
requirements: []
|
260
|
+
rubygems_version: 3.3.3
|
261
|
+
signing_key:
|
262
|
+
specification_version: 4
|
263
|
+
summary: Ruby client for the Creditreform API.
|
264
|
+
test_files: []
|