flinks 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b388d711a383c65fff4792fc54d11024d5c55af0dc0d49bbaa5767125d5f59c
4
- data.tar.gz: 7575f6d1664374bf957dbd8458d1794f9ce6531eef1430a3def130dc8ca701a9
3
+ metadata.gz: e828957d3fa28a60e8efaef004a27bd79adab1093434e03220a73cb489f55dc1
4
+ data.tar.gz: 5ecfa2c75dcd95a2800d9b753fadb742136af10ad6edb6bd785f097af0344f3c
5
5
  SHA512:
6
- metadata.gz: 1c8c33bfc2a5b21a400d0294f6affa86b630cae61c6adce81bf05d4052c76bc821c4f2c9ace48ed717d973d7482a173728263aa5d9287d7cdb7e20d315fed1fa
7
- data.tar.gz: a0fe976c3bfec049d736dbb4feffeee1b0767f811fa9938527bb20ca57092b0b6004d1e6910073740dc39217d720f271914875c6e9cbe4a164c516e490757622
6
+ metadata.gz: 11238f6378dd82d401a2ca78a6fb2d4f96eefd4da19c39ae6c2e07741dcaf1aaac8415d171e5ecad3841e2cf2daeb4c320eab3caac241c904544ed9015931e1b
7
+ data.tar.gz: 26538846f2e14ca59b2d7449e4da2afb147ec89129d14b6b692586713d796458fad5915fda14e2c4ba4d6046013cedf61c6808472701d3e6e7a8e71479bd6195
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/flinks.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: flinks 0.1.1 ruby lib
5
+ # stub: flinks 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "flinks".freeze
9
- s.version = "0.1.1"
9
+ s.version = "0.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
29
29
  "flinks.gemspec",
30
30
  "lib/flinks.rb",
31
31
  "lib/flinks/api/account.rb",
32
+ "lib/flinks/api/authorize.rb",
32
33
  "lib/flinks/api/card.rb",
33
34
  "lib/flinks/api/refresh.rb",
34
35
  "lib/flinks/api/statement.rb",
@@ -36,10 +37,11 @@ Gem::Specification.new do |s|
36
37
  "lib/flinks/error.rb",
37
38
  "lib/flinks/request.rb",
38
39
  "lib/flinks/version.rb",
39
- "spec/lib/api/account.rb",
40
- "spec/lib/api/card.rb",
41
- "spec/lib/api/refresh.rb",
42
- "spec/lib/api/statement.rb",
40
+ "spec/lib/api/account_spec.rb",
41
+ "spec/lib/api/authorize_spec.rb",
42
+ "spec/lib/api/card_spec.rb",
43
+ "spec/lib/api/refresh_spec.rb",
44
+ "spec/lib/api/statement_spec.rb",
43
45
  "spec/lib/client_spec.rb",
44
46
  "spec/spec_helper.rb"
45
47
  ]
@@ -1,24 +1,26 @@
1
+ require 'dry-validation'
2
+
1
3
  module Flinks
2
4
  module API
3
5
  module Account
4
6
  AccountSummaryRequestSchema = Dry::Validation.Schema do
5
7
  required(:request_id).filled(:str?)
6
- optional(:direct_refresh).maybe(:bool?)
7
- optional(:with_balance).maybe(:bool?)
8
- optional(:with_transactions).maybe(:bool?)
9
- optional(:with_account_identity).maybe(:bool?)
10
- optional(:most_recent).maybe(:bool?)
11
- optional(:most_recent_cached).maybe(:bool?)
8
+ optional(:direct_refresh).filled(:bool?)
9
+ optional(:with_balance).filled(:bool?)
10
+ optional(:with_transactions).filled(:bool?)
11
+ optional(:with_account_identity).filled(:bool?)
12
+ optional(:most_recent).filled(:bool?)
13
+ optional(:most_recent_cached).filled(:bool?)
12
14
  end
13
15
 
14
16
  AccountDetailRequestSchema = Dry::Validation.Schema do
15
17
  required(:request_id).filled(:str?)
16
- optional(:with_account_identity).maybe(:bool?)
17
- optional(:with_kyc).maybe(:bool?)
18
- optional(:with_transactions).maybe(:bool?)
19
- optional(:with_balance).maybe(:bool?)
20
- optional(:get_mfa_questions_answers).maybe(:bool?)
21
- optional(:date_from).maybe(:date?)
18
+ optional(:with_account_identity).filled(:bool?)
19
+ optional(:with_kyc).filled(:bool?)
20
+ optional(:with_transactions).filled(:bool?)
21
+ optional(:with_balance).filled(:bool?)
22
+ optional(:get_mfa_questions_answers).filled(:bool?)
23
+ optional(:date_from).filled(:date?)
22
24
  optional(:date_to) { date? | date_time? }
23
25
  optional(:accounts_filter).each(:str?)
24
26
 
@@ -30,8 +32,8 @@ module Flinks
30
32
  end
31
33
 
32
34
  optional(:days_of_transactions).included_in?(['Days90', 'Days360'])
33
- optional(:most_recent).maybe(:bool?)
34
- optional(:most_recent_cached).maybe(:bool?)
35
+ optional(:most_recent).filled(:bool?)
36
+ optional(:most_recent_cached).filled(:bool?)
35
37
  end
36
38
 
37
39
  # @see https://sandbox-api.flinks.io/Readme/#get-accounts-summary
@@ -0,0 +1,74 @@
1
+ require 'dry-validation'
2
+
3
+ module Flinks
4
+ module API
5
+ module Authorize
6
+ AuthorizeRequestSchema = Dry::Validation.Schema do
7
+ required(:login_id).filled(:str?)
8
+
9
+ optional(:language).filled(:str?)
10
+ optional(:save).filled(:bool?)
11
+ optional(:security_responses).filled(:hash?)
12
+ optional(:schedule_refresh).filled(:bool?)
13
+ optional(:direct_refresh).filled(:bool?)
14
+ optional(:days_of_transactions).included_in?(['Days90', 'Days360'])
15
+ optional(:most_recent_cached).filled(:bool?)
16
+ optional(:with_transactions).filled(:bool?)
17
+ optional(:with_balance).filled(:bool?)
18
+ end
19
+
20
+ AuthorizeWithCredentialsRequestSchema = Dry::Validation.Schema do
21
+ required(:username).filled?(:str?)
22
+ required(:password).filled?(:str?)
23
+ required(:institution).filled?(:str?)
24
+
25
+ optional(:language).filled(:str?)
26
+ optional(:save).filled(:bool?)
27
+ optional(:security_responses).filled(:hash?)
28
+ optional(:schedule_refresh).filled(:bool?)
29
+ optional(:direct_refresh).filled(:bool?)
30
+ optional(:days_of_transactions).included_in?(['Days90', 'Days360'])
31
+ optional(:most_recent_cached).filled(:bool?)
32
+ optional(:with_transactions).filled(:bool?)
33
+ optional(:with_balance).filled(:bool?)
34
+ end
35
+
36
+ AuthorizeMultipleRequestSchema = Dry::Validation.Schema do
37
+ required(:login_ids).each(:str?)
38
+ end
39
+
40
+ # @see https://sandbox-api.flinks.io/Readme/#authorize
41
+ # @param login_id [String]
42
+ # @param options [Hash]
43
+ # @return [Hash]
44
+ def authorize(login_id:, options: {})
45
+ payload = AuthorizeRequestSchema.call(options.merge(login_id: login_id))
46
+ raise ArgumentError, error_message(payload) unless payload.success?
47
+
48
+ post("#{customer_id}/BankingServices/Authorize", body: payload.to_hash)
49
+ end
50
+
51
+ # @see https://sandbox-api.flinks.io/Readme/#authorize
52
+ # @param username [String]
53
+ # @param password [String]
54
+ # @param institution [String]
55
+ # @param options [Hash]
56
+ def authorize_with_credentials(username:, password:, institution:, options: {})
57
+ payload = AuthorizeWithCredentialsRequestSchema.call(options.merge(username: username, password: password, institution: institution))
58
+ raise ArgumentError, error_message(payload) unless payload.success?
59
+
60
+ post("#{customer_id}/BankingServices/Authorize", body: payload.to_hash)
61
+ end
62
+
63
+ # @see https://sandbox-api.flinks.io/Readme/#authorize-multiple
64
+ # @param login_ids [Array]
65
+ # @return [Hash]
66
+ def authorize_multiple(login_ids:)
67
+ payload = AuthorizeMultipleRequestSchema.call(options.merge(login_ids: login_ids))
68
+ raise ArgumentError, error_message(payload) unless payload.success?
69
+
70
+ post("#{customer_id}/BankingServices/AuthorizeMultiple", body: payload.to_hash)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -1,3 +1,5 @@
1
+ require 'dry-validation'
2
+
1
3
  module Flinks
2
4
  module API
3
5
  module Statement
data/lib/flinks/client.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext/object'
3
3
  require 'dry-initializer'
4
- require 'dry-validation'
5
4
 
6
5
  require 'flinks/version'
7
6
  require 'flinks/request'
8
7
  require 'flinks/api/account'
8
+ require 'flinks/api/authorize'
9
9
  require 'flinks/api/card'
10
10
  require 'flinks/api/refresh'
11
11
  require 'flinks/api/statement'
@@ -16,6 +16,7 @@ module Flinks
16
16
 
17
17
  include Flinks::Request
18
18
  include Flinks::API::Account
19
+ include Flinks::API::Authorize
19
20
  include Flinks::API::Card
20
21
  include Flinks::API::Refresh
21
22
  include Flinks::API::Statement
File without changes
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flinks::API::Authorize do
4
+ let(:api_endpoint) { Flinks::Client.dry_initializer.definitions[:api_endpoint].default.call }
5
+ let(:client) { Flinks.new(customer_id: 'customer_id') }
6
+
7
+ describe '#authorize' do
8
+ let(:login_id) { 'login_id' }
9
+
10
+ before do
11
+ stub_request(:post, /#{api_endpoint}/)
12
+ .to_return(status: 200, body: "{}", headers: { 'Content-Type'=>'application/json' })
13
+ end
14
+
15
+ it "returns an object" do
16
+ expect(client.authorize(login_id: login_id)).to be_a(Hash)
17
+ end
18
+
19
+ context "with valid options" do
20
+ let(:options) do
21
+ {
22
+ language: 'language',
23
+ save: true,
24
+ security_responses: {
25
+ 'Question': ['response']
26
+ },
27
+ schedule_refresh: true,
28
+ direct_refresh: true,
29
+ days_of_transactions: 'Days90',
30
+ most_recent_cached: true,
31
+ with_transactions: true,
32
+ with_balance: true
33
+ }
34
+ end
35
+
36
+ it "returns an object" do
37
+ expect(client.authorize(login_id: login_id, options: options)).to be_a(Hash)
38
+ end
39
+ end
40
+
41
+ context "with invalid options" do
42
+ let(:options) do
43
+ {
44
+ language: 'invalid',
45
+ save: 'invalid',
46
+ security_responses: 'invalid',
47
+ schedule_refresh: 'invalid',
48
+ direct_refresh: 'invalid',
49
+ days_of_transactions: 'invalid',
50
+ most_recent_cached: 'invalid',
51
+ with_transactions: 'invalid',
52
+ with_balance: 'invalid'
53
+ }
54
+ end
55
+
56
+ it "raises an error" do
57
+ expect {
58
+ client.accounts_summary(login_id: login_id, options: options)
59
+ }.to raise_error(ArgumentError)
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '#authorize_with_credentials' do
65
+ let(:username) { 'username' }
66
+ let(:password) { 'password' }
67
+ let(:institution) { 'institution' }
68
+
69
+ before do
70
+ stub_request(:post, /#{api_endpoint}/)
71
+ .to_return(status: 200, body: "{}", headers: { 'Content-Type'=>'application/json' })
72
+ end
73
+
74
+ context "with valid options" do
75
+ let(:options) do
76
+ {
77
+ language: 'language',
78
+ save: true,
79
+ security_responses: {
80
+ 'Question': ['response']
81
+ },
82
+ schedule_refresh: true,
83
+ direct_refresh: true,
84
+ days_of_transactions: 'Days90',
85
+ most_recent_cached: true,
86
+ with_transactions: true,
87
+ with_balance: true
88
+ }
89
+ end
90
+
91
+ it "returns an object" do
92
+ expect(client.authorize_with_credentials(username: username, password: password, institution: institution, options: options)).to be_a(Hash)
93
+ end
94
+ end
95
+
96
+ context "with invalid options" do
97
+ let(:options) do
98
+ {
99
+ language: 'invalid',
100
+ save: 'invalid',
101
+ security_responses: 'invalid',
102
+ schedule_refresh: 'invalid',
103
+ direct_refresh: 'invalid',
104
+ days_of_transactions: 'invalid',
105
+ most_recent_cached: 'invalid',
106
+ with_transactions: 'invalid',
107
+ with_balance: 'invalid'
108
+ }
109
+ end
110
+
111
+ it "raises an error" do
112
+ expect {
113
+ client.authorize_with_credentials(username: username, password: password, institution: institution, options: options)
114
+ }.to raise_error(ArgumentError)
115
+ end
116
+ end
117
+ end
118
+ end
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Dionne
@@ -182,6 +182,7 @@ files:
182
182
  - flinks.gemspec
183
183
  - lib/flinks.rb
184
184
  - lib/flinks/api/account.rb
185
+ - lib/flinks/api/authorize.rb
185
186
  - lib/flinks/api/card.rb
186
187
  - lib/flinks/api/refresh.rb
187
188
  - lib/flinks/api/statement.rb
@@ -189,10 +190,11 @@ files:
189
190
  - lib/flinks/error.rb
190
191
  - lib/flinks/request.rb
191
192
  - lib/flinks/version.rb
192
- - spec/lib/api/account.rb
193
- - spec/lib/api/card.rb
194
- - spec/lib/api/refresh.rb
195
- - spec/lib/api/statement.rb
193
+ - spec/lib/api/account_spec.rb
194
+ - spec/lib/api/authorize_spec.rb
195
+ - spec/lib/api/card_spec.rb
196
+ - spec/lib/api/refresh_spec.rb
197
+ - spec/lib/api/statement_spec.rb
196
198
  - spec/lib/client_spec.rb
197
199
  - spec/spec_helper.rb
198
200
  homepage: http://github.com/phildionne/flinks