ibanity 0.5 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +1 -0
  3. data/.travis.yml +20 -0
  4. data/CHANGELOG.md +20 -0
  5. data/README.md +2 -0
  6. data/ibanity.gemspec +1 -2
  7. data/lib/ibanity.rb +68 -14
  8. data/lib/ibanity/api/base_resource.rb +45 -15
  9. data/lib/ibanity/api/consent/consent.rb +41 -0
  10. data/lib/ibanity/api/consent/processing_operation.rb +37 -0
  11. data/lib/ibanity/api/isabel_connect/access_token.rb +17 -0
  12. data/lib/ibanity/api/isabel_connect/account.rb +15 -0
  13. data/lib/ibanity/api/isabel_connect/account_report.rb +15 -0
  14. data/lib/ibanity/api/isabel_connect/balance.rb +11 -0
  15. data/lib/ibanity/api/isabel_connect/bulk_payment_initiation_request.rb +25 -0
  16. data/lib/ibanity/api/isabel_connect/intraday_transaction.rb +10 -0
  17. data/lib/ibanity/api/isabel_connect/refresh_token.rb +29 -0
  18. data/lib/ibanity/api/isabel_connect/transaction.rb +10 -0
  19. data/lib/ibanity/api/o_auth_resource.rb +19 -0
  20. data/lib/ibanity/api/ponto_connect/account.rb +15 -0
  21. data/lib/ibanity/api/ponto_connect/financial_institution.rb +15 -0
  22. data/lib/ibanity/api/ponto_connect/payment.rb +20 -0
  23. data/lib/ibanity/api/ponto_connect/sandbox/financial_institution_account.rb +21 -0
  24. data/lib/ibanity/api/ponto_connect/sandbox/financial_institution_transaction.rb +31 -0
  25. data/lib/ibanity/api/ponto_connect/synchronization.rb +15 -0
  26. data/lib/ibanity/api/ponto_connect/token.rb +53 -0
  27. data/lib/ibanity/api/ponto_connect/transaction.rb +15 -0
  28. data/lib/ibanity/api/ponto_connect/usage.rb +10 -0
  29. data/lib/ibanity/api/ponto_connect/user_info.rb +10 -0
  30. data/lib/ibanity/api/sandbox/financial_institution_account.rb +41 -0
  31. data/lib/ibanity/api/sandbox/financial_institution_holding.rb +45 -0
  32. data/lib/ibanity/api/sandbox/financial_institution_transaction.rb +45 -0
  33. data/lib/ibanity/api/sandbox/financial_institution_user.rb +32 -0
  34. data/lib/ibanity/api/xs2a/account.rb +33 -0
  35. data/lib/ibanity/api/xs2a/account_information_access_request.rb +27 -0
  36. data/lib/ibanity/api/xs2a/account_information_access_request_authorization.rb +21 -0
  37. data/lib/ibanity/api/xs2a/bulk_payment_initiation_request.rb +33 -0
  38. data/lib/ibanity/api/xs2a/customer.rb +10 -0
  39. data/lib/ibanity/api/xs2a/customer_access_token.rb +11 -0
  40. data/lib/ibanity/api/xs2a/financial_institution.rb +36 -0
  41. data/lib/ibanity/api/xs2a/holding.rb +21 -0
  42. data/lib/ibanity/api/xs2a/payment_initiation_request.rb +33 -0
  43. data/lib/ibanity/api/xs2a/payment_initiation_request_authorization.rb +21 -0
  44. data/lib/ibanity/api/xs2a/periodic_payment_initiation_request.rb +33 -0
  45. data/lib/ibanity/api/xs2a/synchronization.rb +17 -0
  46. data/lib/ibanity/api/xs2a/transaction.rb +21 -0
  47. data/lib/ibanity/client.rb +41 -30
  48. data/lib/ibanity/collection.rb +47 -0
  49. data/lib/ibanity/error.rb +9 -5
  50. data/lib/ibanity/http_signature.rb +4 -2
  51. data/lib/ibanity/util.rb +11 -4
  52. data/lib/ibanity/version.rb +1 -1
  53. data/spec/lib/ibanity/util_spec.rb +89 -0
  54. data/spec/spec_helper.rb +100 -0
  55. metadata +52 -30
  56. data/lib/ibanity/api/account.rb +0 -20
  57. data/lib/ibanity/api/account_information_access_request.rb +0 -17
  58. data/lib/ibanity/api/customer_access_token.rb +0 -9
  59. data/lib/ibanity/api/financial_institution.rb +0 -30
  60. data/lib/ibanity/api/financial_institution_account.rb +0 -39
  61. data/lib/ibanity/api/financial_institution_transaction.rb +0 -43
  62. data/lib/ibanity/api/financial_institution_user.rb +0 -30
  63. data/lib/ibanity/api/payment_initiation_request.rb +0 -24
  64. data/lib/ibanity/api/transaction.rb +0 -19
