truelayer 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -0
- data/Gemfile.lock +5 -33
- data/lib/truelayer/account.rb +1 -1
- data/lib/truelayer/authentication_repository.rb +1 -1
- data/lib/truelayer/card.rb +20 -0
- data/lib/truelayer/cards_repository.rb +49 -0
- data/lib/truelayer/client.rb +6 -2
- data/lib/truelayer/configuration.rb +1 -0
- data/lib/truelayer/errors.rb +4 -0
- data/lib/truelayer/token.rb +4 -0
- data/lib/truelayer/transaction.rb +3 -3
- data/lib/truelayer/version.rb +1 -1
- data/lib/truelayer/webhook_payload.rb +2 -2
- data/lib/truelayer.rb +1 -0
- data/truelayer.gemspec +1 -10
- metadata +9 -133
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97b25ca97786a2e59e0770f9f1b827f842c0e10ca638090373bd7eeb5df76053
|
4
|
+
data.tar.gz: 91ff1ac6dbe044c5c2626c33737110525ed67b3fe0a07ef100a2095d054bb2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf13e238cdc673f8fb9992fc9095e072a2227b3008eeac7bcfe685cf56f349860ef1c1122a0ed8542f1acb444e742946a78ce4bab1ffa313bbb8f6e9c533e4d6
|
7
|
+
data.tar.gz: f04e331d511d80d41f070384d1fb015be598039da7046ae7cac7030fd9be2fdad1f79616ca4eef18b95995043214f733c93478553128b9db13dcc919c0b2bc58
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
truelayer (0.1.
|
5
|
-
faraday
|
6
|
-
faraday_middleware
|
7
|
-
faraday_middleware-multi_json
|
4
|
+
truelayer (0.1.2)
|
5
|
+
faraday (~> 2.7)
|
8
6
|
multi_json
|
9
7
|
|
10
8
|
GEM
|
@@ -17,38 +15,13 @@ GEM
|
|
17
15
|
rexml
|
18
16
|
diff-lcs (1.4.4)
|
19
17
|
dotenv (2.7.6)
|
20
|
-
faraday (
|
21
|
-
faraday-
|
22
|
-
faraday-em_synchrony (~> 1.0)
|
23
|
-
faraday-excon (~> 1.1)
|
24
|
-
faraday-httpclient (~> 1.0)
|
25
|
-
faraday-multipart (~> 1.0)
|
26
|
-
faraday-net_http (~> 1.0)
|
27
|
-
faraday-net_http_persistent (~> 1.0)
|
28
|
-
faraday-patron (~> 1.0)
|
29
|
-
faraday-rack (~> 1.0)
|
30
|
-
faraday-retry (~> 1.0)
|
18
|
+
faraday (2.7.4)
|
19
|
+
faraday-net_http (>= 2.0, < 3.1)
|
31
20
|
ruby2_keywords (>= 0.0.4)
|
32
|
-
faraday-
|
33
|
-
faraday-em_synchrony (1.0.0)
|
34
|
-
faraday-excon (1.1.0)
|
35
|
-
faraday-httpclient (1.0.1)
|
36
|
-
faraday-multipart (1.0.3)
|
37
|
-
multipart-post (>= 1.2, < 3)
|
38
|
-
faraday-net_http (1.0.1)
|
39
|
-
faraday-net_http_persistent (1.2.0)
|
40
|
-
faraday-patron (1.0.0)
|
41
|
-
faraday-rack (1.0.0)
|
42
|
-
faraday-retry (1.0.3)
|
43
|
-
faraday_middleware (1.2.0)
|
44
|
-
faraday (~> 1.0)
|
45
|
-
faraday_middleware-multi_json (0.0.6)
|
46
|
-
faraday_middleware
|
47
|
-
multi_json
|
21
|
+
faraday-net_http (3.0.2)
|
48
22
|
hashdiff (1.0.1)
|
49
23
|
method_source (1.0.0)
|
50
24
|
multi_json (1.15.0)
|
51
|
-
multipart-post (2.1.1)
|
52
25
|
pry (0.13.1)
|
53
26
|
coderay (~> 1.1)
|
54
27
|
method_source (~> 1.0)
|
@@ -81,7 +54,6 @@ PLATFORMS
|
|
81
54
|
x86_64-linux
|
82
55
|
|
83
56
|
DEPENDENCIES
|
84
|
-
bundler (~> 2.2)
|
85
57
|
dotenv
|
86
58
|
pry
|
87
59
|
rake
|
data/lib/truelayer/account.rb
CHANGED
@@ -7,7 +7,7 @@ require 'truelayer/account_number'
|
|
7
7
|
module Truelayer
|
8
8
|
class Account < BaseModel
|
9
9
|
attributes :update_timestamp, :account_id, :account_type, :display_name,
|
10
|
-
|
10
|
+
:currency, :account_number, :provider, :provider_id
|
11
11
|
|
12
12
|
def self.build(json:)
|
13
13
|
super.tap do |record|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'truelayer/base_model'
|
5
|
+
|
6
|
+
module Truelayer
|
7
|
+
class Card < BaseModel
|
8
|
+
attributes :update_timestamp, :account_id, :card_type,
|
9
|
+
:card_network, :partial_card_number, :name_on_card,
|
10
|
+
:valid_from, :valid_to, :display_name,
|
11
|
+
:currency, :provider, :provider_id
|
12
|
+
|
13
|
+
def self.build(json:)
|
14
|
+
super.tap do |record|
|
15
|
+
record.update_timestamp = Time.parse(record.update_timestamp) if record.update_timestamp
|
16
|
+
record.provider_id = record.provider[:provider_id] if record.provider
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'truelayer/base_repository'
|
4
|
+
require 'truelayer/response'
|
5
|
+
require 'truelayer/card'
|
6
|
+
require 'truelayer/balance'
|
7
|
+
require 'truelayer/transaction'
|
8
|
+
|
9
|
+
module Truelayer
|
10
|
+
class CardsRepository < BaseRepository
|
11
|
+
def all_cards(webhook_uri: nil)
|
12
|
+
response = get('/data/v1/cards', params: async_params(webhook_uri))
|
13
|
+
|
14
|
+
Response.build_with_results(json: response.body, results_class: Card)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_card(card_id, webhook_uri: nil)
|
18
|
+
url = format_url('/data/v1/cards/:card_id', card_id: card_id)
|
19
|
+
response = get(url, params: async_params(webhook_uri))
|
20
|
+
|
21
|
+
Response.build_with_results(json: response.body, results_class: Card)
|
22
|
+
end
|
23
|
+
|
24
|
+
def current_balance(card_id, webhook_uri: nil)
|
25
|
+
url = format_url('/data/v1/cards/:card_id/balance', card_id: card_id)
|
26
|
+
response = get(url, params: async_params(webhook_uri))
|
27
|
+
|
28
|
+
Response.build_with_results(json: response.body, results_class: Balance)
|
29
|
+
end
|
30
|
+
|
31
|
+
def transactions(card_id, from: nil, to: nil, webhook_uri: nil)
|
32
|
+
url = format_url('/data/v1/cards/:card_id/transactions', card_id: card_id)
|
33
|
+
response = get(url, params: { from: from, to: to }.merge(async_params(webhook_uri)))
|
34
|
+
|
35
|
+
Response.build_with_results(json: response.body, results_class: Transaction)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def async_params(webhook_uri)
|
41
|
+
{}.tap do |params|
|
42
|
+
if webhook_uri
|
43
|
+
params[:async] = true
|
44
|
+
params[:webhook_uri] = webhook_uri
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/truelayer/client.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
-
|
4
|
+
|
5
5
|
require 'truelayer/configuration'
|
6
6
|
require 'truelayer/errors'
|
7
7
|
|
@@ -34,7 +34,7 @@ module Truelayer
|
|
34
34
|
def connection
|
35
35
|
@connection ||= Faraday.new(url: base_url) do |conn|
|
36
36
|
conn.request :truelayer_auth, access_token
|
37
|
-
conn.response :
|
37
|
+
conn.response :json, parser_options: { symbolize_names: true }
|
38
38
|
if Truelayer.configuration.debug
|
39
39
|
conn.response :logger, nil, { headers: true, bodies: Truelayer.configuration.verbose }
|
40
40
|
end
|
@@ -50,8 +50,12 @@ module Truelayer
|
|
50
50
|
raise InvalidRequestError, response.body
|
51
51
|
when 401
|
52
52
|
raise UnauthorizedError, response.body
|
53
|
+
when 403
|
54
|
+
raise AccessDeniedError, response.body
|
53
55
|
when 404
|
54
56
|
raise NotFoundError, response.body
|
57
|
+
when 501
|
58
|
+
raise EndpointNotSupportedError, response.body
|
55
59
|
else
|
56
60
|
raise GenericError, "#{response.status}: #{response.body}"
|
57
61
|
end
|
data/lib/truelayer/errors.rb
CHANGED
data/lib/truelayer/token.rb
CHANGED
@@ -8,9 +8,9 @@ require 'truelayer/transaction_meta'
|
|
8
8
|
module Truelayer
|
9
9
|
class Transaction < BaseModel
|
10
10
|
attributes :transaction_id, :normalised_provider_transaction_id, :provider_transaction_id,
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
:timestamp, :description, :amount, :currency,
|
12
|
+
:transaction_type, :transaction_category, :transaction_classification,
|
13
|
+
:merchant_name, :running_balance, :meta
|
14
14
|
|
15
15
|
def self.build(json:)
|
16
16
|
super.tap do |record|
|
data/lib/truelayer/version.rb
CHANGED
@@ -5,8 +5,8 @@ require 'truelayer/base_model'
|
|
5
5
|
module Truelayer
|
6
6
|
class WebhookPayload < BaseModel
|
7
7
|
attributes :request_timestamp, :request_uri,
|
8
|
-
|
9
|
-
|
8
|
+
:credentials_id, :results_uri, :status, :task_id,
|
9
|
+
:error, :error_description
|
10
10
|
|
11
11
|
def success?
|
12
12
|
status == 'Succeeded'
|
data/lib/truelayer.rb
CHANGED
data/truelayer.gemspec
CHANGED
@@ -23,15 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_dependency 'faraday'
|
27
|
-
spec.add_dependency 'faraday_middleware'
|
28
|
-
spec.add_dependency 'faraday_middleware-multi_json'
|
26
|
+
spec.add_dependency 'faraday', '~> 2.7'
|
29
27
|
spec.add_dependency 'multi_json'
|
30
|
-
spec.add_development_dependency 'bundler', '~> 2.2'
|
31
|
-
spec.add_development_dependency 'dotenv'
|
32
|
-
spec.add_development_dependency 'pry'
|
33
|
-
spec.add_development_dependency 'rake'
|
34
|
-
spec.add_development_dependency 'rspec'
|
35
|
-
spec.add_development_dependency 'vcr'
|
36
|
-
spec.add_development_dependency 'webmock'
|
37
28
|
end
|
metadata
CHANGED
@@ -1,57 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: truelayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finpoint
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
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_middleware
|
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-multi_json
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
17
|
+
- - "~>"
|
46
18
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
19
|
+
version: '2.7'
|
48
20
|
type: :runtime
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
|
-
- - "
|
24
|
+
- - "~>"
|
53
25
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
26
|
+
version: '2.7'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: multi_json
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,104 +38,6 @@ dependencies:
|
|
66
38
|
- - ">="
|
67
39
|
- !ruby/object:Gem::Version
|
68
40
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: bundler
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '2.2'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '2.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: dotenv
|
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: pry
|
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'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rspec
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: vcr
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: webmock
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
41
|
description: Truelayer client
|
168
42
|
email:
|
169
43
|
- nenad@finpoint.co.uk
|
@@ -190,6 +64,8 @@ files:
|
|
190
64
|
- lib/truelayer/balance.rb
|
191
65
|
- lib/truelayer/base_model.rb
|
192
66
|
- lib/truelayer/base_repository.rb
|
67
|
+
- lib/truelayer/card.rb
|
68
|
+
- lib/truelayer/cards_repository.rb
|
193
69
|
- lib/truelayer/client.rb
|
194
70
|
- lib/truelayer/configuration.rb
|
195
71
|
- lib/truelayer/errors.rb
|
@@ -221,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
97
|
- !ruby/object:Gem::Version
|
222
98
|
version: '0'
|
223
99
|
requirements: []
|
224
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.2.3
|
225
101
|
signing_key:
|
226
102
|
specification_version: 4
|
227
103
|
summary: Truelayer client
|