revolut 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -0
- data/README.md +1 -1
- data/lib/revolut/configuration.rb +21 -5
- data/lib/revolut/error.rb +9 -1
- data/lib/revolut/mash.rb +1 -0
- data/lib/revolut/utils.rb +1 -0
- data/lib/revolut/version.rb +1 -1
- data/revolut.gemspec +5 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 106c28ec334b2566b903580960a0ce3bfd11dc0449871bdf8b02179176bdfe34
|
4
|
+
data.tar.gz: 3f17e74ee206acf23be60719fbd1d4ab557a74a04312bac584d3feb2aedfedc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e21d338e64c34f8f912607d09708321142a0e74dab07c0c1ae1a99fcb5b9dfe58659b1d10cbf29959899c028dc1a6362c9cc2bac16055c8445a0c3b1793ecf8
|
7
|
+
data.tar.gz: 9950762ef3e995da0df938e31f576462a07739674233f1722d1630b3fa739cd02cd938c634b0a0e5cf31303a129aa75d22589f41c55f7d070d4f5dc66157eaa7
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
module Revolut
|
2
2
|
# A class responsible for all configurations.
|
3
3
|
class Configuration
|
4
|
-
# Default API endpoint.
|
5
4
|
PRODUCTION_API_ENDPOINT = 'https://b2b.revolut.com/api/1.0'.freeze
|
6
5
|
SANDBOX_API_ENDPOINT = 'https://sandbox-b2b.revolut.com/api/1.0'.freeze
|
7
|
-
|
8
|
-
|
6
|
+
AVAILABLE_ENVIRONMENTS = %i[production sandbox].freeze
|
7
|
+
DEFAULT_ENVIRONMENT = :production
|
9
8
|
USER_AGENT = "Revolut Ruby v#{Revolut::VERSION}".freeze
|
10
9
|
|
11
10
|
attr_accessor :api_key
|
12
|
-
attr_writer :url, :user_agent
|
11
|
+
attr_writer :url, :user_agent
|
13
12
|
|
14
13
|
# Takes url provided from configuration or uses default one.
|
15
14
|
#
|
@@ -31,8 +30,25 @@ module Revolut
|
|
31
30
|
@user_agent || USER_AGENT
|
32
31
|
end
|
33
32
|
|
33
|
+
# Takes environment from configuration or uses default one.
|
34
|
+
# It will be used to set url automatically.
|
35
|
+
#
|
36
|
+
# @return [Symbol] Environment which will be used to set url.
|
34
37
|
def environment
|
35
|
-
@environment ||
|
38
|
+
@environment || DEFAULT_ENVIRONMENT
|
39
|
+
end
|
40
|
+
|
41
|
+
# Sets environment which will be used for url.
|
42
|
+
#
|
43
|
+
# @return [Symbol] Environment which will be used to set url.
|
44
|
+
def environment=(environment)
|
45
|
+
env_sym = environment.is_a?(String) ? environment.to_sym : environment
|
46
|
+
|
47
|
+
unless AVAILABLE_ENVIRONMENTS.include?(env_sym)
|
48
|
+
raise Revolut::Error, 'Invalid environment provided.'
|
49
|
+
end
|
50
|
+
|
51
|
+
@environment = env_sym
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|
data/lib/revolut/error.rb
CHANGED
@@ -5,6 +5,11 @@ module Revolut
|
|
5
5
|
@message = msg
|
6
6
|
end
|
7
7
|
|
8
|
+
# Default error message.
|
9
|
+
def to_s
|
10
|
+
@message || super
|
11
|
+
end
|
12
|
+
|
8
13
|
# Returns the appropriate Revolut::Error sublcass based on status and
|
9
14
|
# response message.
|
10
15
|
#
|
@@ -19,6 +24,7 @@ module Revolut
|
|
19
24
|
klass.new(message) if klass
|
20
25
|
end
|
21
26
|
|
27
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
22
28
|
def self.error_class(status)
|
23
29
|
case status
|
24
30
|
when 400 then Revolut::BadRequest
|
@@ -32,6 +38,7 @@ module Revolut
|
|
32
38
|
when 503 then Revolut::ServiceUnavailable
|
33
39
|
end
|
34
40
|
end
|
41
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/MethodLength
|
35
42
|
|
36
43
|
# Returns the appropriate Revolut error message based on response
|
37
44
|
#
|
@@ -114,7 +121,8 @@ module Revolut
|
|
114
121
|
class ServiceUnavailable < Error
|
115
122
|
# Default error message.
|
116
123
|
def to_s
|
117
|
-
@message ||
|
124
|
+
@message ||
|
125
|
+
"We're temporarily offline for maintenance. Please try again later."
|
118
126
|
end
|
119
127
|
end
|
120
128
|
end
|
data/lib/revolut/mash.rb
CHANGED
data/lib/revolut/utils.rb
CHANGED
data/lib/revolut/version.rb
CHANGED
data/revolut.gemspec
CHANGED
@@ -2,6 +2,8 @@ lib = File.expand_path('lib', __dir__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'revolut/version'
|
4
4
|
|
5
|
+
github_repo_url = 'https://github.com/jpalumickas/revolut-ruby'
|
6
|
+
|
5
7
|
Gem::Specification.new do |spec|
|
6
8
|
spec.name = 'revolut'
|
7
9
|
spec.version = Revolut::VERSION
|
@@ -13,9 +15,9 @@ Gem::Specification.new do |spec|
|
|
13
15
|
spec.homepage = 'https://github.com/jpalumickas/revolut-ruby'
|
14
16
|
spec.license = 'MIT'
|
15
17
|
spec.metadata = {
|
16
|
-
'bug_tracker_uri' =>
|
17
|
-
'source_code_uri' => "
|
18
|
-
'changelog_uri' => "
|
18
|
+
'bug_tracker_uri' => "#{github_repo_url}/issues",
|
19
|
+
'source_code_uri' => "#{github_repo_url}/tree/v#{Revolut::VERSION}",
|
20
|
+
'changelog_uri' => "#{github_repo_url}/releases/tag/v#{Revolut::VERSION}"
|
19
21
|
}
|
20
22
|
|
21
23
|
# Specify which files should be added to the gem when it is released.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revolut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justas Palumickas
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
119
|
- ".rspec"
|
120
|
+
- ".rubocop.yml"
|
120
121
|
- ".travis.yml"
|
121
122
|
- CODE_OF_CONDUCT.md
|
122
123
|
- Gemfile
|
@@ -143,8 +144,8 @@ licenses:
|
|
143
144
|
- MIT
|
144
145
|
metadata:
|
145
146
|
bug_tracker_uri: https://github.com/jpalumickas/revolut-ruby/issues
|
146
|
-
source_code_uri: https://github.com/jpalumickas/revolut-ruby/tree/v0.2.
|
147
|
-
changelog_uri: https://github.com/jpalumickas/revolut-ruby/releases/tag/v0.2.
|
147
|
+
source_code_uri: https://github.com/jpalumickas/revolut-ruby/tree/v0.2.1
|
148
|
+
changelog_uri: https://github.com/jpalumickas/revolut-ruby/releases/tag/v0.2.1
|
148
149
|
post_install_message:
|
149
150
|
rdoc_options: []
|
150
151
|
require_paths:
|