bunq-client 0.7.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yml +40 -0
  3. data/.rubocop.yml +212 -0
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +2 -0
  7. data/README.md +2 -0
  8. data/Rakefile +7 -3
  9. data/bunq-client.gemspec +22 -20
  10. data/lib/bunq/attachment.rb +15 -0
  11. data/lib/bunq/attachment_public.rb +13 -0
  12. data/lib/bunq/attachment_public_content.rb +4 -2
  13. data/lib/bunq/attachment_publics.rb +20 -0
  14. data/lib/bunq/attachments.rb +20 -0
  15. data/lib/bunq/avatar.rb +15 -0
  16. data/lib/bunq/avatars.rb +15 -0
  17. data/lib/bunq/bunq.rb +2 -0
  18. data/lib/bunq/bunqme_tab.rb +17 -0
  19. data/lib/bunq/bunqme_tabs.rb +21 -0
  20. data/lib/bunq/card.rb +2 -0
  21. data/lib/bunq/cards.rb +3 -1
  22. data/lib/bunq/certificate_pinned.rb +10 -6
  23. data/lib/bunq/client.rb +74 -51
  24. data/lib/bunq/device_servers.rb +5 -4
  25. data/lib/bunq/draft_share_invite_bank.rb +2 -0
  26. data/lib/bunq/draft_share_invite_banks.rb +3 -1
  27. data/lib/bunq/encryptor.rb +6 -7
  28. data/lib/bunq/errors.rb +9 -2
  29. data/lib/bunq/header.rb +20 -0
  30. data/lib/bunq/installation.rb +2 -0
  31. data/lib/bunq/installations.rb +4 -2
  32. data/lib/bunq/monetary_account.rb +17 -0
  33. data/lib/bunq/monetary_account_bank.rb +17 -0
  34. data/lib/bunq/monetary_account_banks.rb +21 -0
  35. data/lib/bunq/monetary_accounts.rb +3 -1
  36. data/lib/bunq/notification_filter_url.rb +4 -2
  37. data/lib/bunq/paginated.rb +14 -3
  38. data/lib/bunq/payment.rb +2 -0
  39. data/lib/bunq/payments.rb +3 -1
  40. data/lib/bunq/qr_code_content.rb +5 -3
  41. data/lib/bunq/resource.rb +25 -11
  42. data/lib/bunq/session_servers.rb +5 -2
  43. data/lib/bunq/signature.rb +9 -7
  44. data/lib/bunq/user.rb +17 -0
  45. data/lib/bunq/user_company.rb +2 -0
  46. data/lib/bunq/user_person.rb +2 -0
  47. data/lib/bunq/users.rb +17 -0
  48. data/lib/bunq/version.rb +3 -1
  49. metadata +53 -20
  50. data/.travis.yml +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be254960c8428aa33d20c3f8a46666d0d5a01b1e6a08749e0026d7aa8ef6c93d
4
- data.tar.gz: a711a80bff07d74ea85f941aa1bd39b28c0241c26f753e09c9c336ea8f1701ee
3
+ metadata.gz: ef10a801a625977962349812aa5b47ef63e802a4a3a5c33853b332a514bca935
4
+ data.tar.gz: 42d8632ffa3063f16f13c12a881478b735c7849e0bc0cfce1f5fe3fe44e0b81e
5
5
  SHA512:
6
- metadata.gz: 90e12c808f2675e307581c74de203fd31e09967caad14cd9c6636cbaed77b46d318e1408b0bce4863d70952fbf8dd83e45f9b5ad2a024994f4bd8d8384ef554f
7
- data.tar.gz: 8036d1a337e605d3d396edbba2c0c4518dbc0602e478c09fe41e42d71615aaacfc64fcf7f6ccff202763358ce18be315aeb749fce94486ac38e36893efc84ae2
6
+ metadata.gz: 58ee5014d8792932f156b65902af3c72d8bb11671b8838f6685ef3132a74f947457db81f0d8aeec315e3f4d348016a417c59a8276d5b3ed526dd6b397dfbc146
7
+ data.tar.gz: 5cbfff265e0bdd934d4364581cae0baba31f0c5ea71d3fc2c2270032f77b0d6d7b5424cf3adb7bfb257f9517252f3b03a6450946c255616be23450d1ee4a1514
@@ -0,0 +1,40 @@
1
+ name: rspec
2
+
3
+ on:
4
+ [push]
5
+
6
+ env:
7
+ RACK_ENV: test
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ include:
15
+ - ruby-version: 3.0.0
16
+ - ruby-version: 2.7
17
+
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v2
21
+ - name: Set up Ruby
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby-version }}
25
+ - name: Cache bundler
26
+ uses: actions/cache@v2
27
+ with:
28
+ path: vendor/bundle
29
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
30
+ restore-keys: |
31
+ ${{ runner.os }}-gems-
32
+ - name: Install bundler
33
+ run: |
34
+ gem install bundler
35
+ - name: Install ruby dependencies
36
+ run: |
37
+ bundle config path vendor/bundle
38
+ bundle install --jobs 4
39
+ - name: Run tests
40
+ run: bundle exec rspec
data/.rubocop.yml ADDED
@@ -0,0 +1,212 @@
1
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
2
+ # configuration file. It makes it possible to enable/disable
3
+ # certain cops (checks) and to alter their behavior if they accept
4
+ # any parameters. The file can be placed either in your home
5
+ # directory or in some project directory.
6
+ #
7
+ # RuboCop will start looking for the configuration file in the directory
8
+ # where the inspected file is and continue its way up to the root directory.
9
+ #
10
+ # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
11
+
12
+ ##
13
+ # General styles
14
+ ##
15
+ Style/Documentation:
16
+ Enabled: false # Code should be self-documenting
17
+
18
+ Style/AsciiComments:
19
+ Enabled: false # We have no issues with non-ascii characters in comments
20
+
21
+ Style/GuardClause:
22
+ Enabled: false # Can lead to strange constructions
23
+
24
+ Style/EachWithObject:
25
+ Enabled: false # We prefer/are used to using reduce
26
+
27
+ Style/NumericPredicate:
28
+ Enabled: false # Using .zero? can lead to 'Undefined method x for nil'
29
+
30
+ Style/MultilineBlockChain:
31
+ Enabled: false # Acceptable
32
+
33
+ Style/DoubleNegation:
34
+ Enabled: false # Usable 'hack'
35
+
36
+ Style/Lambda:
37
+ EnforcedStyle: literal
38
+
39
+ Style/SignalException:
40
+ EnforcedStyle: semantic
41
+
42
+ Style/FormatStringToken:
43
+ EnforcedStyle: unannotated
44
+
45
+ ##
46
+ # Metrics (all disabled; we have our own opinion on this)
47
+ ##
48
+ Layout/LineLength:
49
+ Enabled: true
50
+ Max: 120
51
+ AutoCorrect: true
52
+
53
+ Metrics/AbcSize:
54
+ Enabled: false
55
+
56
+ Metrics/BlockLength:
57
+ Enabled: false
58
+
59
+ Metrics/BlockNesting:
60
+ Enabled: false
61
+
62
+ Metrics/ClassLength:
63
+ Enabled: false
64
+
65
+ Metrics/CyclomaticComplexity:
66
+ Enabled: false
67
+
68
+ Metrics/MethodLength:
69
+ Enabled: false
70
+
71
+ Metrics/ModuleLength:
72
+ Enabled: false
73
+
74
+ Metrics/ParameterLists:
75
+ Enabled: false
76
+
77
+ Metrics/PerceivedComplexity:
78
+ Enabled: false
79
+
80
+ ##
81
+ # Trailing comma's
82
+ ##
83
+ Style/TrailingCommaInArguments:
84
+ EnforcedStyleForMultiline: comma
85
+
86
+ Style/TrailingCommaInArrayLiteral:
87
+ EnforcedStyleForMultiline: comma
88
+
89
+ Style/TrailingCommaInHashLiteral:
90
+ EnforcedStyleForMultiline: comma
91
+
92
+ ##
93
+ # Naming things
94
+ ##
95
+ Naming/AccessorMethodName:
96
+ Enabled: false # We have our own opinion on this
97
+
98
+ Naming/PredicateName:
99
+ Enabled: false # We have our own opinion on this
100
+
101
+ Naming/VariableNumber:
102
+ Enabled: false # We have our own opinion on this
103
+
104
+ Naming/HeredocDelimiterNaming:
105
+ Enabled: false # We have our own opinion on this
106
+
107
+ ##
108
+ # Lint
109
+ Lint/UriEscapeUnescape:
110
+ Enabled: false
111
+
112
+ Lint/SuppressedException:
113
+ AllowComments: true
114
+
115
+ Lint/AmbiguousBlockAssociation:
116
+ Enabled: true
117
+ Exclude:
118
+ - spec/**/*
119
+
120
+ Lint/NestedMethodDefinition:
121
+ Enabled: true
122
+
123
+ ##
124
+ # Layout
125
+ ##
126
+ Layout/ExtraSpacing:
127
+ Enabled: true
128
+ AllowForAlignment: false
129
+
130
+ Layout/SpaceInsideHashLiteralBraces:
131
+ EnforcedStyle: no_space
132
+
133
+ ##
134
+ # Multi-line formatting (hashes)
135
+ ##
136
+ Layout/FirstHashElementLineBreak:
137
+ Enabled: true
138
+
139
+ Layout/FirstHashElementIndentation:
140
+ Enabled: true
141
+ EnforcedStyle: consistent
142
+
143
+ Layout/MultilineHashBraceLayout:
144
+ Enabled: true
145
+ EnforcedStyle: new_line
146
+
147
+ Layout/MultilineHashKeyLineBreaks:
148
+ Enabled: true
149
+
150
+ ##
151
+ # Multi-line formatting (array)
152
+ ##
153
+ Layout/FirstArrayElementLineBreak:
154
+ Enabled: true
155
+
156
+ Layout/FirstArrayElementIndentation:
157
+ Enabled: true
158
+ EnforcedStyle: consistent
159
+
160
+ Layout/MultilineArrayBraceLayout:
161
+ Enabled: true
162
+ EnforcedStyle: new_line
163
+
164
+ Layout/MultilineArrayLineBreaks:
165
+ Enabled: true
166
+
167
+ ##
168
+ # Multi-line formatting (methods/arguments)
169
+ ##
170
+ Layout/FirstMethodArgumentLineBreak:
171
+ Enabled: true
172
+
173
+ Layout/FirstArgumentIndentation:
174
+ Enabled: true
175
+ EnforcedStyle: consistent
176
+
177
+ Layout/FirstParameterIndentation:
178
+ Enabled: true
179
+ EnforcedStyle: consistent
180
+
181
+ Layout/MultilineMethodCallBraceLayout:
182
+ Enabled: true
183
+ EnforcedStyle: new_line
184
+
185
+ Layout/MultilineMethodArgumentLineBreaks:
186
+ Enabled: true
187
+
188
+ Layout/MultilineMethodCallIndentation:
189
+ Enabled: true
190
+ EnforcedStyle: indented
191
+
192
+ # New
193
+ Layout/SpaceAroundMethodCallOperator:
194
+ Enabled: true
195
+
196
+ Lint/RaiseException:
197
+ Enabled: true
198
+
199
+ Lint/StructNewOverride:
200
+ Enabled: true
201
+
202
+ Style/ExponentialNotation:
203
+ Enabled: true
204
+
205
+ Style/HashEachMethods:
206
+ Enabled: true
207
+
208
+ Style/HashTransformKeys:
209
+ Enabled: true
210
+
211
+ Style/HashTransformValues:
212
+ Enabled: true
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.5
1
+ 3.0.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0
4
+
5
+ - Ruby 3.0
6
+
3
7
  ## 0.4.0
