revolut-connect 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +44 -39
- data/README.md +76 -4
- data/lib/revolut/resources/foreign_exchange.rb +28 -0
- data/lib/revolut/resources/rate.rb +15 -0
- data/lib/revolut/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0b5d6b9801d9238ff7de1397f5398dd26651944e8d82de4f80eb497cbd89878
|
4
|
+
data.tar.gz: d9057ed5cbcc377551854526e4be16fcc11ad5bbcb0419ec7e6806e36d81ef52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f7f02ffc2a8dba0c99ae87953ca8d02f880dde5343478678ff85fb88d0b736840b60260a82b893d750369214a7ae7b1cbe0f73e5643e9cf67d3e7973ceda8d
|
7
|
+
data.tar.gz: 778f06a9e1fe00e69450f8b74213461df563aa51ba51f95850f42cf75a6bca64a7cd7626b2ef44a69a7b8c0b1c15f5ccb163168170a32dcce99911bc4a15dd55
|
data/Gemfile
CHANGED
@@ -5,7 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in revolut-connect.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem "rake", "~> 13.
|
8
|
+
gem "rake", "~> 13.2"
|
9
9
|
|
10
10
|
group :development, :test do
|
11
11
|
gem "byebug", "~> 11.1"
|
@@ -14,13 +14,13 @@ group :development, :test do
|
|
14
14
|
gem "pry-rescue", "~> 1.5"
|
15
15
|
gem "pry-stack_explorer", "~> 0.6.1"
|
16
16
|
gem "dotenv"
|
17
|
-
gem "standard", "~> 1.
|
17
|
+
gem "standard", "~> 1.36"
|
18
18
|
gem "timecop"
|
19
19
|
end
|
20
20
|
|
21
21
|
group :test do
|
22
22
|
gem "rspec", "~> 3.0"
|
23
|
-
gem "webmock", "~> 3.23.
|
23
|
+
gem "webmock", "~> 3.23.1"
|
24
24
|
gem "simplecov"
|
25
25
|
gem "simplecov-cobertura"
|
26
26
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
revolut-connect (0.1.
|
4
|
+
revolut-connect (0.1.7)
|
5
5
|
faraday (>= 2)
|
6
6
|
faraday-retry (>= 2)
|
7
7
|
jwt (>= 1)
|
@@ -9,13 +9,13 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
addressable (2.8.
|
13
|
-
public_suffix (>= 2.0.2, <
|
12
|
+
addressable (2.8.7)
|
13
|
+
public_suffix (>= 2.0.2, < 7.0)
|
14
14
|
ast (2.4.2)
|
15
15
|
base64 (0.2.0)
|
16
|
-
bigdecimal (3.1.
|
17
|
-
binding_of_caller (1.0.
|
18
|
-
debug_inspector (>=
|
16
|
+
bigdecimal (3.1.8)
|
17
|
+
binding_of_caller (1.0.1)
|
18
|
+
debug_inspector (>= 1.2.0)
|
19
19
|
byebug (11.1.3)
|
20
20
|
coderay (1.1.3)
|
21
21
|
crack (1.0.0)
|
@@ -23,26 +23,28 @@ GEM
|
|
23
23
|
rexml
|
24
24
|
debug_inspector (1.2.0)
|
25
25
|
diff-lcs (1.5.1)
|
26
|
-
docile (1.4.
|
27
|
-
dotenv (3.1.
|
28
|
-
faraday (2.
|
26
|
+
docile (1.4.1)
|
27
|
+
dotenv (3.1.2)
|
28
|
+
faraday (2.10.0)
|
29
29
|
faraday-net_http (>= 2.0, < 3.2)
|
30
|
-
|
30
|
+
logger
|
31
|
+
faraday-net_http (3.1.1)
|
31
32
|
net-http
|
32
|
-
faraday-retry (2.2.
|
33
|
+
faraday-retry (2.2.1)
|
33
34
|
faraday (~> 2.0)
|
34
35
|
hashdiff (1.1.0)
|
35
36
|
interception (0.5)
|
36
|
-
json (2.7.
|
37
|
-
jwt (2.8.
|
37
|
+
json (2.7.2)
|
38
|
+
jwt (2.8.2)
|
38
39
|
base64
|
39
40
|
language_server-protocol (3.17.0.3)
|
40
41
|
lint_roller (1.1.0)
|
41
|
-
|
42
|
+
logger (1.6.0)
|
43
|
+
method_source (1.1.0)
|
42
44
|
net-http (0.4.1)
|
43
45
|
uri
|
44
|
-
parallel (1.
|
45
|
-
parser (3.3.0
|
46
|
+
parallel (1.25.1)
|
47
|
+
parser (3.3.4.0)
|
46
48
|
ast (~> 2.4.1)
|
47
49
|
racc
|
48
50
|
pry (0.14.2)
|
@@ -57,26 +59,27 @@ GEM
|
|
57
59
|
pry-stack_explorer (0.6.1)
|
58
60
|
binding_of_caller (~> 1.0)
|
59
61
|
pry (~> 0.13)
|
60
|
-
public_suffix (
|
61
|
-
racc (1.
|
62
|
+
public_suffix (6.0.1)
|
63
|
+
racc (1.8.0)
|
62
64
|
rainbow (3.1.1)
|
63
|
-
rake (13.1
|
64
|
-
regexp_parser (2.9.
|
65
|
-
rexml (3.2
|
65
|
+
rake (13.2.1)
|
66
|
+
regexp_parser (2.9.2)
|
67
|
+
rexml (3.3.2)
|
68
|
+
strscan
|
66
69
|
rspec (3.13.0)
|
67
70
|
rspec-core (~> 3.13.0)
|
68
71
|
rspec-expectations (~> 3.13.0)
|
69
72
|
rspec-mocks (~> 3.13.0)
|
70
73
|
rspec-core (3.13.0)
|
71
74
|
rspec-support (~> 3.13.0)
|
72
|
-
rspec-expectations (3.13.
|
75
|
+
rspec-expectations (3.13.1)
|
73
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
74
77
|
rspec-support (~> 3.13.0)
|
75
|
-
rspec-mocks (3.13.
|
78
|
+
rspec-mocks (3.13.1)
|
76
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
77
80
|
rspec-support (~> 3.13.0)
|
78
81
|
rspec-support (3.13.1)
|
79
|
-
rubocop (1.
|
82
|
+
rubocop (1.64.1)
|
80
83
|
json (~> 2.3)
|
81
84
|
language_server-protocol (>= 3.17.0)
|
82
85
|
parallel (~> 1.10)
|
@@ -84,14 +87,14 @@ GEM
|
|
84
87
|
rainbow (>= 2.2.2, < 4.0)
|
85
88
|
regexp_parser (>= 1.8, < 3.0)
|
86
89
|
rexml (>= 3.2.5, < 4.0)
|
87
|
-
rubocop-ast (>= 1.
|
90
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
88
91
|
ruby-progressbar (~> 1.7)
|
89
92
|
unicode-display_width (>= 2.4.0, < 3.0)
|
90
|
-
rubocop-ast (1.31.
|
91
|
-
parser (>= 3.3.0
|
92
|
-
rubocop-performance (1.
|
93
|
+
rubocop-ast (1.31.3)
|
94
|
+
parser (>= 3.3.1.0)
|
95
|
+
rubocop-performance (1.21.1)
|
93
96
|
rubocop (>= 1.48.1, < 2.0)
|
94
|
-
rubocop-ast (>= 1.
|
97
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
95
98
|
ruby-progressbar (1.13.0)
|
96
99
|
simplecov (0.22.0)
|
97
100
|
docile (~> 1.1)
|
@@ -102,28 +105,30 @@ GEM
|
|
102
105
|
simplecov (~> 0.19)
|
103
106
|
simplecov-html (0.12.3)
|
104
107
|
simplecov_json_formatter (0.1.4)
|
105
|
-
standard (1.
|
108
|
+
standard (1.39.2)
|
106
109
|
language_server-protocol (~> 3.17.0.2)
|
107
110
|
lint_roller (~> 1.0)
|
108
|
-
rubocop (~> 1.
|
111
|
+
rubocop (~> 1.64.0)
|
109
112
|
standard-custom (~> 1.0.0)
|
110
|
-
standard-performance (~> 1.
|
113
|
+
standard-performance (~> 1.4)
|
111
114
|
standard-custom (1.0.2)
|
112
115
|
lint_roller (~> 1.0)
|
113
116
|
rubocop (~> 1.50)
|
114
|
-
standard-performance (1.
|
117
|
+
standard-performance (1.4.0)
|
115
118
|
lint_roller (~> 1.1)
|
116
|
-
rubocop-performance (~> 1.
|
117
|
-
|
119
|
+
rubocop-performance (~> 1.21.0)
|
120
|
+
strscan (3.1.0)
|
121
|
+
timecop (0.9.10)
|
118
122
|
unicode-display_width (2.5.0)
|
119
123
|
uri (0.13.0)
|
120
|
-
webmock (3.23.
|
124
|
+
webmock (3.23.1)
|
121
125
|
addressable (>= 2.8.0)
|
122
126
|
crack (>= 0.3.2)
|
123
127
|
hashdiff (>= 0.4.0, < 2.0.0)
|
124
128
|
|
125
129
|
PLATFORMS
|
126
130
|
x86_64-darwin-23
|
131
|
+
x86_64-linux
|
127
132
|
|
128
133
|
DEPENDENCIES
|
129
134
|
byebug (~> 11.1)
|
@@ -132,14 +137,14 @@ DEPENDENCIES
|
|
132
137
|
pry-byebug (~> 3.10)
|
133
138
|
pry-rescue (~> 1.5)
|
134
139
|
pry-stack_explorer (~> 0.6.1)
|
135
|
-
rake (~> 13.
|
140
|
+
rake (~> 13.2)
|
136
141
|
revolut-connect!
|
137
142
|
rspec (~> 3.0)
|
138
143
|
simplecov
|
139
144
|
simplecov-cobertura
|
140
|
-
standard (~> 1.
|
145
|
+
standard (~> 1.36)
|
141
146
|
timecop
|
142
|
-
webmock (~> 3.23.
|
147
|
+
webmock (~> 3.23.1)
|
143
148
|
|
144
149
|
BUNDLED WITH
|
145
150
|
2.4.22
|
data/README.md
CHANGED
@@ -19,6 +19,7 @@ _:warning: For now this connector only supports the [Business API](https://devel
|
|
19
19
|
|
20
20
|
- `Account`
|
21
21
|
- `Counterparty`
|
22
|
+
- `ForeignExchange`
|
22
23
|
- `Payment`
|
23
24
|
- `Transaction`
|
24
25
|
- `TransferReason`
|
@@ -30,7 +31,6 @@ _:warning: For now this connector only supports the [Business API](https://devel
|
|
30
31
|
### Business API
|
31
32
|
|
32
33
|
- `Card` resource
|
33
|
-
- `ForeignExchange` resource
|
34
34
|
- `PaymentDraft` resource
|
35
35
|
- `PayoutLink` resource
|
36
36
|
- `TeamMember` resource
|
@@ -101,7 +101,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
101
101
|
And then, when you need to load the auth again:
|
102
102
|
|
103
103
|
```rb
|
104
|
-
Revolut::Auth.load(auth_to_persist)
|
104
|
+
Revolut::Auth.load(JSON.parse(auth_to_persist))
|
105
105
|
```
|
106
106
|
|
107
107
|
You can also store this json in an environment variable and the gem will auto load it:
|
@@ -149,8 +149,8 @@ Revolut.configure do |config|
|
|
149
149
|
# Useful for observability tools like Helicone: https://www.helicone.ai/
|
150
150
|
# Default: {}
|
151
151
|
config.global_headers = {
|
152
|
-
"Helicone-Auth": "Bearer {HELICONE_API_KEY}"
|
153
|
-
"helicone-stream-force-format" => "true"
|
152
|
+
"Helicone-Auth": "Bearer {HELICONE_API_KEY}",
|
153
|
+
"helicone-stream-force-format" => "true"
|
154
154
|
}
|
155
155
|
|
156
156
|
# Optional: Set the environment to be production or sandbox.
|
@@ -218,6 +218,35 @@ retrieved_counterparty = Revolut::Counterparty.retrieve(created_counterparty.id)
|
|
218
218
|
deleted = Revolut::Counterparty.delete(retrieved_counterparty.id)
|
219
219
|
```
|
220
220
|
|
221
|
+
#### ForeignExchange
|
222
|
+
|
223
|
+
<https://developer.revolut.com/docs/business/foreign-exchange>
|
224
|
+
|
225
|
+
```rb
|
226
|
+
# Exchange currencies
|
227
|
+
exchange = Revolut::ForeignExchange.exchange(
|
228
|
+
request_id: "49c6a48b-6b58-40a0-b974-0b8c4888c8a9", # The ID of the request, provided by you. It helps you identify the transaction in your system.
|
229
|
+
from: {
|
230
|
+
account_id: "8fe12333-5b27-4ad5-896c-38a25673fcc8",
|
231
|
+
currency: "USD"
|
232
|
+
},
|
233
|
+
to: {
|
234
|
+
account_id: "b4a3bcd2-c1dd-47cc-ac50-40cdb5856d42",
|
235
|
+
currency: "GBP",
|
236
|
+
amount: 10
|
237
|
+
},
|
238
|
+
reference: "exchange"
|
239
|
+
)
|
240
|
+
|
241
|
+
|
242
|
+
# Retrieve information on exchange rates between currencies
|
243
|
+
rate = Revolut::ForeignExchange.rate(
|
244
|
+
from: "EUR",
|
245
|
+
to: "USD",
|
246
|
+
amount: 100
|
247
|
+
)
|
248
|
+
```
|
249
|
+
|
221
250
|
#### Payments
|
222
251
|
|
223
252
|
<https://developer.revolut.com/docs/business/create-payment>
|
@@ -297,6 +326,49 @@ rotated = Revolut::Webhook.rotate_signing_secret(webhook.id)
|
|
297
326
|
failed_events = Revolut::Webhook.failed_events(webhook.id)
|
298
327
|
```
|
299
328
|
|
329
|
+
#### Webhooks in web applications (Rails example)
|
330
|
+
|
331
|
+
In order to start listening to revolut webhook events you'll first have to create a webhook in your revolut instance so that revolut knows that it needs to start pushing events to a certain URL:
|
332
|
+
|
333
|
+
```rb
|
334
|
+
webhook = Revolut::Webhook.create(url: "http://{your web app webhook URL}")
|
335
|
+
puts webhook.signing_secret
|
336
|
+
```
|
337
|
+
|
338
|
+
You can then copy the signing secret and store it in the env variables as follows:
|
339
|
+
|
340
|
+
```text
|
341
|
+
REVOLUT_WEBHOOK_SECRET={copy your signing secret here}
|
342
|
+
```
|
343
|
+
|
344
|
+
Then, in the revolut webhook controller, you can do the following to coerce revolut events (rails example):
|
345
|
+
|
346
|
+
```rb
|
347
|
+
class Webhooks::RevolutController < ApplicationController
|
348
|
+
|
349
|
+
def run
|
350
|
+
coerced = Revolut::WebhookEvent.construct_from(request, ENV["REVOLUT_WEBHOOK_SECRET"])
|
351
|
+
case coerced.event
|
352
|
+
when "TransactionStateChanged"
|
353
|
+
# handle event
|
354
|
+
when "PayoutLinkCreated"
|
355
|
+
# handle event
|
356
|
+
...
|
357
|
+
end
|
358
|
+
rescue Revolut::SignatureVerificationError => e
|
359
|
+
# Do something when the signature verification fails
|
360
|
+
head :bad_request
|
361
|
+
end
|
362
|
+
|
363
|
+
end
|
364
|
+
```
|
365
|
+
|
366
|
+
The rails routes would look something like this:
|
367
|
+
|
368
|
+
```rb
|
369
|
+
post "webhooks/revolut", to: "webhooks/revolut#run"
|
370
|
+
```
|
371
|
+
|
300
372
|
## Development
|
301
373
|
|
302
374
|
You can use `bin/console` to access an interactive console. This will preload environment variables from a `.env` file.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
|
3
|
+
module Revolut
|
4
|
+
class ForeignExchange < Resource
|
5
|
+
shallow
|
6
|
+
|
7
|
+
class << self
|
8
|
+
extend Forwardable
|
9
|
+
|
10
|
+
def resource_name
|
11
|
+
"exchange"
|
12
|
+
end
|
13
|
+
|
14
|
+
def exchange(**attrs)
|
15
|
+
response = http_client.post("/#{resource_name}", data: attrs)
|
16
|
+
|
17
|
+
new(response.body)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Delegate rate to the rate resource
|
21
|
+
def_delegators :rate_resource, :rate
|
22
|
+
|
23
|
+
def rate_resource
|
24
|
+
Revolut::Rate
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/revolut/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revolut-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Mochetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -82,7 +82,9 @@ files:
|
|
82
82
|
- lib/revolut/resources/auth.rb
|
83
83
|
- lib/revolut/resources/bank_account.rb
|
84
84
|
- lib/revolut/resources/counterparty.rb
|
85
|
+
- lib/revolut/resources/foreign_exchange.rb
|
85
86
|
- lib/revolut/resources/payment.rb
|
87
|
+
- lib/revolut/resources/rate.rb
|
86
88
|
- lib/revolut/resources/resource.rb
|
87
89
|
- lib/revolut/resources/simulation.rb
|
88
90
|
- lib/revolut/resources/transaction.rb
|