nordigen-ruby 1.0.1 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a0a198d2708a354e0cb9c3a4dc0a5b3c86a48558a3cbc7fdd194a5e6f51c339
4
- data.tar.gz: cb7f41ae35dac9c280cccde6a0e9d3881d3903569254c3a14e2e19ab93885f88
3
+ metadata.gz: 55e72e3ae468d31197df1d31c3ed1ab62d54c2e3f138bf2c8f946559a605d4db
4
+ data.tar.gz: 55f1a55b4c854d9cc96d701999b832c59388cf707d26f611cf43f7dc17205fd1
5
5
  SHA512:
6
- metadata.gz: 5fff49c6c59a8b05e8777a84e9b1423a36936b73762f39e02a101b363ad3c7e69a4b14caeb6e6cbcfcac4f1bd69161ddc7f2d06f5b69291dbdb4613f04cad9fa
7
- data.tar.gz: ae06748d1a8369a1e6dc5e0a61a3a36218044408734450dbac06173feb5125cece179624725ce47d519493933605e4aa832a748fdd9b514a19d2432606c2ae95
6
+ metadata.gz: 0432d6819c810c20cf5424c9d771e44192c8e27506cb01e8d40fb83395c645efa6c975e61f78493cfc9a348a22e687a7cb373668ff2408ba15e4411630c8d990
7
+ data.tar.gz: 417f3953480f7bcc91d6f88d6c0ad2256ee915bdab43a88d395005e36fc516f5383393e1db92603f707f15a7ea53271f2e3ffbb03af669c2224922e69317b77c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.0] - 2022-05-05
4
+
5
+ - Use JSON response instead of OpenStruct
6
+ - Add `date_to`, `date_from` arguments to filter transactions
7
+
8
+
9
+ ## [1.0.1] - 2022-01-13
10
+
11
+ - Republish library with latest working gem
12
+
3
13
  ## [1.0.0] - 2022-01-13
4
14
 
5
15
  - Initial release
data/Gemfile CHANGED
@@ -5,7 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in nordigen.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
- gem "faraday", "~> 1.8.0"
10
- gem "faraday_middleware", "~> 1.2.0"
11
- gem "test-unit", "~> 3.5.3"
8
+ gem "faraday", "~> 2.5.2"
9
+
10
+ group :development do
11
+ gem "rake", "~> 13.0"
12
+ gem "test-unit", "~> 3.5.3"
13
+ gem "dotenv", "~> 2.8.1"
14
+ end
data/Gemfile.lock CHANGED
@@ -1,37 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nordigen-ruby (1.0.0)
5
- dotenv (~> 2.7.6)
6
- faraday (~> 1.8.0)
7
- faraday_middleware (~> 1.2.0)
4
+ nordigen-ruby (2.0.0)
5
+ faraday (~> 2.5.2)
8
6
 
9
7
  GEM
10
8
  remote: https://rubygems.org/
11
9
  specs:
12
- dotenv (2.7.6)
13
- faraday (1.8.0)
14
- faraday-em_http (~> 1.0)
15
- faraday-em_synchrony (~> 1.0)
16
- faraday-excon (~> 1.1)
17
- faraday-httpclient (~> 1.0.1)
18
- faraday-net_http (~> 1.0)
19
- faraday-net_http_persistent (~> 1.1)
20
- faraday-patron (~> 1.0)
21
- faraday-rack (~> 1.0)
22
- multipart-post (>= 1.2, < 3)
10
+ dotenv (2.8.1)
11
+ faraday (2.5.2)
12
+ faraday-net_http (>= 2.0, < 3.1)
23
13
  ruby2_keywords (>= 0.0.4)
24
- faraday-em_http (1.0.0)
25
- faraday-em_synchrony (1.0.0)
26
- faraday-excon (1.1.0)
27
- faraday-httpclient (1.0.1)
28
- faraday-net_http (1.0.1)
29
- faraday-net_http_persistent (1.2.0)
30
- faraday-patron (1.0.0)
31
- faraday-rack (1.0.0)
32
- faraday_middleware (1.2.0)
33
- faraday (~> 1.0)
34
- multipart-post (2.1.1)
14
+ faraday-net_http (3.0.0)
35
15
  power_assert (2.0.1)