@@ -0,0 +1,47 @@
1
+ module Ibanity
2
+ class Collection < DelegateClass(Array)
3
+ attr_accessor :page_limit,
4
+ :before_cursor,
5
+ :after_cursor,
6
+ :offset,
7
+ :total,
8
+ :first_link,
9
+ :next_link,
10
+ :previous_link,
11
+ :latest_synchronization,
12
+ :synchronized_at
13
+
14
+ def initialize(
15
+ klass:,
16
+ items:,
17
+ paging:,
18
+ links:,
19
+ synchronized_at:,
20
+ latest_synchronization:
21
+ )
22
+ paging ||= {}
23
+ links ||= {}
24
+ @klass = klass
25
+ @page_limit = paging["limit"]
26
+ @before_cursor = paging["before"]
27
+ @after_cursor = paging["after"]
28
+ @offset = paging["offset"]
29
+ @total = paging["total"]
30
+ @first_link = links["first"]
31
+ @next_link = links["next"]
32
+ @previous_link = links["prev"]
33
+ @synchronized_at = synchronized_at
34
+ @latest_synchronization = latest_synchronization
35
+ super(items)
36
+ end
37
+
38
+ def inspect
39
+ result = "#<#{self.class.name}"
40
+ instance_variables.each do |instance_variable|
41
+ result +=" #{instance_variable}=#{instance_variable_get(instance_variable).inspect}"
42
+ end
43
+ result += ">"
44
+ result
45
+ end
46
+ end
47
+ end
@@ -2,14 +2,14 @@ module Ibanity
2
2
  class Error < StandardError
3
3
  attr_reader :errors
4
4
 
5
- def initialize(errors)
5
+ def initialize(errors, ibanity_request_id)
6
6
  @errors = errors
7
+ @ibanity_request_id = ibanity_request_id
7
8
  end
8
9
 
9
10
  def to_s
10
- if @errors && @errors.size > 0
11
- @errors.map do |error|
12
- p error
11
+ if @errors.is_a?(Array) && @errors.size > 0
12
+ formatted_errors = @errors.map do |error|
13
13
  if error["meta"] && error["meta"]["attribute"]
14
14
  "* #{error["code"]}: '#{error["meta"]["attribute"]}' #{error["detail"]}"
15
15
  elsif error["meta"] && error["meta"]["resource"]
@@ -17,7 +17,11 @@ module Ibanity
17
17
  else
18
18
  "* #{error["code"]}: #{error["detail"]}"
19
19
  end
20
- end.join("\n")
20
+ end
21
+ formatted_errors << "* ibanity_request_id: #{@ibanity_request_id}"
22
+ formatted_errors.join("\n")
23
+ elsif @errors.is_a?(Hash)
24
+ "* #{@errors["error"]}: #{@errors["error_description"]}\n * Error hint: #{@errors["error_hint"]}\n * ibanity_request_id: #{@ibanity_request_id}"
21
25
  else
