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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b9657e59d398bee91251de918c472f74dd2aea52151166a668edfcacf5f9cad
4
- data.tar.gz: 3b1c166bf2a570fccf8243999c66cf8f5293b6b50367089ebba92e2836b2b0e7
3
+ metadata.gz: 106c28ec334b2566b903580960a0ce3bfd11dc0449871bdf8b02179176bdfe34
4
+ data.tar.gz: 3f17e74ee206acf23be60719fbd1d4ab557a74a04312bac584d3feb2aedfedc1
5
5
  SHA512:
6
- metadata.gz: a366caacfcd613d84be4ce92d5003f9d236ce83254d0fdd9ee61b44926e0f8de4fb590ed64cc27f3ef68a38c6ac5b46e692ab5b0ececbb35188d1f0f12199625
7
- data.tar.gz: 27e73e91527b52b1f2232e434cca58a72d911aac80954a4224bf4204019856151c3c6096bcf2ce472c8d33c9fc71dc35182bddefc3323940a2b27b3586effad2
6
+ metadata.gz: 7e21d338e64c34f8f912607d09708321142a0e74dab07c0c1ae1a99fcb5b9dfe58659b1d10cbf29959899c028dc1a6362c9cc2bac16055c8445a0c3b1793ecf8
7
+ data.tar.gz: 9950762ef3e995da0df938e31f576462a07739674233f1722d1630b3fa739cd02cd938c634b0a0e5cf31303a129aa75d22589f41c55f7d070d4f5dc66157eaa7
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.1
3
+
4
+ Style/DoubleNegation:
5
+ Exclude:
6
+ - 'lib/revolut/utils.rb'
7
+
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - 'spec/**/*_spec.rb'
11
+ - 'revolut.gemspec'
data/README.md CHANGED
@@ -37,7 +37,7 @@ Or create file under `config/initializers/revolut.rb`
37
37
  ```ruby
38
38
  Revolut.configure do |config|
39
39
  config.api_key = 'my-secret-api-key'
40
- config.environment = :sandbox # Or :production
40
+ config.environment = :sandbox # :production
41
41
  end
42
42
  ```
43
43
 
@@ -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
- # Default User Agent header string.
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, :environment
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 || :production
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
@@ -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 || "We're temporarily offline for maintenance. Please try again later."
124
+ @message ||
125
+ "We're temporarily offline for maintenance. Please try again later."
118
126
  end
119
127
  end
120
128
  end
@@ -1,6 +1,7 @@
1
1
  require 'hashie/mash'
2
2
 
3
3
  module Revolut
4
+ # Custom Mash class with disabled warnings.
4
5
  class Mash < Hashie::Mash
5
6
  disable_warnings
6
7
  end
@@ -1,4 +1,5 @@
1
1
  module Revolut
2
+ # Custom utilities
2
3
  module Utils
3
4
  BLANK_RE = /\A[[:space:]]*\z/
4
5
 
@@ -1,3 +1,3 @@
1
1
  module Revolut
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
@@ -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' => 'https://github.com/jpalumickas/revolut-ruby/issues',
17
- 'source_code_uri' => "https://github.com/jpalumickas/revolut-ruby/tree/v#{Revolut::VERSION}",
18
- 'changelog_uri' => "https://github.com/jpalumickas/revolut-ruby/releases/tag/v#{Revolut::VERSION}"
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.0
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.0
147
- changelog_uri: https://github.com/jpalumickas/revolut-ruby/releases/tag/v0.2.0
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: