revolut-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5b839fefd5c6946b7a458278de2a4d050d933b26379f0acbb491e8f0c47e9658
4
+ data.tar.gz: b3eed9fc2bec72a95d5ce2b46f67e71ec3837fa4657737f1d374e56c3aabc26f
5
+ SHA512:
6
+ metadata.gz: f6f9db586b2d09776bf3ac056377dc33969e1059e122b61c5ae24236790efc297f90997e1aaf92b79986d7c736e77202ee5f72a8024f08ecdb9904a52c18b617
7
+ data.tar.gz: 03e93f10777bc7b52cf94f9b78bab92c68b59ea149ec73e909af76ad563cf3f03714439f937a6f142d9b6e7d111d7608a43e52e372f01f831643ccede50da391
@@ -0,0 +1,27 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # pry history
14
+ .pry_history
15
+
16
+ # appraisals
17
+ /gemfiles/*.lock
18
+
19
+ # credentials
20
+ credentials.yml
21
+
22
+ # RVM
23
+ .ruby-version
24
+ .ruby-gemset
25
+
26
+ # DS_Store
27
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.0
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at sebastian.johnsson@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in revolut.gemspec
6
+ gemspec
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ revolut-api (0.1.0)
5
+ faraday (>= 0.15)
6
+ faraday_middleware (>= 0.12)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.5.2)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ coderay (1.1.2)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
16
+ diff-lcs (1.3)
17
+ faraday (0.15.2)
18
+ multipart-post (>= 1.2, < 3)
19
+ faraday_middleware (0.12.2)
20
+ faraday (>= 0.7.4, < 1.0)
21
+ hashdiff (0.3.7)
22
+ method_source (0.9.0)
23
+ multipart-post (2.0.0)
24
+ pry (0.11.3)
25
+ coderay (~> 1.1.0)
26
+ method_source (~> 0.9.0)
27
+ public_suffix (3.0.3)
28
+ rake (10.5.0)
29
+ rdoc (6.0.4)
30
+ rspec (3.8.0)
31
+ rspec-core (~> 3.8.0)
32
+ rspec-expectations (~> 3.8.0)
33
+ rspec-mocks (~> 3.8.0)
34
+ rspec-core (3.8.0)
35
+ rspec-support (~> 3.8.0)
36
+ rspec-expectations (3.8.1)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-mocks (3.8.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-support (3.8.0)
43
+ safe_yaml (1.0.4)
44
+ vcr (4.0.0)
45
+ webmock (3.4.2)
46
+ addressable (>= 2.3.6)
47
+ crack (>= 0.3.2)
48
+ hashdiff
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ bundler (~> 1.16)
55
+ pry (~> 0.11)
56
+ rake (~> 10.0)
57
+ rdoc (~> 6.0)
58
+ revolut-api!
59
+ rspec (~> 3.0)
60
+ vcr (~> 4.0)
61
+ webmock (~> 3.1)
62
+
63
+ BUNDLED WITH
64
+ 1.16.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Sebastian
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,238 @@
1
+ # Revolut::Api
2
+
3
+ Revolut::Api is a Ruby gem to interact with Revolut's internal consumer API.
4
+
5
+ This is the actual API used by the iOS/Android apps and this is not the business API.
6
+
7
+ I've reverse engineered the API by checking what endpoints are invoked using [Charles Proxy](https://www.charlesproxy.com).
8
+
9
+ This API is subject to change at any time and you should obviously take care using this client since it could result in loss of funds in your Revolut account.
10
+
11
+ Hopefully Revolut will release an official API for the personal app and not just for Revolut Business.
12
+
13
+ _NOTE: I do not take any responsibility of loss of funds or similar issues due to using this client!_
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'revolut-api'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install revolut-api
30
+
31
+ ## Usage
32
+
33
+ ### Public client
34
+
35
+ If you just want to use the public client to check exchange rates:
36
+
37
+ ```ruby
38
+ public_client = Revolut::Api::Public::Client.new
39
+ public_client.quotes(from: "EUR,USD", to: "SEK")
40
+ ```
41
+
42
+ You can also check quotes for cryptocurrencies:
43
+
44
+ ```ruby
45
+ public_client = Revolut::Api::Public::Client.new
46
+ public_client.quotes(from: "BTC,ETH,LTC,XRP", to: "USD")
47
+ ```
48
+
49
+ ### Private/authenticated client
50
+
51
+ #### Authentication
52
+
53
+ In order to use the private/authenticated endpoints of Revolut's API you need to sign in first using your phone number and your PIN/password:
54
+
55
+ ```ruby
56
+ client = Revolut::Api::Client.new
57
+ client.signin(phone: "+1555555555", password: "1337")
58
+ ```
59
+
60
+ After invoking this method Revolut will send you a text message with a code to confirm your sign in attempt. When you've received this code (which is valid for 10 minutes), do the following:
61
+
62
+ ```ruby
63
+ client.confirm_signin(phone: "+1555555555", code: "CODE_RECEIVED_FROM_REVOLUT")
64
+ => {:id=>"YOUR-USER-ID", :access_token=>"YOUR-ACCESS-TOKEN"}
65
+ ```
66
+
67
+ If the call is successful you should receive a hash containing your user id and your access token.
68
+
69
+ If you haven't configured the device id the library will automatically generate one using `SecureRandom.uuid`. I'd also suggest saving this id and use it for configuring subsequent API calls using the client:
70
+
71
+ ```ruby
72
+ Revolut::Api.configuration.device_id
73
+ => "SOME-RANDOM-DEVICE-GUID"
74
+ ```
75
+
76
+ Update your configuration file (e.g. an initializer if you're using Rails) for setting up Revolut::API:
77
+
78
+ ```ruby
79
+ Revolut::Api.configure do |config|
80
+ config.user_id = "YOUR-USER-ID"
81
+ config.access_token = "YOUR-ACCESS-TOKEN"
82
+ config.device_id = "SOME-RANDOM-DEVICE-GUID"
83
+ end
84
+ ```
85
+
86
+ This way you don't have to sign in / confirm your sign in next time you want to interact with the API.
87
+
88
+ Verify that you can call endpoints that require correct authorization:
89
+
90
+ ```ruby
91
+ client.user
92
+ => #<Revolut::Api::Response::User:0x00007ff27615eee0
93
+ @address=#<Revolut::Api::Response::Address:0x00007ff27615ed00 @city="Random Town", @country="US", @postcode="111111", @region="REGION", @street_line_one="Epic Street", @street_line_two=nil>,
94
+ @birth_date=[1999, 12, 31],
95
+ ```
96
+
97
+ Revolut::Api::AuthorizationError is raised if there are any issues with authorization.
98
+
99
+ #### User data
100
+
101
+ ##### User details
102
+
103
+ To get your current Revolut user details:
104
+
105
+ ```ruby
106
+ client.user
107
+ ```
108
+
109
+ ##### Wallet & pockets
110
+
111
+ ```ruby
112
+ client.wallet
113
+ ```
114
+
115
+ ##### Cards
116
+
117
+ ```ruby
118
+ client.cards
119
+ ```
120
+
121
+ ##### Update address
122
+
123
+ ```ruby
124
+ client.update_address(city: "New City")
125
+ ```
126
+
127
+ #### Transactions
128
+
129
+ Fetch and memoize all transactions executed the current year:
130
+
131
+ ```ruby
132
+ client.transactions(fetch_all: true, memoize: true)
133
+ ```
134
+
135
+ Fetch and memoize all completed transfer transactions executed the current year:
136
+
137
+ ```ruby
138
+ client.transactions(type: :transfer, completed: true, fetch_all: true, memoize: true)
139
+ ```
140
+
141
+ Fetch and memoize all completed card payment transactions executed the current year:
142
+
143
+ ```ruby
144
+ client.transactions(type: :card_payment, completed: true, fetch_all: true, memoize: true)
145
+ ```
146
+
147
+ Fetch and memoize all pending card payment transactions executed the current year:
148
+
149
+ ```ruby
150
+ client.transactions(type: :card_payment, pending: true, fetch_all: true, memoize: true)
151
+ ```
152
+
153
+ Fetch a specific transaction by its transaction id:
154
+
155
+ ```ruby
156
+ client.transaction("TRANSACTION_ID")
157
+ ```
158
+
159
+ #### Exchange
160
+
161
+ ##### Fiat
162
+
163
+ Exchange 0.1 EUR to USD:
164
+
165
+ ```ruby
166
+ client.exchange(from: "EUR", to: "USD", amount: 0.1, side: :sell)
167
+ ```
168
+
169
+ Exchange all available USD to EUR:
170
+
171
+ ```ruby
172
+ client.exchange(from: "USD", to: "EUR", amount: :all, side: :sell)
173
+ ```
174
+
175
+ ##### Cryptocurrency
176
+
177
+ Buy/exchange 10 EUR worth of BTC:
178
+
179
+ ```ruby
180
+ client.exchange(from: "EUR", to: "BTC", amount: 10, side: :sell)
181
+ ```
182
+
183
+ Buy/exchange 10 EUR worth of LTC:
184
+
185
+ ```ruby
186
+ client.exchange(from: "EUR", to: "LTC", amount: 10, side: :sell)
187
+ ```
188
+
189
+ Buy/exchange 10 EUR worth of ETH:
190
+
191
+ ```ruby
192
+ client.exchange(from: "EUR", to: "ETH", amount: 10, side: :sell)
193
+ ```
194
+
195
+ Buy/exchange 10 EUR worth of XRP:
196
+
197
+ ```ruby
198
+ client.exchange(from: "EUR", to: "XRP", amount: 10, side: :sell)
199
+ ```
200
+
201
+ ## Development & Testing
202
+
203
+ After checking out the repo, run `bin/setup` to install dependencies.
204
+
205
+ Copy credentials.yml.example to credentials.yml. If you do not already have your user id and an access token, run `bin/console`:
206
+
207
+ ```ruby
208
+ client = Revolut::Api::Client.new
209
+ client.signin(phone: "+1555555555", password: "1337")
210
+ client.confirm_signin(phone: "+1555555555", code: "CODE_RECEIVED_FROM_REVOLUT")
211
+ => {:id=>"YOUR-USER-ID", :access_token=>"YOUR-ACCESS-TOKEN"}
212
+ Revolut::Api.configuration.device_id
213
+ => "SOME-RANDOM-DEVICE-GUID"
214
+ ```
215
+
216
+ Update credentials.yml with your user id, access token and device id.
217
+
218
+ You can now run `rake spec` to run the tests.
219
+
220
+ WARNING: If you delete the VCR cassettes in the spec/fixtures/vcr_cassettes-folder real API calls will be made to Revolut and real data will be returned from Revolut.
221
+
222
+ For the current test suite this means performing actual exchanges from EUR to USD and exchanging _all_ available USD in your wallet to EUR.
223
+
224
+ _I repeat: I do not take any responsibility for any loss of funds._
225
+
226
+ The data returned from Revolut will contain your real user data. You have to manually edit all VCR cassette files and replace your personal/sensitive data with dummy data.
227
+
228
+ ## Contributing
229
+
230
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SebastianJ/revolut-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
231
+
232
+ ## License
233
+
234
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
235
+
236
+ ## Code of Conduct
237
+
238
+ Everyone interacting in the Revolut project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SebastianJ/revolut-api/blob/master/CODE_OF_CONDUCT.md).