22
26
  super
23
27
  end
@@ -1,3 +1,5 @@
1
+ require "base64"
2
+
1
3
  module Ibanity
2
4
  class HttpSignature
3
5
  def initialize(certificate:, certificate_id:, key:, method:, uri:, query_params:, headers:, payload:)
@@ -13,7 +15,7 @@ module Ibanity
13
15
 
14
16
  def payload_digest
15
17
  digest = OpenSSL::Digest::SHA512.new
16
- string_payload = @payload.nil? ? "" : @payload.to_json
18
+ string_payload = @payload.nil? ? "" : @payload
17
19
  digest.update(string_payload)
18
20
  base64 = Base64.urlsafe_encode64(digest.digest)
19
21
  "SHA-512=#{base64}"
@@ -33,7 +35,7 @@ module Ibanity
33
35
  end
34
36
 
35
37
  def request_target
36
- @uri.query = URI.encode_www_form(URI.decode_www_form(@uri.query.to_s).concat(@query_params.to_a)) if @query_params&.keys&.any?
38
+ @uri.query = RestClient::Utils.encode_query_string(@query_params) if @query_params&.keys&.any?
37
39
  "#{@method} #{@uri.request_uri}"
38
40
  end
39
41
 
@@ -1,9 +1,16 @@
1
1
  module Ibanity
2
2
  module Util
3
- def self.underscorize_hash(attributes)
4
- attributes.keys.reduce({}) do |result, key|
5
- result[underscore(key)] = attributes[key]
6
- result
3
+ def self.underscorize(obj)
4
+ case obj
5
+ when Array
6
+ obj.map { |e| underscorize(e) }
7
+ when Hash
8
+ obj.keys.reduce({}) do |result, key|
9
+ result[underscore(key)] = underscorize(obj[key])
10
+ result
11
+ end
12
+ else
13
+ obj
7
14
  end
8
15
  end
9
16
 
@@ -1,3 +1,3 @@
1
1
  module Ibanity
2
- VERSION = "0.5"
2
+ VERSION = "1.3"
3
3
  end
