secuconnect 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +20 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +119 -0
- data/.vscode/settings.json +5 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +137 -0
- data/Guardfile +33 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/secuconnect/authenticated.rb +20 -0
- data/lib/secuconnect/configuration.rb +15 -0
- data/lib/secuconnect/connection.rb +19 -0
- data/lib/secuconnect/oauth2/client.rb +30 -0
- data/lib/secuconnect/oauth2/token.rb +39 -0
- data/lib/secuconnect/payment/client.rb +34 -0
- data/lib/secuconnect/payment/contract.rb +50 -0
- data/lib/secuconnect/version.rb +5 -0
- data/lib/secuconnect.rb +32 -0
- data/secuconnect.gemspec +47 -0
- metadata +225 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 961916b223ab39ee7bd98ccd80241234f712ed482536ad66204010a2cb030c68
|
4
|
+
data.tar.gz: 5187cab796b75d2620523bbcd57374eac53f4db07e7fe0133e3073cfab169d80
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34b49382320d68ec1e426ebdcb9986316e8f4115ce7fcb7875002497ea63c588324925729f6cd23adc9fd55f773bdc8e70ee82156f39266ca308be7fc9f86550
|
7
|
+
data.tar.gz: 056dfc69437c1fa20e8f2cabffe84fbf3f9a31292a7d74cb58e6c667f1b2a81a31da39c6828b44def7cc583f4fb0c56f0e78c5010b101340e9ea4661ee173759
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Secuconnect CI
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: '2.7.3'
|
14
|
+
bundler-cache: true
|
15
|
+
- name: Run the default task
|
16
|
+
run: bundle exec rake
|
17
|
+
- name: Upload coverage to Codecov
|
18
|
+
uses: codecov/codecov-action@v2
|
19
|
+
with:
|
20
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Style/Documentation:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Layout/LineLength:
|
16
|
+
Max: 120
|
17
|
+
|
18
|
+
Gemspec/DateAssignment: # new in 1.10
|
19
|
+
Enabled: true
|
20
|
+
Gemspec/RequireMFA: # new in 1.23
|
21
|
+
Enabled: true
|
22
|
+
Layout/LineEndStringConcatenationIndentation: # new in 1.18
|
23
|
+
Enabled: true
|
24
|
+
Layout/SpaceBeforeBrackets: # new in 1.7
|
25
|
+
Enabled: true
|
26
|
+
Lint/AmbiguousAssignment: # new in 1.7
|
27
|
+
Enabled: true
|
28
|
+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
|
29
|
+
Enabled: true
|
30
|
+
Lint/AmbiguousRange: # new in 1.19
|
31
|
+
Enabled: true
|
32
|
+
Lint/DeprecatedConstants: # new in 1.8
|
33
|
+
Enabled: true
|
34
|
+
Lint/DuplicateBranch: # new in 1.3
|
35
|
+
Enabled: true
|
36
|
+
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
|
37
|
+
Enabled: true
|
38
|
+
Lint/EmptyBlock: # new in 1.1
|
39
|
+
Enabled: true
|
40
|
+
Lint/EmptyClass: # new in 1.3
|
41
|
+
Enabled: true
|
42
|
+
Lint/EmptyInPattern: # new in 1.16
|
43
|
+
Enabled: true
|
44
|
+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
|
45
|
+
Enabled: true
|
46
|
+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
|
47
|
+
Enabled: true
|
48
|
+
Lint/NoReturnInBeginEndBlocks: # new in 1.2
|
49
|
+
Enabled: true
|
50
|
+
Lint/NumberedParameterAssignment: # new in 1.9
|
51
|
+
Enabled: true
|
52
|
+
Lint/OrAssignmentToConstant: # new in 1.9
|
53
|
+
Enabled: true
|
54
|
+
Lint/RedundantDirGlobSort: # new in 1.8
|
55
|
+
Enabled: true
|
56
|
+
Lint/RequireRelativeSelfPath: # new in 1.22
|
57
|
+
Enabled: true
|
58
|
+
Lint/SymbolConversion: # new in 1.9
|
59
|
+
Enabled: true
|
60
|
+
Lint/ToEnumArguments: # new in 1.1
|
61
|
+
Enabled: true
|
62
|
+
Lint/TripleQuotes: # new in 1.9
|
63
|
+
Enabled: true
|
64
|
+
Lint/UnexpectedBlockArity: # new in 1.5
|
65
|
+
Enabled: true
|
66
|
+
Lint/UnmodifiedReduceAccumulator: # new in 1.1
|
67
|
+
Enabled: true
|
68
|
+
Lint/UselessRuby2Keywords: # new in 1.23
|
69
|
+
Enabled: true
|
70
|
+
Naming/BlockForwarding: # new in 1.24
|
71
|
+
Enabled: true
|
72
|
+
Security/IoMethods: # new in 1.22
|
73
|
+
Enabled: true
|
74
|
+
Style/ArgumentsForwarding: # new in 1.1
|
75
|
+
Enabled: true
|
76
|
+
Style/CollectionCompact: # new in 1.2
|
77
|
+
Enabled: true
|
78
|
+
Style/DocumentDynamicEvalDefinition: # new in 1.1
|
79
|
+
Enabled: true
|
80
|
+
Style/EndlessMethod: # new in 1.8
|
81
|
+
Enabled: true
|
82
|
+
Style/FileRead: # new in 1.24
|
83
|
+
Enabled: true
|
84
|
+
Style/FileWrite: # new in 1.24
|
85
|
+
Enabled: true
|
86
|
+
Style/HashConversion: # new in 1.10
|
87
|
+
Enabled: true
|
88
|
+
Style/HashExcept: # new in 1.7
|
89
|
+
Enabled: true
|
90
|
+
Style/IfWithBooleanLiteralBranches: # new in 1.9
|
91
|
+
Enabled: true
|
92
|
+
Style/InPatternThen: # new in 1.16
|
93
|
+
Enabled: true
|
94
|
+
Style/MapToHash: # new in 1.24
|
95
|
+
Enabled: true
|
96
|
+
Style/MultilineInPatternThen: # new in 1.16
|
97
|
+
Enabled: true
|
98
|
+
Style/NegatedIfElseCondition: # new in 1.2
|
99
|
+
Enabled: true
|
100
|
+
Style/NilLambda: # new in 1.3
|
101
|
+
Enabled: true
|
102
|
+
Style/NumberedParameters: # new in 1.22
|
103
|
+
Enabled: true
|
104
|
+
Style/NumberedParametersLimit: # new in 1.22
|
105
|
+
Enabled: true
|
106
|
+
Style/OpenStructUse: # new in 1.23
|
107
|
+
Enabled: true
|
108
|
+
Style/QuotedSymbols: # new in 1.16
|
109
|
+
Enabled: true
|
110
|
+
Style/RedundantArgument: # new in 1.4
|
111
|
+
Enabled: true
|
112
|
+
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
113
|
+
Enabled: true
|
114
|
+
Style/SelectByRegexp: # new in 1.22
|
115
|
+
Enabled: true
|
116
|
+
Style/StringChars: # new in 1.12
|
117
|
+
Enabled: true
|
118
|
+
Style/SwapValues: # new in 1.1
|
119
|
+
Enabled: true
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
## [0.1.1] / 2022-02-14
|
3
|
+
==================
|
4
|
+
|
5
|
+
* Update Readme file.
|
6
|
+
* Change to contract interface to class methods.
|
7
|
+
|
8
|
+
## [0.1.0] / 2022-02-14
|
9
|
+
==================
|
10
|
+
|
11
|
+
* Fix contract index method.
|
12
|
+
* Fix Rubocop yelling.
|
13
|
+
* Add Platform to bundle lock.
|
14
|
+
* Revert "Use setup-ruby action."
|
15
|
+
* Use setup-ruby action.
|
16
|
+
* Add Step 1 to readme.
|
17
|
+
* Update workflow ci.
|
18
|
+
* Change workflow
|
19
|
+
* Update main.yml
|
20
|
+
* Add Contract creation and validation.
|
21
|
+
* Add Oauth2 authentication.
|
22
|
+
* Add configuration to the gem.
|
23
|
+
* Initial commit.
|
24
|
+
|
25
|
+
## [0.0.0] - 2022-01-21
|
26
|
+
|
27
|
+
- Initial release
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
secuconnect (0.1.1)
|
5
|
+
activesupport (~> 6.1)
|
6
|
+
faraday (~> 2.1)
|
7
|
+
rake (~> 13.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.1.4.4)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
addressable (2.8.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
|
+
ast (2.4.2)
|
21
|
+
coderay (1.1.3)
|
22
|
+
concurrent-ruby (1.1.9)
|
23
|
+
crack (0.4.5)
|
24
|
+
rexml
|
25
|
+
diff-lcs (1.5.0)
|
26
|
+
docile (1.4.0)
|
27
|
+
faraday (2.1.0)
|
28
|
+
faraday-net_http (~> 2.0)
|
29
|
+
ruby2_keywords (>= 0.0.4)
|
30
|
+
faraday-net_http (2.0.1)
|
31
|
+
ffi (1.15.5)
|
32
|
+
formatador (1.0.0)
|
33
|
+
guard (2.18.0)
|
34
|
+
formatador (>= 0.2.4)
|
35
|
+
listen (>= 2.7, < 4.0)
|
36
|
+
lumberjack (>= 1.0.12, < 2.0)
|
37
|
+
nenv (~> 0.1)
|
38
|
+
notiffany (~> 0.0)
|
39
|
+
pry (>= 0.13.0)
|
40
|
+
shellany (~> 0.0)
|
41
|
+
thor (>= 0.18.1)
|
42
|
+
guard-compat (1.2.1)
|
43
|
+
guard-rspec (4.7.3)
|
44
|
+
guard (~> 2.1)
|
45
|
+
guard-compat (~> 1.1)
|
46
|
+
rspec (>= 2.99.0, < 4.0)
|
47
|
+
hashdiff (1.0.1)
|
48
|
+
i18n (1.9.0)
|
49
|
+
concurrent-ruby (~> 1.0)
|
50
|
+
listen (3.7.1)
|
51
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
52
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
53
|
+
lumberjack (1.2.8)
|
54
|
+
method_source (1.0.0)
|
55
|
+
minitest (5.15.0)
|
56
|
+
nenv (0.3.0)
|
57
|
+
notiffany (0.1.3)
|
58
|
+
nenv (~> 0.1)
|
59
|
+
shellany (~> 0.0)
|
60
|
+
parallel (1.21.0)
|
61
|
+
parser (3.1.0.0)
|
62
|
+
ast (~> 2.4.1)
|
63
|
+
pry (0.14.1)
|
64
|
+
coderay (~> 1.1)
|
65
|
+
method_source (~> 1.0)
|
66
|
+
public_suffix (4.0.6)
|
67
|
+
rainbow (3.1.1)
|
68
|
+
rake (13.0.6)
|
69
|
+
rb-fsevent (0.11.0)
|
70
|
+
rb-inotify (0.10.1)
|
71
|
+
ffi (~> 1.0)
|
72
|
+
regexp_parser (2.2.0)
|
73
|
+
rexml (3.2.5)
|
74
|
+
rspec (3.10.0)
|
75
|
+
rspec-core (~> 3.10.0)
|
76
|
+
rspec-expectations (~> 3.10.0)
|
77
|
+
rspec-mocks (~> 3.10.0)
|
78
|
+
rspec-core (3.10.1)
|
79
|
+
rspec-support (~> 3.10.0)
|
80
|
+
rspec-expectations (3.10.2)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.10.0)
|
83
|
+
rspec-mocks (3.10.2)
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
+
rspec-support (~> 3.10.0)
|
86
|
+
rspec-support (3.10.3)
|
87
|
+
rubocop (1.25.0)
|
88
|
+
parallel (~> 1.10)
|
89
|
+
parser (>= 3.1.0.0)
|
90
|
+
rainbow (>= 2.2.2, < 4.0)
|
91
|
+
regexp_parser (>= 1.8, < 3.0)
|
92
|
+
rexml
|
93
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
94
|
+
ruby-progressbar (~> 1.7)
|
95
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
96
|
+
rubocop-ast (1.15.1)
|
97
|
+
parser (>= 3.0.1.1)
|
98
|
+
rubocop-performance (1.13.2)
|
99
|
+
rubocop (>= 1.7.0, < 2.0)
|
100
|
+
rubocop-ast (>= 0.4.0)
|
101
|
+
ruby-progressbar (1.11.0)
|
102
|
+
ruby2_keywords (0.0.5)
|
103
|
+
shellany (0.0.1)
|
104
|
+
simplecov (0.21.2)
|
105
|
+
docile (~> 1.1)
|
106
|
+
simplecov-html (~> 0.11)
|
107
|
+
simplecov_json_formatter (~> 0.1)
|
108
|
+
simplecov-html (0.12.3)
|
109
|
+
simplecov_json_formatter (0.1.3)
|
110
|
+
thor (1.2.1)
|
111
|
+
tzinfo (2.0.4)
|
112
|
+
concurrent-ruby (~> 1.0)
|
113
|
+
unicode-display_width (2.1.0)
|
114
|
+
vcr (6.0.0)
|
115
|
+
webmock (3.14.0)
|
116
|
+
addressable (>= 2.8.0)
|
117
|
+
crack (>= 0.3.2)
|
118
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
119
|
+
zeitwerk (2.5.3)
|
120
|
+
|
121
|
+
PLATFORMS
|
122
|
+
x86_64-darwin-20
|
123
|
+
x86_64-linux
|
124
|
+
|
125
|
+
DEPENDENCIES
|
126
|
+
guard-rspec
|
127
|
+
pry
|
128
|
+
rspec (~> 3.7)
|
129
|
+
rubocop
|
130
|
+
rubocop-performance
|
131
|
+
secuconnect!
|
132
|
+
simplecov
|
133
|
+
vcr (~> 6.0)
|
134
|
+
webmock (~> 3.4)
|
135
|
+
|
136
|
+
BUNDLED WITH
|
137
|
+
2.2.21
|
data/Guardfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
7
|
+
# directories %w(app lib config test spec features) \
|
8
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
9
|
+
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
13
|
+
#
|
14
|
+
# $ mkdir config
|
15
|
+
# $ mv Guardfile config/
|
16
|
+
# $ ln -s config/Guardfile .
|
17
|
+
#
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
|
+
|
20
|
+
# NOTE: The cmd option is now required due to the increasing number of ways
|
21
|
+
# rspec may be run, below are examples of the most common uses.
|
22
|
+
# * bundler: 'bundle exec rspec'
|
23
|
+
# * bundler binstubs: 'bin/rspec'
|
24
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
25
|
+
# installed the spring binstubs per the docs)
|
26
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
27
|
+
# * 'just' rspec: 'rspec'
|
28
|
+
|
29
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
30
|
+
watch(%r{^spec/.+_spec\.rb$})
|
31
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
32
|
+
watch("spec/spec_helper.rb") { "spec" }
|
33
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Eugen
|
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,94 @@
|
|
1
|
+
# Secuconnect
|
2
|
+
|
3
|
+
This gem provide a client for the secuconnect api. Currently it support only the payout contracts endpoint. Pr's for other endpoints are welcome.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'secuconnect'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install secuconnect
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Configuration
|
24
|
+
|
25
|
+
First of all yout should provide secuconnect credentials. To do it just create an initializer file and add a configuration block inside it.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Secuconnect.configure do |config|
|
29
|
+
config.secuconnect_client_id = "your_client_id"
|
30
|
+
config.secuconnect_client_secret = "your_client_secret"
|
31
|
+
# optional
|
32
|
+
config.secuconnect_base_url = "secucconect base url"
|
33
|
+
config.secuconnect_token_expiration_seconds = "token expiration time"
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
### Contracts
|
38
|
+
|
39
|
+
The contract endpoint provide function to create and validate a contract sub-project
|
40
|
+
|
41
|
+
You could create a contract sub-project in this way
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
contract = Secuconnect::Payment::Contract.create(account_id: account_id, body: body)
|
45
|
+
|
46
|
+
# body could look like this
|
47
|
+
body = {
|
48
|
+
contact: {
|
49
|
+
salutation: "Mr",
|
50
|
+
forename: "John",
|
51
|
+
surname: "Doe",
|
52
|
+
dob: "1980-02-03",
|
53
|
+
email: "john.doe@example.com",
|
54
|
+
mobile: "",
|
55
|
+
address: {
|
56
|
+
street: "Test Street",
|
57
|
+
street_number: "6",
|
58
|
+
postal_code: "01234",
|
59
|
+
city: "Examplecity",
|
60
|
+
country: "Germany"
|
61
|
+
}
|
62
|
+
},
|
63
|
+
project: "project_name",
|
64
|
+
payout_account: {
|
65
|
+
iban: "DE89370400440532013000",
|
66
|
+
bic: "",
|
67
|
+
owner: "Test 1"
|
68
|
+
}
|
69
|
+
}
|
70
|
+
```
|
71
|
+
|
72
|
+
for further information which arguments are provided. Please check it on https://developer.secuconnect.com/
|
73
|
+
|
74
|
+
if you want to validate the contract use
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
validation_result = Secuconnect::Payment::Contract.validate(account_id: account_id)
|
78
|
+
```
|
79
|
+
|
80
|
+
## Step 1
|
81
|
+
|
82
|
+
## Development
|
83
|
+
|
84
|
+
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.
|
85
|
+
|
86
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/secuconnect.
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "secuconnect"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Secuconnect
|
4
|
+
module Authenticated
|
5
|
+
API_PATH_PREFIX = "api/v2"
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def headers
|
10
|
+
{
|
11
|
+
"Content-Type": "application/json",
|
12
|
+
Authorization: "Bearer #{access_token}"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def access_token
|
17
|
+
Secuconnect::Oauth2::Token.find_or_create
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Secuconnect
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :secuconnect_client_id, :secuconnect_client_secret, :secuconnect_base_url,
|
6
|
+
:secuconnect_token_expiration_seconds
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@secuconnect_client_id = "09ae83af7c37121b2de929b211bad944"
|
10
|
+
@secuconnect_client_secret = "9c5f250b69f6436cb38fd780349bc00810d8d5051d3dcf821e428f65a32724bd"
|
11
|
+
@secuconnect_base_url = "https://connect-testing.secupay-ag.de/"
|
12
|
+
@secuconnect_token_expiration_seconds = 1200
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Secuconnect
|
4
|
+
module Connection
|
5
|
+
def connection
|
6
|
+
Faraday.new(url: base_url, headers: headers)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def base_url
|
12
|
+
Secuconnect.config.secuconnect_base_url
|
13
|
+
end
|
14
|
+
|
15
|
+
def headers
|
16
|
+
raise NoMethodError, "#{self.class} #headers is abstract and have to be implemented in the subclass"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Secuconnect
|
4
|
+
module Oauth2
|
5
|
+
class Client
|
6
|
+
class << self
|
7
|
+
include Secuconnect::Connection
|
8
|
+
GRAND_TYPE = "client_credentials"
|
9
|
+
|
10
|
+
def retrieve_token
|
11
|
+
connection.post("oauth/token", body)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def headers
|
17
|
+
{ "Content-Type": "application/x-www-form-urlencoded" }
|
18
|
+
end
|
19
|
+
|
20
|
+
def body
|
21
|
+
{
|
22
|
+
grant_type: GRAND_TYPE,
|
23
|
+
client_id: Secuconnect.config.secuconnect_client_id,
|
24
|
+
client_secret: Secuconnect.config.secuconnect_client_secret
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Secuconnect
|
4
|
+
module Oauth2
|
5
|
+
class AuthenticationResponseError < StandardError
|
6
|
+
attr_reader :response
|
7
|
+
|
8
|
+
def initialize(response)
|
9
|
+
@response = response
|
10
|
+
super(response)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Token
|
15
|
+
class << self
|
16
|
+
def find_or_create
|
17
|
+
Secuconnect.cache.fetch("secuconnect_auth_token", expires_in: token_expiration_time) do
|
18
|
+
retrieve_token_from_service
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def retrieve_token_from_service
|
25
|
+
response = Client.retrieve_token
|
26
|
+
body_as_json = JSON.parse(response.body)
|
27
|
+
|
28
|
+
raise AuthenticationResponseError.new(response), "Secuconnect authentication error" unless response.success?
|
29
|
+
|
30
|
+
body_as_json["access_token"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def token_expiration_time
|
34
|
+
Secuconnect.config.secuconnect_token_expiration_seconds
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Secuconnect
|
4
|
+
module Payment
|
5
|
+
class ResponseError < StandardError
|
6
|
+
attr_accessor :response
|
7
|
+
|
8
|
+
def initialize(response)
|
9
|
+
@response = response
|
10
|
+
super(response)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Client
|
15
|
+
class << self
|
16
|
+
include Secuconnect::Connection
|
17
|
+
include Secuconnect::Authenticated
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def headers
|
22
|
+
{
|
23
|
+
"Content-Type": "application/json",
|
24
|
+
Authorization: "Bearer #{access_token}"
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def access_token
|
29
|
+
Secuconnect::Oauth2::Token.find_or_create
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Secuconnect
|
4
|
+
module Payment
|
5
|
+
class Contract < Client
|
6
|
+
class << self
|
7
|
+
def index
|
8
|
+
response = connection.get(base_path)
|
9
|
+
|
10
|
+
handle_response(__method__, response)
|
11
|
+
end
|
12
|
+
|
13
|
+
def show(account_id:)
|
14
|
+
path = "#{base_path}/#{account_id}"
|
15
|
+
response = connection.get(path)
|
16
|
+
|
17
|
+
handle_response(__method__, response)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(account_id:, body:)
|
21
|
+
path = "#{base_path}/#{account_id}/RequestID"
|
22
|
+
response = connection.post(path, body.to_json)
|
23
|
+
|
24
|
+
handle_response(__method__, response)
|
25
|
+
end
|
26
|
+
|
27
|
+
def validate(account_id:)
|
28
|
+
path = "#{base_path}/#{account_id}"
|
29
|
+
response = connection.get(path)
|
30
|
+
|
31
|
+
raise ResponseError.new(response), "#{action.capitalize} response error" unless response.success?
|
32
|
+
|
33
|
+
response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def handle_response(action, response)
|
39
|
+
raise ResponseError.new(response), "#{action.capitalize} response error" unless response.success?
|
40
|
+
|
41
|
+
JSON.parse(response.body)
|
42
|
+
end
|
43
|
+
|
44
|
+
def base_path
|
45
|
+
"#{API_PATH_PREFIX}/Payment/Contracts"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/secuconnect.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "active_support"
|
5
|
+
require_relative "secuconnect/configuration"
|
6
|
+
require_relative "secuconnect/version"
|
7
|
+
require_relative "secuconnect/connection"
|
8
|
+
require_relative "secuconnect/authenticated"
|
9
|
+
require_relative "secuconnect/oauth2/client"
|
10
|
+
require_relative "secuconnect/oauth2/token"
|
11
|
+
require_relative "secuconnect/payment/client"
|
12
|
+
require_relative "secuconnect/payment/contract"
|
13
|
+
module Secuconnect
|
14
|
+
class Error < StandardError; end
|
15
|
+
# Configuration of global settings for Secupay
|
16
|
+
# Secuconnect.configure do |config|
|
17
|
+
# config.secuconnect_client_id = '123ab'
|
18
|
+
# end
|
19
|
+
class << self
|
20
|
+
attr_accessor :config, :cache
|
21
|
+
|
22
|
+
def configure
|
23
|
+
self.cache ||= ActiveSupport::Cache::MemoryStore.new
|
24
|
+
self.config ||= Configuration.new
|
25
|
+
yield config
|
26
|
+
end
|
27
|
+
|
28
|
+
def reset
|
29
|
+
self.config = Configuration.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/secuconnect.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/secuconnect/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "secuconnect"
|
7
|
+
spec.version = Secuconnect::VERSION
|
8
|
+
spec.authors = ["Eugen"]
|
9
|
+
spec.email = ["eugen.mllr@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Secuconnect api rails sdk"
|
12
|
+
spec.description = "Secuconnect api rails sdk"
|
13
|
+
spec.homepage = "https://github.com/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.7.3"
|
16
|
+
|
17
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
22
|
+
spec.metadata["rubygems_mfa_required"] = true
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
# Gem dependencies
|
34
|
+
spec.add_dependency "activesupport", "~> 6.1"
|
35
|
+
spec.add_dependency "faraday", "~> 2.1"
|
36
|
+
spec.add_dependency "rake", "~> 13.0"
|
37
|
+
|
38
|
+
spec.add_development_dependency "guard-rspec"
|
39
|
+
spec.add_development_dependency "pry"
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.7"
|
41
|
+
spec.add_development_dependency "rubocop"
|
42
|
+
spec.add_development_dependency "rubocop-performance"
|
43
|
+
spec.add_development_dependency "simplecov"
|
44
|
+
spec.add_development_dependency "vcr", "~> 6.0"
|
45
|
+
spec.add_development_dependency "webmock", "~> 3.4"
|
46
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: secuconnect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eugen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-performance
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: vcr
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '6.0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '6.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: webmock
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.4'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.4'
|
167
|
+
description: Secuconnect api rails sdk
|
168
|
+
email:
|
169
|
+
- eugen.mllr@gmail.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".github/workflows/main.yml"
|
175
|
+
- ".gitignore"
|
176
|
+
- ".rspec"
|
177
|
+
- ".rubocop.yml"
|
178
|
+
- ".vscode/settings.json"
|
179
|
+
- CHANGELOG.md
|
180
|
+
- Gemfile
|
181
|
+
- Gemfile.lock
|
182
|
+
- Guardfile
|
183
|
+
- LICENSE.txt
|
184
|
+
- README.md
|
185
|
+
- Rakefile
|
186
|
+
- bin/console
|
187
|
+
- bin/setup
|
188
|
+
- lib/secuconnect.rb
|
189
|
+
- lib/secuconnect/authenticated.rb
|
190
|
+
- lib/secuconnect/configuration.rb
|
191
|
+
- lib/secuconnect/connection.rb
|
192
|
+
- lib/secuconnect/oauth2/client.rb
|
193
|
+
- lib/secuconnect/oauth2/token.rb
|
194
|
+
- lib/secuconnect/payment/client.rb
|
195
|
+
- lib/secuconnect/payment/contract.rb
|
196
|
+
- lib/secuconnect/version.rb
|
197
|
+
- secuconnect.gemspec
|
198
|
+
homepage: https://github.com/
|
199
|
+
licenses:
|
200
|
+
- MIT
|
201
|
+
metadata:
|
202
|
+
homepage_uri: https://github.com/
|
203
|
+
source_code_uri: https://github.com/
|
204
|
+
changelog_uri: https://github.com/
|
205
|
+
rubygems_mfa_required: 'true'
|
206
|
+
post_install_message:
|
207
|
+
rdoc_options: []
|
208
|
+
require_paths:
|
209
|
+
- lib
|
210
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: 2.7.3
|
215
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
|
+
requirements:
|
217
|
+
- - ">="
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
version: '0'
|
220
|
+
requirements: []
|
221
|
+
rubygems_version: 3.1.6
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: Secuconnect api rails sdk
|
225
|
+
test_files: []
|