revolut-connect 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b08af3f8efdfcf2b02fce80fce21004a59b416ee3915c78e1747791878129a3
4
- data.tar.gz: b84ccc92e6ee0605242a3f729ab18b0ed1fce145dd4d232b3e4d36e5dff51df3
3
+ metadata.gz: 3c3fcb46e2423e47f2597ae155daa4e0f86f0a861c4a862c04b7ca8e8064378d
4
+ data.tar.gz: aabf68cbbccf5c8e5e6c14bfb6ad329c45251e3621b0fc5c0f53373d3cf5e8ab
5
5
  SHA512:
6
- metadata.gz: 73771ea0352ef2cf70b509c24ff84e536bd77058fe208097da4fe3277657d129350e08753077348a6b43d809426b7d39d5c80aa3f5a9fa1daee7e31e7e031ea9
7
- data.tar.gz: 225d751bebc87dafb3920bc8a4d613a926f771cc7ab0a264323919e642a4ff693e9e1171a0332a4d69e3f351e935e4640b404ed609fec71467f970d5f4d56cca
6
+ metadata.gz: 9687a994b4e4944c2f1148ddbd0d0a064655bbaf0534e230ff5367508f7a77cbe00f57dde98fa7a09811678448b4d1d4b03ca5a7a00874f8ec2ca52ee0d54bc8
7
+ data.tar.gz: fe4531d59a808adb461487693b146207ab5f54b254e2a07d1447448203cfba2cec9f19c06182aab41e36ce050951720f9548659c141b3306e17b0a1687f15a4c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- revolut-connect (0.1.2)
4
+ revolut-connect (0.1.3)
5
5
  faraday (>= 1)
6
6
  faraday-retry (>= 1)
7
7
  jwt (>= 1)
data/README.md CHANGED
@@ -156,6 +156,10 @@ Revolut.configure do |config|
156
156
  # Optional: Set the environment to be production or sandbox.
157
157
  # Default: sandbox
158
158
  config.environment = ENV["REVOLUT_ENVIRONMENT"]
159
+
160
+ # Optional: The JWT for an already exchanged token.
161
+ # Used to preload an existing auth token so that you don't have to exchange / renew it again.
162
+ config.auth_json = ENV["REVOLUT_AUTH_JSON"]
159
163
  end
160
164
  ```
161
165
 
@@ -229,6 +233,8 @@ deleted = Revolut::Payment.delete(transaction.id)
229
233
 
230
234
  ## Development
231
235
 
236
+ You can use `bin/console` to access an interactive console. This will preload environment variables from a `.env` file.
237
+
232
238
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
233
239
 
234
240
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
@@ -105,17 +105,17 @@ module Revolut
105
105
  !@access_token.nil? && !expired?
106
106
  end
107
107
 
108
- # Loads authentication information from environment variable REVOLUT_AUTH_JSON.
108
+ # Loads authentication information from the configuration auth_json.
109
109
  #
110
- # If the access token is not already set and the environment variable REVOLUT_AUTH_JSON is present,
111
- # this method loads the JSON data from the environment variable and calls the load method to set the authentication information.
110
+ # If the access token is not already set and auth_json config is present,
111
+ # this method loads the JSON data from the config variable and calls the load method to set the authentication information.
112
112
  #
113
113
  # Example:
114
114
  # auth.load_from_env
115
115
  #
116
116
  # @return [void]
117
117
  def load_from_env
118
- env_json = ENV["REVOLUT_AUTH_JSON"]
118
+ env_json = Revolut.config.auth_json
119
119
 
120
120
  return unless @access_token.nil? && env_json
121
121
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Revolut
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/revolut.rb CHANGED
@@ -10,9 +10,6 @@ require_relative "revolut/client"
10
10
  require_relative "revolut/resources/resource"
11
11
  Dir[File.join(__dir__, "revolut", "resources", "*.rb")].each { |file| require file }
12
12
 
13
- # Load the authentication information from the environment variable REVOLUT_AUTH_JSON right away if possible.
14
- Revolut::Auth.load_from_env
15
-
16
13
  module Revolut
17
14
  class Error < StandardError; end
18
15
 
@@ -21,7 +18,7 @@ module Revolut
21
18
  class NotImplementedError < Error; end
22
19
 
23
20
  class Configuration
24
- attr_accessor :request_timeout, :global_headers, :environment, :token_duration, :scope
21
+ attr_accessor :request_timeout, :global_headers, :environment, :token_duration, :scope, :auth_json
25
22
  attr_writer :client_id, :signing_key, :iss, :authorize_redirect_uri
26
23
  attr_reader :base_uri
27
24
 
@@ -38,6 +35,7 @@ module Revolut
38
35
  @iss = ENV.fetch("REVOLUT_ISS", "example.com")
39
36
  @authorize_redirect_uri = ENV["REVOLUT_AUTHORIZE_REDIRECT_URI"]
40
37
  @token_duration = ENV.fetch("REVOLUT_TOKEN_DURATION", DEFAULT_TOKEN_DURATION)
38
+ @auth_json = ENV["REVOLUT_AUTH_JSON"]
41
39
  @scope = ENV["REVOLUT_SCOPE"]
42
40
  @environment = ENV.fetch("REVOLUT_ENVIRONMENT", DEFAULT_ENVIRONMENT).to_sym
43
41
  @base_uri = (environment == :sandbox) ? "https://sandbox-b2b.revolut.com/api/1.0/" : "https://b2b.revolut.com/api/1.0/"
@@ -80,3 +78,6 @@ module Revolut
80
78
  end
81
79
  end
82
80
  end
81
+
82
+ # Load the authentication information from the environment variable REVOLUT_AUTH_JSON right away if possible.
83
+ Revolut::Auth.load_from_env
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revolut-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Mochetti