36
16
  rake (13.0.6)
37
17
  ruby2_keywords (0.0.5)
@@ -42,9 +22,8 @@ PLATFORMS
42
22
  x86_64-linux
43
23
 
44
24
  DEPENDENCIES
45
- dotenv (~> 2.7.6)
46
- faraday (~> 1.8.0)
47
- faraday_middleware (~> 1.2.0)
25
+ dotenv (~> 2.8.1)
26
+ faraday (~> 2.5.2)
48
27
  nordigen-ruby!
49
28
  rake (~> 13.0)
50
29
  test-unit (~> 3.5.3)
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 Nordigen Solutions SIA
3
+ Copyright (c) 2022 SIA "Nordigen Solutions"
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -45,8 +45,8 @@ client.set_token("YOUR_TOKEN")
45
45
 
46
46
  # Get access and refresh token
47
47
  # Note: access_token is automatically injected to other requests after you successfully obtain it
48
- access_token = token_data.access
49
- refresh_token = token_data.refresh
48
+ access_token = token_data["access"]
49
+ refresh_token = token_data["refresh"]
50
50
 
51
51
  # Exchange refresh token. Refresh token is valid for 30 days
52
52
  refresh_token = client.exchange_token(refresh_token)
@@ -69,9 +69,9 @@ init = client.init_session(
69
69
  reference_id: SecureRandom.uuid
70
70
  )
71
71
 
72
- link = init.link # bank authorization link
73
- puts init.link
74
- requisition_id = init.requisition_id # requisition id that is needed to get an account_id
72
+ link = init["link"] # bank authorization link
73
+ requisition_id = init["id"] # requisition id that is needed to get an account_id
74
+ puts link
75
75
  ```
76
76
 
77
77
  After successful authorization with a bank you can fetch your data (details, balances, transactions)
@@ -82,9 +82,9 @@ After successful authorization with a bank you can fetch your data (details, bal
82
82
  ```ruby
83
83
 
84
84
  # Get account id after you have completed authorization with a bank.
85
- accounts = client.requisition.get_requisition_by_id(requisition_id)
85
+ requisition_data = client.requisition.get_requisition_by_id(requisition_id)
86
86
  # Get account id from list
87
- account_id = accounts.accounts[0]
87
+ account_id = accounts["accounts"][0]
88
88
 
89
89
  # Instantiate account object
90
90
  account = client.account_api(account_id)
@@ -97,6 +97,15 @@ details = account.get_details()
97
97
  balances = account.get_balances()
98
98
  # Fetch transactions
99
99
  transactions = account.get_transactions()
100
+ # Filter transactions by specific date range
101
+ transactions = account.get_transactions(date_from: "2021-12-01", date_to: "2022-01-30")
102
+ ```
103
+
104
+ ## Development
105
+
106
+ Run all tests in a directory
107
+ ```bash
108
+ bundle exec rake test
100
109
  ```
101
110
 
102
111
  ## Support
data/Rakefile CHANGED
@@ -1,4 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rake/testtask"
3
4
  require "bundler/gem_tasks"
4
- task default: %i[]
5
+
6
+ task default: %i[test]
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.pattern = "./tests/test_*.rb"
10
+ end
data/lib/nordigen-ruby.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  require "faraday"
2
- require "faraday_middleware"
3
2
 
4
- require "nordigen_ruby/api/institutions"
5
- require "nordigen_ruby/api/agreements"
6
- require "nordigen_ruby/api/requisitions"
7
- require "nordigen_ruby/api/account"
3
+ require_relative "nordigen_ruby/api/institutions"
4
+ require_relative "nordigen_ruby/api/agreements"
5
+ require_relative "nordigen_ruby/api/requisitions"
6
+ require_relative "nordigen_ruby/api/account"
8
7
 
9
8
  module Nordigen
10
9
  class NordigenClient
@@ -27,13 +26,20 @@ module Nordigen
27
26
  @requisition = RequisitionsApi.new(client=self)
28
27
  end
29
28
 
30
- def request
29
+ def request(params = nil)
31
30
  # HTTP client request
31
+ parameters = {}
32
+ params&.each do |key, value|
33
+ if value
34
+ parameters[key] = value
35
+ end
36
+ end
37
+
32
38
  @request ||= Faraday.new do |conn|
33
39
  conn.url_prefix = BASE_URL
34
40
  conn.headers = @@headers
35
41
  conn.request :json
36
- conn.response :json, parser_options: { object_class: OpenStruct }
42
+ conn.response :json
37
43
  end
38
44
  end
39
45
 
@@ -58,7 +64,7 @@ module Nordigen
58
64
  raise Exception.new response.body
59
65
  end
60
66
 
61
- @@headers["Authorization"] = "Bearer #{response.body.access}"
67
+ @@headers["Authorization"] = "Bearer #{response.body['access']}"
62
68
  request.headers = @@headers
63
69
  return response.body
64
70
  end
@@ -67,7 +73,7 @@ module Nordigen
67
73
  # Exchange refresh token for access token
68
74
  payload = {"refresh": refresh_token}
69
75
  response = self.request.post("token/refresh/", payload).body
70
- @@headers["Authorization"] = "Bearer #{response.access}"
76
+ @@headers["Authorization"] = "Bearer #{response['access']}"
71
77
  request.headers = @@headers
72
78
  return response
73
79
  end
@@ -93,8 +99,9 @@ module Nordigen
93
99
  new_requsition = @requisition.create_requisition(
94
100
  redirect_url: redirect_url,
95
101
  reference: reference_id,
96
- institution_id: institution_id
97
- )
102
+ institution_id: institution_id,
103
+ agreement: new_agreement["id"]
104
+ )
98
105
 
99
106
  return new_requsition
100
107
  end
@@ -9,15 +9,14 @@ module Nordigen
9
9
  @account_id = account_id
10
10
  end
11
11
 
12
- def get(path = nil)
12
+ def get(path = nil, params = nil)
13
13
  # Create Get request
14
14
  url = "#{ENDPOINT}#{@account_id}/"
15
-
16
15
  if path
17
16
  url = "#{url}#{path}/"
18
17
  end
19
18
 
20
- return client.request.get(url).body
19
+ return client.request(params).get(url).body
21
20
  end
22
21
 
23
22
  def get_metadata
@@ -36,9 +35,13 @@ module Nordigen
36
35
  return get("balances")
37
36
  end
38
37
 
39
- def get_transactions
38
+ def get_transactions(date_from: nil, date_to: nil)
40
39
  # Access account transactions
41
- return get("transactions")
40
+ date_range = {
41
+ "date_from" => date_from,
42
+ "date_to" => date_to
43
+ }
44
+ return get("transactions", date_range)
42
45
  end
43
46
 
44
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nordigen
4
- VERSION = "1.0.1"
4
+ VERSION = "2.0.0"
5
5
  end
data/nordigen.gemspec CHANGED
@@ -33,8 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = `git ls-files -- bin/*`.split("\n")
34
34
  .map { |f| ::File.basename(f) }
35
35
 
36
- spec.add_dependency "faraday", "~> 1.8.0"
37
- spec.add_dependency "faraday_middleware", "~> 1.2.0"
36
+ spec.add_dependency "faraday", "~> 2.5.2"
38
37
 
39
38
  spec.require_paths = ["lib"]
40
39
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nordigen-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nordigen Solutions
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.8.0
19
+ version: 2.5.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.8.0
27
- - !ruby/object:Gem::Dependency
28
- name: faraday_middleware
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 1.2.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 1.2.0
26
+ version: 2.5.2
41
27
  description: Nordigen official API client for Ruby
42
28
  email:
43
29
  - support@nordigen.com
@@ -87,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
73
  - !ruby/object:Gem::Version
88
74
  version: '0'
89
75
  requirements: []
90
- rubygems_version: 3.2.15
76
+ rubygems_version: 3.1.2
91
77
  signing_key:
92
78
  specification_version: 4
93
79
  summary: Nordigen client for Ruby