4
8
 
5
9
  - Each `Bunq.client` call now `.dup`s the `Bunq::Configuration`. This means the `Bunq::Client#configuration` is no longer shared as a global.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in bunq-client.gemspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Bunq::Client
2
2
 
3
+ [![rspec Actions Status](https://github.com/jorttbv/bunq-client/workflows/rspec/badge.svg)](https://github.com/jorttbv/bunq-client/actions)
4
+
3
5
  The `Bunq::Client` is a ruby wrapper of the [bunq Public API](https://doc.bunq.com) extracted from [Jortt Online boekhouden](https://www.jortt.nl).
4
6
 
5
7
  The `Bunq::Client` is the main interface which can be used to navigate to other resources. The response objects are just
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
5
9
 
6
- task :default => :spec
10
+ task default: %w[rubocop spec]
data/bunq-client.gemspec CHANGED
@@ -1,42 +1,44 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'bunq/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "bunq-client"
8
- spec.version = Bunq::VERSION
9
- spec.authors = [
8
+ spec.name = 'bunq-client'
9
+ spec.version = Bunq::VERSION
10
+ spec.authors = [
10
11
  'Lars Vonk',
11
12
  'Bob Forma',
12
13
  'Derek Kraan',
13
14
  'Mike van Diepen',
14
15
  ]
15
- spec.email = [
16
+ spec.email = [
16
17
  'lars.vonk@gmail.com',
17
18
  'bforma@zilverline.com',
18
19
  'derek.kraan@gmail.com',
19
20
  'mvdiepen@zilverline.com',
20
21
  ]
21
22
 
22
- spec.summary = %q{Ruby client for the bunq public API.}
23
- spec.description = %q{Ruby client for the bunq public API. Extracted from www.jortt.nl}
24
- spec.homepage = "https://github.com/jorttbv/bunq-client"
25
- spec.license = "MIT"
23
+ spec.summary = 'Ruby client for the bunq public API.'
24
+ spec.description = 'Ruby client for the bunq public API. Extracted from www.jortt.nl'
25
+ spec.homepage = 'https://github.com/jorttbv/bunq-client'
26
+ spec.license = 'MIT'
26
27
 
27
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
29
  f.match(%r{^(test|spec|features)/})
29
30
  end
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
31
+ spec.bindir = 'exe'
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ['lib']
33
34
 
34
- spec.add_runtime_dependency 'rest-client', '~> 2.0'
35
+ spec.add_runtime_dependency 'rest-client', ['>= 2.0', '< 2.2']
35
36
  spec.add_runtime_dependency 'thread_safe', '~> 0.3.6'
36
37
 
37
- spec.add_development_dependency "rake", "~> 12.3"
38
- spec.add_development_dependency "rspec", "~> 3.7"
39
- spec.add_development_dependency "webmock", "~> 3.2.1"
40
- spec.add_development_dependency "rspec-json_expectations", "~> 2.1"
41
- spec.add_development_dependency "codecov", "~> 0.1.10"
38
+ spec.add_development_dependency 'codecov', '~> 0.4.2'
39
+ spec.add_development_dependency 'rake', '~> 12.3'
40
+ spec.add_development_dependency 'rspec', '~> 3.10'
41
+ spec.add_development_dependency 'rspec-json_expectations', '~> 2.2'
42
+ spec.add_development_dependency 'rubocop', '~> 0.82.0'
43
+ spec.add_development_dependency 'webmock', '~> 3.11'
42
44
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'resource'
4
+
5
+ module Bunq
6
+ class Attachment
7
+ def initialize(parent_resource, id)
8
+ @resource = parent_resource.append("/attachment/#{id}")
9
+ end
10
+
11
+ def show
12
+ @resource.with_session { @resource.get }['Response']
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bunq
4
+ class AttachmentPublic
5
+ def initialize(client, id)
6
+ @resource = Bunq::Resource.new(client, "/v1/attachment-public/#{id}")
7
+ end
8
+
9
+ def show
10
+ @resource.with_session { @resource.get }['Response']
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Bunq
2
4
  ##
3
5
  # https://doc.bunq.com/api/1/call/attachment-public-content
@@ -11,8 +13,8 @@ module Bunq
11
13
  # Returns the raw content of a public attachment with given ID.
12
14
  # The raw content is the binary representation of a file.
13
15
  def show
14
- @resource.with_session do
15
- @resource.get { |response| response.body }
16
+ @resource.with_session do
17
+ @resource.get(&:body)
16
18
  end
17
19
  end
18
20
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+
5
+ module Bunq
6
+ class AttachmentPublics
7
+ def initialize(client)
8
+ @resource = Bunq::Resource.new(client, '/v1/attachment-public')
9
+ end
10
+
11
+ def create(binary_payload, description, mime_type)
12
+ custom_headers = {
13
+ Bunq::Header::CONTENT_TYPE => mime_type,
14
+ Bunq::Header::ATTACHMENT_DESCRIPTION => description,
15
+ }
16
+ payload = Base64.decode64(binary_payload)
17
+ @resource.with_session { @resource.post(payload, custom_headers: custom_headers) }['Response']
18
+ end
19
+ end
20
+ end