investec_open_api 1.0.0 → 1.1.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: d69402eec4e9726ed5bfe503c817b6b179b53b5cd3658ae5d5906971482908da
4
- data.tar.gz: f98b0b7abc269d4d915787061ae937ce6674a1d3a80bc94627490973e6a74c63
3
+ metadata.gz: 77c64b266bba27ab306dea5d458ad2d712bad628a7969e633ba2443267c9e893
4
+ data.tar.gz: a74ccee5e67cfc5d0255eb2a9acd4d80e7f62d6c3615b4f20aaca4480c2fbda6
5
5
  SHA512:
6
- metadata.gz: 9fa72caba53822a4ed58cceae465e629044ba5a6b5c0699e546695d1f4ff91694253f410ae81b55bb7e8ad4713cd02f4e1052164fc0991f3e0413a564c94a876
7
- data.tar.gz: 90cdd9eab5eb502edd1f6995a95d91780aa7def38f47c7957bbe0d4b7c64a62bd6a3259238f10b03341bcb0041d86da01bc03ba2389385c37250e8122a42240c
6
+ metadata.gz: ac96b83766d92429bac7f6976566ea73e83b5c057ac1c9426ce511d630f7924c33690a6379bbb352bcaecaf264beeafc0395e57178a3018604be183a656add2a
7
+ data.tar.gz: 4bbe8c37fc10868da9dd940c9fc3570069a07f25d8f5238da9d0767ed35eb21da7604a32945b0a7a26bbae16616368dccf2748e29da55706586766d601413451
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.4
1
+ 3.2.0
data/.travis.yml CHANGED
@@ -2,5 +2,5 @@
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.6.3
6
- before_install: gem install bundler -v 2.1.4
5
+ - 3.2.0
6
+ before_install: gem install bundler -v 2.4.12
data/Gemfile CHANGED
@@ -1,12 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in investec_open_api.gemspec
4
- # gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
- gem "active_attr"
9
- gem "money"
10
- gem "faraday"
11
- gem "faraday_middleware"
12
- gem "webmock"
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,67 +1,99 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ investec_open_api (1.1.0)
5
+ active_attr
6
+ faraday
7
+ faraday_middleware
8
+ money
9
+
1
10
  GEM
2
11
  remote: https://rubygems.org/
3
12
  specs:
4
- actionpack (6.0.3.2)
5
- actionview (= 6.0.3.2)
6
- activesupport (= 6.0.3.2)
7
- rack (~> 2.0, >= 2.0.8)
13
+ actionpack (7.0.4.3)
14
+ actionview (= 7.0.4.3)
15
+ activesupport (= 7.0.4.3)
16
+ rack (~> 2.0, >= 2.2.0)
8
17
  rack-test (>= 0.6.3)
9
18
  rails-dom-testing (~> 2.0)
10
19
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
11
- actionview (6.0.3.2)
12
- activesupport (= 6.0.3.2)
20
+ actionview (7.0.4.3)
21
+ activesupport (= 7.0.4.3)
13
22
  builder (~> 3.1)
14
23
  erubi (~> 1.4)
15
24
  rails-dom-testing (~> 2.0)
16
25
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
17
- active_attr (0.15.0)
18
- actionpack (>= 3.0.2, < 6.1)
19
- activemodel (>= 3.0.2, < 6.1)
20
- activesupport (>= 3.0.2, < 6.1)
21
- activemodel (6.0.3.2)
22
- activesupport (= 6.0.3.2)
23
- activesupport (6.0.3.2)
26
+ active_attr (0.15.4)
27
+ actionpack (>= 3.0.2, < 7.1)
28
+ activemodel (>= 3.0.2, < 7.1)
29
+ activesupport (>= 3.0.2, < 7.1)
30
+ activemodel (7.0.4.3)
31
+ activesupport (= 7.0.4.3)
32
+ activesupport (7.0.4.3)
24
33
  concurrent-ruby (~> 1.0, >= 1.0.2)
25
- i18n (>= 0.7, < 2)
26
- minitest (~> 5.1)
27
- tzinfo (~> 1.1)
28
- zeitwerk (~> 2.2, >= 2.2.2)
29
- addressable (2.7.0)
30
- public_suffix (>= 2.0.2, < 5.0)
34
+ i18n (>= 1.6, < 2)
35
+ minitest (>= 5.1)
36
+ tzinfo (~> 2.0)
37
+ addressable (2.8.4)
38
+ public_suffix (>= 2.0.2, < 6.0)
31
39
  builder (3.2.4)
32
- concurrent-ruby (1.1.6)
33
- crack (0.4.3)
34
- safe_yaml (~> 1.0.0)
40
+ concurrent-ruby (1.2.2)
41
+ crack (0.4.5)
42
+ rexml
35
43
  crass (1.0.6)
36
44
  diff-lcs (1.4.4)
37
- erubi (1.9.0)
38
- faraday (1.0.1)
39
- multipart-post (>= 1.2, < 3)
40
- faraday_middleware (1.0.0)
45
+ erubi (1.12.0)
46
+ faraday (1.10.3)
47
+ faraday-em_http (~> 1.0)
48
+ faraday-em_synchrony (~> 1.0)
49
+ faraday-excon (~> 1.1)
50
+ faraday-httpclient (~> 1.0)
51
+ faraday-multipart (~> 1.0)
52
+ faraday-net_http (~> 1.0)
53
+ faraday-net_http_persistent (~> 1.0)
54
+ faraday-patron (~> 1.0)
55
+ faraday-rack (~> 1.0)
56
+ faraday-retry (~> 1.0)
57
+ ruby2_keywords (>= 0.0.4)
58
+ faraday-em_http (1.0.0)
59
+ faraday-em_synchrony (1.0.0)
60
+ faraday-excon (1.1.0)
61
+ faraday-httpclient (1.0.1)
62
+ faraday-multipart (1.0.4)
63
+ multipart-post (~> 2)
64
+ faraday-net_http (1.0.1)
65
+ faraday-net_http_persistent (1.2.0)
66
+ faraday-patron (1.0.0)
67
+ faraday-rack (1.0.0)
68
+ faraday-retry (1.0.3)
69
+ faraday_middleware (1.2.0)
41
70
  faraday (~> 1.0)
42
71
  hashdiff (1.0.1)
43
- i18n (1.8.4)
72
+ i18n (1.13.0)
44
73
  concurrent-ruby (~> 1.0)
45
- loofah (2.6.0)
74
+ loofah (2.20.0)
46
75
  crass (~> 1.0.2)
47
76
  nokogiri (>= 1.5.9)
48
- mini_portile2 (2.4.0)
49
- minitest (5.14.1)
50
- money (6.13.8)
77
+ mini_portile2 (2.8.2)
78
+ minitest (5.18.0)
79
+ money (6.16.0)
51
80
  i18n (>= 0.6.4, <= 2)
52
- multipart-post (2.1.1)
53
- nokogiri (1.10.10)
54
- mini_portile2 (~> 2.4.0)
55
- public_suffix (4.0.5)
56
- rack (2.2.3)
57
- rack-test (1.1.0)
58
- rack (>= 1.0, < 3)
81
+ multipart-post (2.3.0)
82
+ nokogiri (1.14.3)
83
+ mini_portile2 (~> 2.8.0)
84
+ racc (~> 1.4)
85
+ public_suffix (5.0.1)
86
+ racc (1.6.2)
87
+ rack (2.2.7)
88
+ rack-test (2.1.0)
89
+ rack (>= 1.3)
59
90
  rails-dom-testing (2.0.3)
60
91
  activesupport (>= 4.2.0)
61
92
  nokogiri (>= 1.6)
62
- rails-html-sanitizer (1.3.0)
63
- loofah (~> 2.3)
93
+ rails-html-sanitizer (1.5.0)
94
+ loofah (~> 2.19, >= 2.19.1)
64
95
  rake (12.3.3)
96
+ rexml (3.2.5)
65
97
  rspec (3.9.0)
66
98
  rspec-core (~> 3.9.0)
67
99
  rspec-expectations (~> 3.9.0)
@@ -75,27 +107,22 @@ GEM
75
107
  diff-lcs (>= 1.2.0, < 2.0)
76
108
  rspec-support (~> 3.9.0)
77
109
  rspec-support (3.9.3)
78
- safe_yaml (1.0.5)
79
- thread_safe (0.3.6)
80
- tzinfo (1.2.7)
81
- thread_safe (~> 0.1)
82
- webmock (3.8.3)
83
- addressable (>= 2.3.6)
110
+ ruby2_keywords (0.0.5)
111
+ tzinfo (2.0.6)
112
+ concurrent-ruby (~> 1.0)
113
+ webmock (3.18.1)
114
+ addressable (>= 2.8.0)
84
115
  crack (>= 0.3.2)
85
116
  hashdiff (>= 0.4.0, < 2.0.0)
86
- zeitwerk (2.4.0)
87
117
 
88
118
  PLATFORMS
89
119
  ruby
90
120
 
91
121
  DEPENDENCIES
92
- active_attr
93
- faraday
94
- faraday_middleware
95
- money
96
- rake (~> 12.0)
97
- rspec (~> 3.0)
122
+ investec_open_api!
123
+ rake
124
+ rspec
98
125
  webmock
99
126
 
100
127
  BUNDLED WITH
101
- 2.1.4
128
+ 2.4.12
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # InvestecOpenApi Client
2
2
 
3
- A simple client wrapper for the [Investec Open API](https://developer.investec.com/programmable-banking/#open-api).
3
+ [![Gem Version](https://badge.fury.io/rb/investec_open_api.svg)](https://badge.fury.io/rb/investec_open_api)
4
+
5
+ A simple client wrapper for the [Investec Open API](https://developer.investec.com/za/api-products).
4
6
 
5
7
  *Features:*
6
8
 
@@ -32,13 +34,21 @@ Create a new initializer called `investec_open_api.rb` in `config/initializers`:
32
34
 
33
35
  ```ruby
34
36
  InvestecOpenApi.configuration do |config|
35
- config.api_username = "https://openapi.investec.com/"
36
- config.api_password = "<Open API username>"
37
- config.api_url = "<Open API password>"
37
+ config.api_key = ENV['API_KEY']
38
+ config.client_id = ENV['CLIENT_ID']
39
+ config.client_secret = ENV['CLIENT_SECRET']
38
40
  end
39
41
  ```
40
42
 
41
- You will need to register for Open API access. Follow the steps in [Enrolment in the documentation](https://developer.investec.com/programmable-banking/#enrolment).
43
+ Create a new file in the root of your directory called `.env` and place the following:
44
+
45
+ ```
46
+ API_KEY='YOUR API KEY'
47
+ CLIENT_ID='YOUR CLIENT ID'
48
+ CLIENT_SECRET='YOUR CLIENT SECRET'
49
+ ```
50
+
51
+ You will need to register to get the following credentials. Follow the steps in [Enrolment in the documentation](https://developer.investec.com/programmable-banking/#enrolment).
42
52
 
43
53
 
44
54
  ## Usage
@@ -3,12 +3,12 @@ require_relative 'lib/investec_open_api/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "investec_open_api"
5
5
  spec.version = InvestecOpenApi::VERSION
6
- spec.authors = ["Markus Kuhn", "Jethro Flanagan"]
7
- spec.email = ["mkk0856@gmail.com", "jethroflanagan@gmail.com"]
6
+ spec.authors = ["Community Core Team"]
7
+ spec.email = ["community@make.dev"]
8
8
 
9
9
  spec.summary = %q{Investec Open API Wrapper}
10
10
  spec.description = %q{A small wrapper client for accessing Investec's Open API}
11
- spec.homepage = "https://github.com/offerzen/investec_open_api"
11
+ spec.homepage = "https://github.com/programmable-banking-community/investec_open_api"
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
14
 
@@ -26,4 +26,15 @@ Gem::Specification.new do |spec|
26
26
  spec.bindir = "exe"
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
+
30
+ # add runtime dependencies
31
+ spec.add_runtime_dependency 'active_attr'
32
+ spec.add_runtime_dependency 'faraday'
33
+ spec.add_runtime_dependency 'faraday_middleware'
34
+ spec.add_runtime_dependency 'money'
35
+
36
+ # add development dependencies
37
+ spec.add_development_dependency 'rake'
38
+ spec.add_development_dependency 'rspec'
39
+ spec.add_development_dependency 'webmock'
29
40
  end
@@ -4,6 +4,8 @@ require "investec_open_api/models/account"
4
4
  require "investec_open_api/models/transaction"
5
5
 
6
6
  class InvestecOpenApi::Client
7
+ INVESTEC_API_URL="https://openapi.investec.com/"
8
+
7
9
  def authenticate!
8
10
  @token = get_oauth_token["access_token"]
9
11
  end
@@ -25,24 +27,22 @@ class InvestecOpenApi::Client
25
27
  private
26
28
 
27
29
  def get_oauth_token
28
- auth_connection = Faraday.new(url: InvestecOpenApi.api_url) do |builder|
29
- builder.headers["Accept"] = "application/json"
30
- builder.basic_auth(InvestecOpenApi.api_username, InvestecOpenApi.api_password)
31
- builder.response :raise_error
32
- builder.response :json
33
- builder.adapter Faraday.default_adapter
34
- end
35
-
36
- response = auth_connection.post("identity/v2/oauth2/token", {
37
- grant_type: "client_credentials",
38
- scope: "accounts"
39
- }.to_query)
40
-
41
- response.body
30
+ auth_token = Base64.strict_encode64("#{InvestecOpenApi.client_id}:#{InvestecOpenApi.client_secret}")
31
+
32
+ response = Faraday.post(
33
+ "#{INVESTEC_API_URL}identity/v2/oauth2/token",
34
+ { grant_type: "client_credentials" },
35
+ {
36
+ 'x-api-key' => InvestecOpenApi.api_key,
37
+ 'Authorization' => "Basic #{auth_token}"
38
+ }
39
+ )
40
+
41
+ JSON.parse(response.body)
42
42
  end
43
43
 
44
44
  def connection
45
- @_connection ||= Faraday.new(url: InvestecOpenApi.api_url) do |builder|
45
+ @_connection ||= Faraday.new(url: INVESTEC_API_URL) do |builder|
46
46
  if @token
47
47
  builder.headers["Authorization"] = "Bearer #{@token}"
48
48
  end
@@ -8,6 +8,7 @@ module InvestecOpenApi::Models
8
8
  attribute :card_number
9
9
  attribute :amount
10
10
  attribute :description
11
+ attribute :date, type: Date
11
12
  attribute :posting_date, type: Date
12
13
  attribute :value_date, type: Date
13
14
  attribute :action_date, type: Date
@@ -18,7 +19,7 @@ module InvestecOpenApi::Models
18
19
  [
19
20
  amount.to_i,
20
21
  description,
21
- posting_date.to_s
22
+ date.to_s
22
23
  ].map(&:to_s).join('-')
23
24
  end
24
25
 
@@ -29,6 +30,10 @@ module InvestecOpenApi::Models
29
30
  params['amount'] = Money.new(adjusted_amount, "ZAR")
30
31
  end
31
32
 
33
+ if params['transactionDate']
34
+ params['date'] = params['transactionDate']
35
+ end
36
+
32
37
  super
33
38
  end
34
39
  end
@@ -1,3 +1,3 @@
1
1
  module InvestecOpenApi
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,12 +1,11 @@
1
1
  require "investec_open_api/version"
2
2
  require "investec_open_api/models/base"
3
+ require "investec_open_api/client"
3
4
 
4
5
  module InvestecOpenApi
5
6
  class Error < StandardError; end
6
7
 
7
- class << self
8
- mattr_accessor :api_url, :api_username, :api_password, :scope
9
- end
8
+ mattr_accessor :api_key, :client_id, :client_secret, :scope
10
9
 
11
10
  def self.configuration(&block)
12
11
  yield self
metadata CHANGED
@@ -1,20 +1,116 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: investec_open_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Markus Kuhn
8
- - Jethro Flanagan
7
+ - Community Core Team
9
8
  autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2020-07-30 00:00:00.000000000 Z
13
- dependencies: []
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: active_attr
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: money
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: rake
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: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
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'
14
111
  description: A small wrapper client for accessing Investec's Open API
15
112
  email:
16
- - mkk0856@gmail.com
17
- - jethroflanagan@gmail.com
113
+ - community@make.dev
18
114
  executables: []
19
115
  extensions: []
20
116
  extra_rdoc_files: []
@@ -38,14 +134,14 @@ files:
38
134
  - lib/investec_open_api/models/base.rb
39
135
  - lib/investec_open_api/models/transaction.rb
40
136
  - lib/investec_open_api/version.rb
41
- homepage: https://github.com/offerzen/investec_open_api
137
+ homepage: https://github.com/programmable-banking-community/investec_open_api
42
138
  licenses:
43
139
  - MIT
44
140
  metadata:
45
141
  allowed_push_host: https://rubygems.org
46
- homepage_uri: https://github.com/offerzen/investec_open_api
47
- source_code_uri: https://github.com/offerzen/investec_open_api
48
- changelog_uri: https://github.com/offerzen/investec_open_api
142
+ homepage_uri: https://github.com/programmable-banking-community/investec_open_api
143
+ source_code_uri: https://github.com/programmable-banking-community/investec_open_api
144
+ changelog_uri: https://github.com/programmable-banking-community/investec_open_api
49
145
  post_install_message:
50
146
  rdoc_options: []
51
147
  require_paths:
@@ -61,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
157
  - !ruby/object:Gem::Version
62
158
  version: '0'
63
159
  requirements: []
64
- rubygems_version: 3.0.8
160
+ rubygems_version: 3.4.1
65
161
  signing_key:
66
162
  specification_version: 4
67
163
  summary: Investec Open API Wrapper