@@ -0,0 +1,89 @@
1
+ require 'ibanity/util'
2
+
3
+ RSpec.describe Ibanity::Util do
4
+ describe ".underscorize" do
5
+ it "transforms all keys to snake_case" do
6
+ hash = {
7
+ "currency" => "EUR",
8
+ "amount" => 1,
9
+ "debtorName" => "Sophie Schowalter",
10
+ "debtorAccountReference" => "BE59823362319793",
11
+ }
12
+
13
+ expected = {
14
+ "currency" => "EUR",
15
+ "amount" => 1,
16
+ "debtor_name" => "Sophie Schowalter",
17
+ "debtor_account_reference" => "BE59823362319793",
18
+ }
19
+
20
+ expect(Ibanity::Util.underscorize(hash)).to eq(expected)
21
+ end
22
+
23
+ it "processes hashes recursively" do
24
+ hash = {
25
+ "currency" => "EUR",
26
+ "amount" => 1,
27
+ "debtorName" => "Sophie Schowalter",
28
+ "details" => {
29
+ "debtorAccountReference" => "BE59823362319793"
30
+ }
31
+ }
32
+
33
+ expected = {
34
+ "currency" => "EUR",
35
+ "amount" => 1,
36
+ "debtor_name" => "Sophie Schowalter",
37
+ "details" => {
38
+ "debtor_account_reference" => "BE59823362319793"
39
+ }
40
+ }
41
+
42
+ expect(Ibanity::Util.underscorize(hash)).to eq(expected)
43
+ end
44
+
45
+ it "processes each array element" do
46
+ hash = {
47
+ "currency" => "EUR",
48
+ "amount" => 1,
49
+ "debtorName" => "Sophie Schowalter",
50
+ "details" => [
51
+ {"debtorAccountReference" => "BE59823362319793"}
52
+ ]
53
+ }
54
+
55
+ expected = {
56
+ "currency" => "EUR",
57
+ "amount" => 1,
58
+ "debtor_name" => "Sophie Schowalter",
59
+ "details" => [
60
+ {"debtor_account_reference" => "BE59823362319793"}
61
+ ]
62
+ }
63
+
64
+ expect(Ibanity::Util.underscorize(hash)).to eq(expected)
65
+ end
66
+
67
+ it "leaves arrays elements untouched if they are not themselves hashes or arrays" do
68
+ hash = {
69
+ "currency" => "EUR",
70
+ "amount" => 1,
71
+ "debtorName" => "Sophie Schowalter",
72
+ "details" => [
73
+ "BE59823362319793"
74
+ ]
75
+ }
76
+
77
+ expected = {
78
+ "currency" => "EUR",
79
+ "amount" => 1,
80
+ "debtor_name" => "Sophie Schowalter",
81
+ "details" => [
82
+ "BE59823362319793"
83
+ ]
84
+ }
85
+
86
+ expect(Ibanity::Util.underscorize(hash)).to eq(expected)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,100 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
65
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
66
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
67
+ config.disable_monkey_patching!
68
+
69
+ # This setting enables warnings. It's recommended, but in some cases may
70
+ # be too noisy due to issues in dependencies.
71
+ config.warnings = true
72
+
73
+ # Many RSpec users commonly either run the entire suite or an individual
74
+ # file, and it's useful to allow more verbose output when running an
75
+ # individual spec file.
76
+ if config.files_to_run.one?
77
+ # Use the documentation formatter for detailed output,
78
+ # unless a formatter has already been configured
79
+ # (e.g. via a command-line flag).
80
+ config.default_formatter = "doc"
81
+ end
82
+
83
+ # Print the 10 slowest examples and example groups at the
84
+ # end of the spec run, to help surface which specs are running
85
+ # particularly slow.
86
+ config.profile_examples = 10
87
+
88
+ # Run specs in random order to surface order dependencies. If you find an
89
+ # order dependency and want to debug it, you can fix the order by providing
90
+ # the seed, which is printed after each run.
91
+ # --seed 1234
92
+ config.order = :random
93
+
94
+ # Seed global randomization in this process using the `--seed` CLI option.
95
+ # Setting this allows you to use `--seed` to deterministically reproduce
96
+ # test failures related to randomization by passing the same `--seed` value
97
+ # as the one that triggered the failure.
98
+ Kernel.srand config.seed
99
+ =end
100
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibanity
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ibanity
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-30 00:00:00.000000000 Z
11
+ date: 2020-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -30,28 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.4.0
33
+ version: 3.9.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 3.4.0
41
- - !ruby/object:Gem::Dependency
42
- name: webmock
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 1.24.2
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 1.24.2
40
+ version: 3.9.0
55
41
  description: A Ruby wrapper for the Ibanity API.
56
42
  email:
57
43
  - info@ibanity.com
@@ -61,27 +47,62 @@ extra_rdoc_files: []
61
47
  files:
62
48
  - ".gitignore"
63
49
  - ".gitkeep"
50
+ - ".rspec"
51
+ - ".travis.yml"
52
+ - CHANGELOG.md
64
53
  - Gemfile
65
54
  - LICENSE.txt
66
55
  - README.md
67
56
  - Rakefile
68
57
  - ibanity.gemspec
69
58
  - lib/ibanity.rb
70
- - lib/ibanity/api/account.rb
71
- - lib/ibanity/api/account_information_access_request.rb
72
59
  - lib/ibanity/api/base_resource.rb
