stone-ruby 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 633888b0d27b8ce4ccaffb787889afd713d47a5b
4
- data.tar.gz: 5bc15e895db5941481d56ef3c80dcddd5a69e74d
3
+ metadata.gz: a23a63fbdc1bb1433367f370c063a0d28cfdc52c
4
+ data.tar.gz: 204650e096bde9af4068afde6f655d2195500156
5
5
  SHA512:
6
- metadata.gz: 7ede62e66ad0bc5a22ac12a34bdc35155a92dd3dbfaa6ca56fcc6445c07095ff9ab6f4262b17838bd1115f41e3d019ccda132d2a7adff23c2701145073aa44f9
7
- data.tar.gz: c972ba5b05ddbc0e6b6a16dacdd2d1b14819427c297c318f26ea250c9e5627fe69a04c155c3cd13f8c1e4e1f2c048200aeeb63ce77bff349ee6659bde778e9e6
6
+ metadata.gz: 3e85a013d4e0c3bac241c7198a7806ad1d92483ecddd079e0e9c74d117566dbd9de6749e72df2ac15428eeb3c8e36d711b35cf5f568b473f850fd3692570b2ff
7
+ data.tar.gz: 1fe3e4abb1aaf457a838caf58d89b884cf7be6bc8dd7d38c26039efaf65f2810a981fd6774db9e67fd72839ca219b850191bffea27ee18f6bc2919796441bc6a
data/.DS_Store CHANGED
Binary file
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .idea
13
+ .DS_Store
@@ -13,17 +13,11 @@
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
14
  <orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.3, asdf: 2.3.1) [gem]" level="application" />
15
15
  <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.6, asdf: 2.3.1) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, asdf: 2.3.1) [gem]" level="application" />
17
16
  <orderEntry type="library" scope="PROVIDED" name="dry-configurable (v0.8.3, asdf: 2.3.1) [gem]" level="application" />
18
17
  <orderEntry type="library" scope="PROVIDED" name="dry-core (v0.4.9, asdf: 2.3.1) [gem]" level="application" />
19
18
  <orderEntry type="library" scope="PROVIDED" name="ethon (v0.12.0, asdf: 2.3.1) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="ffi (v1.13.1, asdf: 2.3.1) [gem]" level="application" />
21
19
  <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, asdf: 2.3.1) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, asdf: 2.3.1) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.2, asdf: 2.3.1) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.2, asdf: 2.3.1) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, asdf: 2.3.1) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.3, asdf: 2.3.1) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.3.0, asdf: 2.3.1) [gem]" level="application" />
27
21
  <orderEntry type="library" scope="PROVIDED" name="typhoeus (v1.0.2, asdf: 2.3.1) [gem]" level="application" />
28
22
  </component>
29
23
  </module>
data/Gemfile.lock CHANGED
@@ -3,12 +3,13 @@ PATH
3
3
  specs:
4
4
  stone-ruby (0.0.1)
5
5
  dry-configurable (~> 0.8.3)
6
+ request_store_rails (~> 2.0.0)
6
7
  typhoeus (~> 1.0.2)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- concurrent-ruby (1.1.6)
12
+ concurrent-ruby (1.1.8)
12
13
  diff-lcs (1.3)
13
14
  dry-configurable (0.8.3)
14
15
  concurrent-ruby (~> 1.0)
@@ -17,8 +18,10 @@ GEM
17
18
  concurrent-ruby (~> 1.0)
18
19
  ethon (0.12.0)
19
20
  ffi (>= 1.3.0)
20
- ffi (1.13.1)
21
+ ffi (1.14.2)
21
22
  rake (10.5.0)
23
+ request_store_rails (2.0.0)
24
+ concurrent-ruby (~> 1.0)
22
25
  rspec (3.9.0)
23
26
  rspec-core (~> 3.9.0)
24
27
  rspec-expectations (~> 3.9.0)
@@ -1,6 +1,8 @@
1
1
  module Stone::Siclos
2
2
  module Client
3
3
 
4
+ TOKEN_KEY = :siclos_token
5
+
4
6
  autoload :Token, 'stone/siclos/client/token'
5
7
  autoload :Establishment, 'stone/siclos/client/establishment'
6
8
  autoload :Recipient, 'stone/siclos/client/recipient'
@@ -15,7 +17,6 @@ module Stone::Siclos
15
17
  class Response
16
18
  def initialize(code, data)
17
19
  @code = code
18
- ap data
19
20
  @data = JSON.parse(data, symbolize_names: true)
20
21
  raise_exception unless @data[:success]
21
22
  end
@@ -36,8 +37,8 @@ module Stone::Siclos
36
37
 
37
38
  class Base
38
39
 
39
- def initialize
40
- @token = Stone.config.siclos.api_key
40
+ def initialize(_token = Stone.config.siclos.api_key)
41
+ @token = RequestLocals.store[TOKEN_KEY] || _token
41
42
  end
42
43
 
43
44
  def parse_endpoint(path)
@@ -104,19 +105,24 @@ module Stone::Siclos
104
105
  end
105
106
 
106
107
  def with_token
107
- cached_token = Stone.config.siclos.api_key
108
+ clear_token
108
109
  authentication_token = token.token
109
110
 
110
111
  if authentication_token.success?
111
- Stone.config.siclos.api_key = authentication_token.data[:token]
112
+ RequestLocals.store[TOKEN_KEY] = authentication_token.data[:token]
112
113
  result = yield(self)
113
- Stone.config.siclos.api_key = cached_token
114
114
  result
115
115
  else
116
116
  raise Stone::Siclos::Error::TokenError, authentication_token.data[:msg]
117
117
  end
118
118
  ensure
119
- Stone.config.siclos.api_key = cached_token
119
+ clear_token
120
+ end
121
+
122
+ private
123
+
124
+ def clear_token
125
+ RequestLocals.store[TOKEN_KEY] = nil
120
126
  end
121
127
  end
122
128
  end
data/lib/stone/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stone
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/stone-ruby.gemspec CHANGED
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
38
38
 
39
39
  spec.add_dependency 'dry-configurable', '~> 0.8.3'
40
40
  spec.add_dependency 'typhoeus', '~> 1.0.2'
41
+ spec.add_dependency 'request_store_rails', '~> 2.0.0'
41
42
 
42
43
  spec.add_development_dependency 'bundler', '~> 1.17'
43
44
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stone-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Junior
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: request_store_rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -151,4 +165,3 @@ signing_key:
151
165
  specification_version: 4
152
166
  summary: API Wrapper for Stone Payments
153
167
  test_files: []
154
- has_rdoc: