revolut 0.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +42 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -12
- data/LICENSE.txt +5 -5
- data/README.md +10 -6
- data/Rakefile +2 -0
- data/bin/console +5 -4
- data/lib/revolut.rb +3 -0
- data/lib/revolut/client.rb +8 -0
- data/lib/revolut/clients/accounts.rb +15 -3
- data/lib/revolut/clients/counterparties.rb +10 -4
- data/lib/revolut/clients/exchanges.rb +16 -0
- data/lib/revolut/clients/payment_drafts.rb +50 -0
- data/lib/revolut/clients/payments.rb +61 -0
- data/lib/revolut/clients/webhooks.rb +7 -1
- data/lib/revolut/configuration.rb +9 -8
- data/lib/revolut/connection.rb +22 -21
- data/lib/revolut/error.rb +6 -1
- data/lib/revolut/mash.rb +2 -0
- data/lib/revolut/middleware/raise_error.rb +2 -2
- data/lib/revolut/utils.rb +3 -1
- data/lib/revolut/version.rb +3 -1
- data/revolut.gemspec +14 -8
- metadata +69 -25
- data/.travis.yml +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c367065fb41fb43dea368cf659cb40f41e8354dd429f2824f57dfec90f4f14b6
|
4
|
+
data.tar.gz: e2ff0126724503a91cfe775b87bb1b1f4f6a8d5a1e9e32126ac225a949780656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ed254c216d133cc1ed3a79eef9f378cde42d6f1b391bcda5f31c3d32d37fb4d891e329f69dc00a6a3cce401b62f7b3253b00b7535c899bc8dc46840bf29c721
|
7
|
+
data.tar.gz: 664ba4ffd5b779c68dc8593910eff1002514e08706ac7ac8d4f32d32860e35f4f167b9d9263df1a55bb8d73f80cd0fc55575dfdb3514da1739939bef006e8960
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
name: Test
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [2.5, 2.6, 2.7, '3.0']
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- name: Checkout
|
16
|
+
uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Test
|
23
|
+
env:
|
24
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
25
|
+
run: |
|
26
|
+
bundle exec rspec
|
27
|
+
|
28
|
+
rubocop:
|
29
|
+
name: RuboCop
|
30
|
+
runs-on: ubuntu-latest
|
31
|
+
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
- name: Set up Ruby
|
35
|
+
uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: '3.0'
|
38
|
+
|
39
|
+
bundler-cache: true
|
40
|
+
- name: RuboCop
|
41
|
+
run: |
|
42
|
+
bundle exec rubocop
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,18 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
-
|
5
|
-
group :development do
|
6
|
-
gem 'rubocop', '~> 0.56'
|
7
|
-
end
|
1
|
+
# frozen_string_literal: true
|
8
2
|
|
9
|
-
|
10
|
-
gem 'pry'
|
11
|
-
end
|
3
|
+
source 'https://rubygems.org'
|
12
4
|
|
13
5
|
group :test do
|
14
|
-
gem '
|
15
|
-
gem 'simplecov', '~> 0.16', require: false
|
6
|
+
gem 'codecov', require: false
|
16
7
|
end
|
17
8
|
|
18
9
|
# Specify your gem's dependencies in revolut.gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2021 Justas Palumickas
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
10
10
|
furnished to do so, subject to the following conditions:
|
11
11
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
14
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
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
|
-
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
A Ruby gem which helps to communicate with [Revolut Business][revolut] API.
|
4
4
|
|
5
|
+
[![Gem Version](https://img.shields.io/gem/v/revolut.svg?style=flat-square)][rubygems]
|
6
|
+
[![Coverage Status](https://img.shields.io/codecov/c/github/jpalumickas/revolut-ruby?style=flat-square)][codecov]
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -52,14 +55,13 @@ Revolut.accounts
|
|
52
55
|
|
53
56
|
## Supported Ruby Versions
|
54
57
|
|
55
|
-
This library aims to support and is [tested against][
|
58
|
+
This library aims to support and is [tested against][github_actions] the following Ruby
|
56
59
|
implementations:
|
57
60
|
|
58
|
-
* Ruby 2.1.0
|
59
|
-
* Ruby 2.2.0
|
60
|
-
* Ruby 2.3.0
|
61
|
-
* Ruby 2.4.0
|
62
61
|
* Ruby 2.5.0
|
62
|
+
* Ruby 2.6.0
|
63
|
+
* Ruby 2.7.0
|
64
|
+
* Ruby 3.0.0
|
63
65
|
|
64
66
|
## Development
|
65
67
|
|
@@ -79,6 +81,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
79
81
|
|
80
82
|
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/jpalumickas/revolut-ruby/blob/master/CODE_OF_CONDUCT.md).
|
81
83
|
|
82
|
-
[
|
84
|
+
[rubygems]: https://rubygems.org/gems/revolut
|
85
|
+
[codecov]: https://codecov.io/gh/jpalumickas/revolut-ruby
|
86
|
+
[github_actions]: https://github.com/jpalumickas/revolut-ruby/actions
|
83
87
|
|
84
88
|
[revolut]: https://www.revolut.com
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'bundler/setup'
|
4
5
|
require 'revolut'
|
@@ -7,8 +8,8 @@ require 'revolut'
|
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
8
9
|
|
9
10
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
11
|
+
require 'pry'
|
12
|
+
Pry.start
|
12
13
|
|
13
|
-
require 'irb'
|
14
|
-
IRB.start(__FILE__)
|
14
|
+
# require 'irb'
|
15
|
+
# IRB.start(__FILE__)
|
data/lib/revolut.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'revolut/version'
|
2
4
|
require 'revolut/utils'
|
3
5
|
require 'revolut/error'
|
@@ -14,6 +16,7 @@ module Revolut
|
|
14
16
|
|
15
17
|
def method_missing(method_name, *args, &block)
|
16
18
|
return super unless client.respond_to?(method_name)
|
19
|
+
|
17
20
|
client.send(method_name, *args, &block)
|
18
21
|
end
|
19
22
|
|
data/lib/revolut/client.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'revolut/connection'
|
2
4
|
require 'revolut/configuration'
|
3
5
|
|
4
6
|
require 'revolut/clients/accounts'
|
5
7
|
require 'revolut/clients/counterparties'
|
8
|
+
require 'revolut/clients/exchanges'
|
9
|
+
require 'revolut/clients/payment_drafts'
|
10
|
+
require 'revolut/clients/payments'
|
6
11
|
require 'revolut/clients/webhooks'
|
7
12
|
|
8
13
|
module Revolut
|
@@ -10,6 +15,9 @@ module Revolut
|
|
10
15
|
class Client
|
11
16
|
include Revolut::Clients::Accounts
|
12
17
|
include Revolut::Clients::Counterparties
|
18
|
+
include Revolut::Clients::Exchanges
|
19
|
+
include Revolut::Clients::PaymentDrafts
|
20
|
+
include Revolut::Clients::Payments
|
13
21
|
include Revolut::Clients::Webhooks
|
14
22
|
|
15
23
|
# Initialize client.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Revolut
|
2
4
|
module Clients
|
3
5
|
# Revolut Accounts
|
@@ -13,15 +15,25 @@ module Revolut
|
|
13
15
|
|
14
16
|
# Get account information.
|
15
17
|
#
|
16
|
-
# @see
|
17
|
-
# https://revolutdev.github.io/business-api/?shell--sandbox#get-account
|
18
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#get-account
|
18
19
|
#
|
19
|
-
# @param id [
|
20
|
+
# @param id [UUID] Id of account.
|
20
21
|
#
|
21
22
|
# @return [Hash] Response from API.
|
22
23
|
def account(id)
|
23
24
|
connection.get("accounts/#{id}")
|
24
25
|
end
|
26
|
+
|
27
|
+
# Get account bank details.
|
28
|
+
#
|
29
|
+
# @see https://revolutdev.github.io/business-api/#get-account-details
|
30
|
+
#
|
31
|
+
# @param id [UUID] Id of account.
|
32
|
+
#
|
33
|
+
# @return [Hash] Response from API.
|
34
|
+
def account_details(id)
|
35
|
+
connection.get("accounts/#{id}/bank-details")
|
36
|
+
end
|
25
37
|
end
|
26
38
|
end
|
27
39
|
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Revolut
|
2
4
|
module Clients
|
3
5
|
# Revolut Accounts
|
4
6
|
module Counterparties
|
5
7
|
# List counterparties
|
6
8
|
#
|
7
|
-
# @see https://revolutdev.github.io/business-api/?shell--
|
9
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#get-counterparties
|
8
10
|
#
|
9
11
|
# @return [Hash] Response from API.
|
10
12
|
def counterparties
|
@@ -13,7 +15,9 @@ module Revolut
|
|
13
15
|
|
14
16
|
# Get Counterparty
|
15
17
|
#
|
16
|
-
# @see https://revolutdev.github.io/business-api/?shell--
|
18
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#get-counterparty
|
19
|
+
#
|
20
|
+
# @param id [UUID] Id of counterparty.
|
17
21
|
#
|
18
22
|
# @return [Hash] Response from API.
|
19
23
|
def counterparty(id)
|
@@ -22,7 +26,7 @@ module Revolut
|
|
22
26
|
|
23
27
|
# Add Revolut Counterparty
|
24
28
|
#
|
25
|
-
# @see https://revolutdev.github.io/business-api/?shell--
|
29
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#add-revolut-counterparty
|
26
30
|
#
|
27
31
|
# @return [Hash] Response from API.
|
28
32
|
def add_counterparty(params = {})
|
@@ -31,7 +35,9 @@ module Revolut
|
|
31
35
|
|
32
36
|
# Delete Counterparty
|
33
37
|
#
|
34
|
-
# @see https://revolutdev.github.io/business-api/?shell--
|
38
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#delete-counterparty
|
39
|
+
#
|
40
|
+
# @param id [UUID] Id of counterparty.
|
35
41
|
#
|
36
42
|
# @return [Hash] Response from API.
|
37
43
|
def delete_counterparty(id)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Revolut
|
4
|
+
module Clients
|
5
|
+
# Revolut Exchanges
|
6
|
+
module Exchanges
|
7
|
+
def exchange_rate(from:, to:, amount:)
|
8
|
+
connection.get('rate', from: from, to: to, amount: amount)
|
9
|
+
end
|
10
|
+
|
11
|
+
def exchange(params = {})
|
12
|
+
connection.post('exchange', params)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Revolut
|
4
|
+
module Clients
|
5
|
+
# Revolut Payment Drafts
|
6
|
+
module PaymentDrafts
|
7
|
+
# Get payment drafts
|
8
|
+
#
|
9
|
+
# @see https://revolutdev.github.io/business-api/#get-payment-drafts
|
10
|
+
#
|
11
|
+
# @return [Hash] Response from API.
|
12
|
+
def payment_drafts
|
13
|
+
connection.get('payment-drafts')
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get payment draft
|
17
|
+
#
|
18
|
+
# @see https://revolutdev.github.io/business-api/#get-payment-draft-by-id
|
19
|
+
#
|
20
|
+
# @param id [UUID] Id of transaction.
|
21
|
+
#
|
22
|
+
# @return [Hash] Response from API.
|
23
|
+
def payment_draft(id)
|
24
|
+
connection.get("payment-drafts/#{id}")
|
25
|
+
end
|
26
|
+
|
27
|
+
# Create payment draft
|
28
|
+
#
|
29
|
+
# @see https://revolutdev.github.io/business-api/#create-payment-draft
|
30
|
+
#
|
31
|
+
# @param params [Hash] A customizable set of params.
|
32
|
+
#
|
33
|
+
# @return [Hash] Response from API.
|
34
|
+
def create_payment_draft(params = {})
|
35
|
+
connection.post('payment-drafts', params)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Delete payment draft
|
39
|
+
#
|
40
|
+
# @see https://revolutdev.github.io/business-api/#delete-payment-draft
|
41
|
+
#
|
42
|
+
# @param id [UUID] Id of transaction.
|
43
|
+
#
|
44
|
+
# @return [Hash] Response from API.
|
45
|
+
def delete_payment_draft(id)
|
46
|
+
connection.delete("payment-drafts/#{id}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Revolut
|
4
|
+
module Clients
|
5
|
+
# Revolut Payments
|
6
|
+
module Payments
|
7
|
+
# Transfer payment
|
8
|
+
#
|
9
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#transfer
|
10
|
+
#
|
11
|
+
# @param params [Hash] A customizable set of params.
|
12
|
+
#
|
13
|
+
# @return [Hash] Response from API.
|
14
|
+
def transfer(params = {})
|
15
|
+
connection.post('transfer', params)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Create payment
|
19
|
+
#
|
20
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#create-payment
|
21
|
+
#
|
22
|
+
# @param params [Hash] A customizable set of params.
|
23
|
+
#
|
24
|
+
# @return [Hash] Response from API.
|
25
|
+
def pay(params = {})
|
26
|
+
connection.post('pay', params)
|
27
|
+
end
|
28
|
+
|
29
|
+
# List transactions
|
30
|
+
#
|
31
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#get-transactions
|
32
|
+
#
|
33
|
+
# @return [Hash] Response from API.
|
34
|
+
def transactions
|
35
|
+
connection.get('transactions')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Get transaction
|
39
|
+
#
|
40
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#check-payment-status
|
41
|
+
#
|
42
|
+
# @param id [UUID] Id of transaction.
|
43
|
+
#
|
44
|
+
# @return [Hash] Response from API.
|
45
|
+
def transaction(id, params = {})
|
46
|
+
connection.get("transaction/#{id}", params)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Cancel transaction
|
50
|
+
#
|
51
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#cancel-payment
|
52
|
+
#
|
53
|
+
# @param id [UUID] Id of transaction.
|
54
|
+
#
|
55
|
+
# @return [Hash] Response from API.
|
56
|
+
def cancel_transaction(id)
|
57
|
+
connection.delete("transaction/#{id}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,10 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Revolut
|
2
4
|
module Clients
|
3
5
|
# Revolut Webhooks
|
4
6
|
module Webhooks
|
5
7
|
# Create webhook
|
6
8
|
#
|
7
|
-
# @see https://revolutdev.github.io/business-api/?shell--
|
9
|
+
# @see https://revolutdev.github.io/business-api/?shell--production#setting-up-a-web-hook
|
10
|
+
#
|
11
|
+
# @param params [Hash] A customizable set of params.
|
12
|
+
# @option params [String] :url Call back endpoint of the client system,
|
13
|
+
# https is the supported protocol.
|
8
14
|
#
|
9
15
|
# @return [Hash] Response from API.
|
10
16
|
def create_webhook(params = {})
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Revolut
|
2
4
|
# A class responsible for all configurations.
|
3
5
|
class Configuration
|
4
|
-
PRODUCTION_API_ENDPOINT = 'https://b2b.revolut.com/api/1.0'
|
5
|
-
SANDBOX_API_ENDPOINT = 'https://sandbox-b2b.revolut.com/api/1.0'
|
6
|
+
PRODUCTION_API_ENDPOINT = 'https://b2b.revolut.com/api/1.0'
|
7
|
+
SANDBOX_API_ENDPOINT = 'https://sandbox-b2b.revolut.com/api/1.0'
|
6
8
|
AVAILABLE_ENVIRONMENTS = %i[production sandbox].freeze
|
7
9
|
DEFAULT_ENVIRONMENT = :production
|
8
|
-
USER_AGENT = "Revolut Ruby v#{Revolut::VERSION}"
|
10
|
+
USER_AGENT = "Revolut Ruby v#{Revolut::VERSION}"
|
9
11
|
|
10
12
|
attr_accessor :api_key
|
11
13
|
attr_writer :url, :user_agent
|
@@ -16,9 +18,10 @@ module Revolut
|
|
16
18
|
def url
|
17
19
|
return @url if @url
|
18
20
|
|
19
|
-
|
21
|
+
case environment
|
22
|
+
when :production
|
20
23
|
PRODUCTION_API_ENDPOINT
|
21
|
-
|
24
|
+
when :sandbox
|
22
25
|
SANDBOX_API_ENDPOINT
|
23
26
|
end
|
24
27
|
end
|
@@ -44,9 +47,7 @@ module Revolut
|
|
44
47
|
def environment=(environment)
|
45
48
|
env_sym = environment.is_a?(String) ? environment.to_sym : environment
|
46
49
|
|
47
|
-
unless AVAILABLE_ENVIRONMENTS.include?(env_sym)
|
48
|
-
raise Revolut::Error, 'Invalid environment provided.'
|
49
|
-
end
|
50
|
+
raise Revolut::Error, 'Invalid environment provided.' unless AVAILABLE_ENVIRONMENTS.include?(env_sym)
|
50
51
|
|
51
52
|
@environment = env_sym
|
52
53
|
end
|
data/lib/revolut/connection.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'faraday_middleware'
|
3
5
|
require 'json'
|
@@ -29,41 +31,40 @@ module Revolut
|
|
29
31
|
private
|
30
32
|
|
31
33
|
def request(method, path, query_params = {}, body_params = {})
|
32
|
-
|
34
|
+
connection.send(method) do |request|
|
33
35
|
request.url(path, query_params)
|
34
|
-
request
|
35
|
-
|
36
|
-
if client.config.api_key
|
37
|
-
request.headers['Authorization'] = "Bearer #{client.config.api_key}"
|
38
|
-
end
|
36
|
+
add_request_headers!(request)
|
39
37
|
|
40
|
-
request.body = body_params.to_json
|
38
|
+
request.body = body_params.to_json if Revolut::Utils.present?(body_params)
|
41
39
|
end
|
42
|
-
|
43
|
-
response
|
44
40
|
end
|
45
41
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
url: client.config.url,
|
50
|
-
builder: middleware
|
51
|
-
}
|
42
|
+
def add_request_headers!(request)
|
43
|
+
request.headers['Content-Type'] = 'application/json'
|
44
|
+
request.headers['Accept'] = 'application/json'
|
52
45
|
|
53
|
-
|
46
|
+
return unless client.config.api_key
|
47
|
+
|
48
|
+
request.headers['Authorization'] = "Bearer #{client.config.api_key}"
|
54
49
|
end
|
55
50
|
|
56
|
-
def
|
57
|
-
|
51
|
+
def connection
|
52
|
+
Faraday.new(connection_options) do |builder|
|
58
53
|
builder.request :json
|
59
54
|
|
60
|
-
builder.
|
61
|
-
builder.use FaradayMiddleware::Mashify, mash_class: Revolut::Mash
|
55
|
+
builder.response :mashify, mash_class: Revolut::Mash
|
62
56
|
builder.use Revolut::Middleware::RaiseError
|
63
|
-
builder.
|
57
|
+
builder.response :json
|
64
58
|
|
65
59
|
builder.adapter Faraday.default_adapter
|
66
60
|
end
|
67
61
|
end
|
62
|
+
|
63
|
+
def connection_options
|
64
|
+
{
|
65
|
+
headers: { user_agent: client.config.user_agent },
|
66
|
+
url: client.config.url
|
67
|
+
}
|
68
|
+
end
|
68
69
|
end
|
69
70
|
end
|
data/lib/revolut/error.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Revolut
|
2
4
|
# Base Revolut error.
|
3
5
|
class Error < StandardError
|
4
6
|
def initialize(msg = nil)
|
7
|
+
super(msg)
|
5
8
|
@message = msg
|
6
9
|
end
|
7
10
|
|
@@ -21,7 +24,7 @@ module Revolut
|
|
21
24
|
message = error_message(response)
|
22
25
|
|
23
26
|
klass = error_class(status)
|
24
|
-
klass
|
27
|
+
klass&.new(message)
|
25
28
|
end
|
26
29
|
|
27
30
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
@@ -47,8 +50,10 @@ module Revolut
|
|
47
50
|
# @return [String] Revolut error message.
|
48
51
|
def self.error_message(response)
|
49
52
|
return unless response.body.is_a?(Hash)
|
53
|
+
|
50
54
|
message = response.body['message']
|
51
55
|
return unless message
|
56
|
+
|
52
57
|
Revolut::Utils.presence(message)
|
53
58
|
end
|
54
59
|
end
|
data/lib/revolut/mash.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Revolut
|
2
4
|
# Faraday response middleware
|
3
5
|
module Middleware
|
4
6
|
# This class raises an exception based HTTP status codes returned
|
5
7
|
# by the API.
|
6
8
|
class RaiseError < Faraday::Response::Middleware
|
7
|
-
private
|
8
|
-
|
9
9
|
def on_complete(response)
|
10
10
|
error = Revolut::Error.from_response(response)
|
11
11
|
raise error if error
|
data/lib/revolut/utils.rb
CHANGED
data/lib/revolut/version.rb
CHANGED
data/revolut.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'revolut/version'
|
@@ -17,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
17
19
|
spec.metadata = {
|
18
20
|
'bug_tracker_uri' => "#{github_repo_url}/issues",
|
19
21
|
'source_code_uri' => "#{github_repo_url}/tree/v#{Revolut::VERSION}",
|
20
|
-
'changelog_uri'
|
22
|
+
'changelog_uri' => "#{github_repo_url}/releases/tag/v#{Revolut::VERSION}"
|
21
23
|
}
|
22
24
|
|
23
25
|
# Specify which files should be added to the gem when it is released.
|
@@ -31,13 +33,17 @@ Gem::Specification.new do |spec|
|
|
31
33
|
spec.bindir = 'exe'
|
32
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
35
|
spec.require_paths = ['lib']
|
36
|
+
spec.required_ruby_version = '>= 2.5.0'
|
34
37
|
|
35
|
-
spec.add_dependency 'faraday', '~>
|
36
|
-
spec.add_dependency 'faraday_middleware', '~> 0
|
37
|
-
spec.add_dependency 'hashie', '~>
|
38
|
+
spec.add_dependency 'faraday', '~> 1.1'
|
39
|
+
spec.add_dependency 'faraday_middleware', '~> 1.0'
|
40
|
+
spec.add_dependency 'hashie', '~> 4.0'
|
38
41
|
|
39
|
-
spec.add_development_dependency 'bundler', '~>
|
40
|
-
spec.add_development_dependency '
|
41
|
-
spec.add_development_dependency '
|
42
|
-
spec.add_development_dependency '
|
42
|
+
spec.add_development_dependency 'bundler', '~> 2.2'
|
43
|
+
spec.add_development_dependency 'pry', '~> 0.13'
|
44
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
45
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
46
|
+
spec.add_development_dependency 'rubocop', '~> 1.8'
|
47
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
48
|
+
spec.add_development_dependency 'webmock', '~> 3.11'
|
43
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revolut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justas Palumickas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,98 +16,140 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday_middleware
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hashie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '4.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '4.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.2'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.13'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '13.0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '13.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rspec
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
103
|
+
version: '3.10'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.10'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.8'
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
122
|
- - "~>"
|
95
123
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
124
|
+
version: '1.8'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.21'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.21'
|
97
139
|
- !ruby/object:Gem::Dependency
|
98
140
|
name: webmock
|
99
141
|
requirement: !ruby/object:Gem::Requirement
|
100
142
|
requirements:
|
101
143
|
- - "~>"
|
102
144
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
145
|
+
version: '3.11'
|
104
146
|
type: :development
|
105
147
|
prerelease: false
|
106
148
|
version_requirements: !ruby/object:Gem::Requirement
|
107
149
|
requirements:
|
108
150
|
- - "~>"
|
109
151
|
- !ruby/object:Gem::Version
|
110
|
-
version: '3.
|
152
|
+
version: '3.11'
|
111
153
|
description: Ruby gem for Revolut API
|
112
154
|
email:
|
113
155
|
- jpalumickas@gmail.com
|
@@ -115,10 +157,10 @@ executables: []
|
|
115
157
|
extensions: []
|
116
158
|
extra_rdoc_files: []
|
117
159
|
files:
|
160
|
+
- ".github/workflows/test.yml"
|
118
161
|
- ".gitignore"
|
119
162
|
- ".rspec"
|
120
163
|
- ".rubocop.yml"
|
121
|
-
- ".travis.yml"
|
122
164
|
- CODE_OF_CONDUCT.md
|
123
165
|
- Gemfile
|
124
166
|
- LICENSE.txt
|
@@ -130,6 +172,9 @@ files:
|
|
130
172
|
- lib/revolut/client.rb
|
131
173
|
- lib/revolut/clients/accounts.rb
|
132
174
|
- lib/revolut/clients/counterparties.rb
|
175
|
+
- lib/revolut/clients/exchanges.rb
|
176
|
+
- lib/revolut/clients/payment_drafts.rb
|
177
|
+
- lib/revolut/clients/payments.rb
|
133
178
|
- lib/revolut/clients/webhooks.rb
|
134
179
|
- lib/revolut/configuration.rb
|
135
180
|
- lib/revolut/connection.rb
|
@@ -144,9 +189,9 @@ licenses:
|
|
144
189
|
- MIT
|
145
190
|
metadata:
|
146
191
|
bug_tracker_uri: https://github.com/jpalumickas/revolut-ruby/issues
|
147
|
-
source_code_uri: https://github.com/jpalumickas/revolut-ruby/tree/
|
148
|
-
changelog_uri: https://github.com/jpalumickas/revolut-ruby/releases/tag/
|
149
|
-
post_install_message:
|
192
|
+
source_code_uri: https://github.com/jpalumickas/revolut-ruby/tree/v1.3.0
|
193
|
+
changelog_uri: https://github.com/jpalumickas/revolut-ruby/releases/tag/v1.3.0
|
194
|
+
post_install_message:
|
150
195
|
rdoc_options: []
|
151
196
|
require_paths:
|
152
197
|
- lib
|
@@ -154,16 +199,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
199
|
requirements:
|
155
200
|
- - ">="
|
156
201
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
202
|
+
version: 2.5.0
|
158
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
204
|
requirements:
|
160
205
|
- - ">="
|
161
206
|
- !ruby/object:Gem::Version
|
162
207
|
version: '0'
|
163
208
|
requirements: []
|
164
|
-
|
165
|
-
|
166
|
-
signing_key:
|
209
|
+
rubygems_version: 3.2.5
|
210
|
+
signing_key:
|
167
211
|
specification_version: 4
|
168
212
|
summary: Ruby wrapper for Revolut API
|
169
213
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
|
3
|
-
cache:
|
4
|
-
bundler: true
|
5
|
-
|
6
|
-
env:
|
7
|
-
global:
|
8
|
-
- CC_TEST_REPORTER_ID=f86c6bdee47c51e643c1359af6752ac4d85084f5c484733b596f5f9572a91b93
|
9
|
-
|
10
|
-
language: ruby
|
11
|
-
rvm:
|
12
|
-
- 2.1.0
|
13
|
-
- 2.2.0
|
14
|
-
- 2.3.0
|
15
|
-
- 2.4.0
|
16
|
-
- 2.5.0
|
17
|
-
- ruby-head
|
18
|
-
|
19
|
-
before_install:
|
20
|
-
- gem install bundler -v 1.16.2
|
21
|
-
- gem update --system
|
22
|
-
|
23
|
-
before_script:
|
24
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
25
|
-
- chmod +x ./cc-test-reporter
|
26
|
-
- ./cc-test-reporter before-build
|
27
|
-
|
28
|
-
script:
|
29
|
-
- bundle exec rspec
|
30
|
-
|
31
|
-
after_script:
|
32
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
33
|
-
|
34
|
-
matrix:
|
35
|
-
allow_failures:
|
36
|
-
- rvm: ruby-head
|