73
- - lib/ibanity/api/customer_access_token.rb
74
- - lib/ibanity/api/financial_institution.rb
75
- - lib/ibanity/api/financial_institution_account.rb
76
- - lib/ibanity/api/financial_institution_transaction.rb
77
- - lib/ibanity/api/financial_institution_user.rb
78
- - lib/ibanity/api/payment_initiation_request.rb
79
- - lib/ibanity/api/transaction.rb
60
+ - lib/ibanity/api/consent/consent.rb
61
+ - lib/ibanity/api/consent/processing_operation.rb
62
+ - lib/ibanity/api/isabel_connect/access_token.rb
63
+ - lib/ibanity/api/isabel_connect/account.rb
64
+ - lib/ibanity/api/isabel_connect/account_report.rb
65
+ - lib/ibanity/api/isabel_connect/balance.rb
66
+ - lib/ibanity/api/isabel_connect/bulk_payment_initiation_request.rb
67
+ - lib/ibanity/api/isabel_connect/intraday_transaction.rb
68
+ - lib/ibanity/api/isabel_connect/refresh_token.rb
69
+ - lib/ibanity/api/isabel_connect/transaction.rb
70
+ - lib/ibanity/api/o_auth_resource.rb
71
+ - lib/ibanity/api/ponto_connect/account.rb
72
+ - lib/ibanity/api/ponto_connect/financial_institution.rb
73
+ - lib/ibanity/api/ponto_connect/payment.rb
74
+ - lib/ibanity/api/ponto_connect/sandbox/financial_institution_account.rb
75
+ - lib/ibanity/api/ponto_connect/sandbox/financial_institution_transaction.rb
76
+ - lib/ibanity/api/ponto_connect/synchronization.rb
77
+ - lib/ibanity/api/ponto_connect/token.rb
78
+ - lib/ibanity/api/ponto_connect/transaction.rb
79
+ - lib/ibanity/api/ponto_connect/usage.rb
80
+ - lib/ibanity/api/ponto_connect/user_info.rb
81
+ - lib/ibanity/api/sandbox/financial_institution_account.rb
82
+ - lib/ibanity/api/sandbox/financial_institution_holding.rb
83
+ - lib/ibanity/api/sandbox/financial_institution_transaction.rb
84
+ - lib/ibanity/api/sandbox/financial_institution_user.rb
85
+ - lib/ibanity/api/xs2a/account.rb
86
+ - lib/ibanity/api/xs2a/account_information_access_request.rb
87
+ - lib/ibanity/api/xs2a/account_information_access_request_authorization.rb
88
+ - lib/ibanity/api/xs2a/bulk_payment_initiation_request.rb
89
+ - lib/ibanity/api/xs2a/customer.rb
90
+ - lib/ibanity/api/xs2a/customer_access_token.rb
91
+ - lib/ibanity/api/xs2a/financial_institution.rb
92
+ - lib/ibanity/api/xs2a/holding.rb
93
+ - lib/ibanity/api/xs2a/payment_initiation_request.rb
94
+ - lib/ibanity/api/xs2a/payment_initiation_request_authorization.rb
95
+ - lib/ibanity/api/xs2a/periodic_payment_initiation_request.rb
96
+ - lib/ibanity/api/xs2a/synchronization.rb
97
+ - lib/ibanity/api/xs2a/transaction.rb
80
98
  - lib/ibanity/client.rb
99
+ - lib/ibanity/collection.rb
81
100
  - lib/ibanity/error.rb
82
101
  - lib/ibanity/http_signature.rb
83
102
  - lib/ibanity/util.rb
84
103
  - lib/ibanity/version.rb
104
+ - spec/lib/ibanity/util_spec.rb
105
+ - spec/spec_helper.rb
85
106
  homepage: https://documentation.ibanity.com/api/ruby
86
107
  licenses:
87
108
  - MIT
@@ -101,9 +122,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
122
  - !ruby/object:Gem::Version
102
123
  version: '0'
103
124
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.6.14
125
+ rubygems_version: 3.0.8
106
126
  signing_key:
107
127
  specification_version: 4
108
128
  summary: Ibanity Ruby Client
109
- test_files: []
129
+ test_files:
130
+ - spec/lib/ibanity/util_spec.rb
131
+ - spec/spec_helper.rb