mangopay 3.19.0 → 3.21.0

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: 2459553bb0f22fb9230f0b13fa8068e6dccb7996c3436a669bea65e05af3e575
4
- data.tar.gz: 1242453e9fd1f2d9fb943c737c0eef69e1caf26aed2aaae24ee2012803816ddc
3
+ metadata.gz: 4ebf18b4543fba2a3bb18f64c34d7e104647012da1c9a177f20df4c9399832c1
4
+ data.tar.gz: 9907c1a093070848df08f761bcf6ca8e40675220d99bed080987f6545b99d8a2
5
5
  SHA512:
6
- metadata.gz: f3478fdff62b888c86e3e38d1079cd467eb0e7860e16fc9977d9e6be49bec4c645e5a63b0a954c2f416577788abd125759d6b079e191b55a846af524044598e9
7
- data.tar.gz: 11634f163a8d798787a4a1a200592b2387caf05df99df24a4089add703d6128f648aaa8c884c590bbaba2e53ab85ca45100e52fbb3ff89e218a6e0c9d7ddfedb
6
+ metadata.gz: d1abeac43f7b0222ff080a37f6c20c58a01933767e54d6c0b322b13d2b87515c37f791c606c5c755f25957dbfca274139f680ef32bd690e5614345fba45ffd39
7
+ data.tar.gz: 9a083534b2638e0cba743a6a15b9af3e7c25a36108ff87db434aa18dbbf834fbd6a4efe76a2de180cea7a1aeff0fb55a6bf8ca0275cb741142455e1b65f333af
@@ -28,7 +28,7 @@ jobs:
28
28
  ruby-version: 2.6.10
29
29
  - name: Install Rspec
30
30
  run: |
31
- gem install bundler
31
+ gem install bundler -v 2.4.22
32
32
  bundler install
33
33
  - name: Test
34
34
  run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [3.21.0] - 2024-01-23
2
+ ### Added
3
+
4
+ - The endpoint [View a card Validation](https://mangopay.com/docs/endpoints/card-validations#view-card-validation) is now available
5
+
6
+ ## [3.20.0] - 2023-11-15
7
+ ### Added
8
+
9
+ Now, our SDK enables seamless integration with multiple clientIDs, offering enhanced flexibility and customization.
10
+
11
+ You can effortlessly create multiple configuration objects tailored to your specific needs:
12
+
13
+ ```
14
+ config = MangoPay::Configuration.new
15
+ config.client_id = 'your-client-id'
16
+ config.client_apiKey = 'your-api-key'
17
+ config.preproduction = true
18
+ ```
19
+ add them using :
20
+
21
+ `MangoPay.add_config('config1', config)`
22
+
23
+ and perform a call with them using :
24
+
25
+ `MangoPay.get_config('config1').apply_configuration`
26
+
27
+ The previous method configure() is still working.
28
+
1
29
  ## [3.19.0] - 2023-11-02
2
30
  ### Updated
3
31
 
data/README.md CHANGED
@@ -85,6 +85,25 @@ rescue MangoPay::ResponseError => ex
85
85
  end
86
86
  ```
87
87
 
88
+ ### Using multiple clientIDs
89
+ You can effortlessly create multiple configuration objects tailored to your specific needs:
90
+
91
+ ```
92
+ config = MangoPay::Configuration.new
93
+ config.client_id = 'your-client-id'
94
+ config.client_apiKey = 'your-api-key'
95
+ config.preproduction = true
96
+ ```
97
+ add them using :
98
+
99
+ `MangoPay.add_config('config1', config)`
100
+
101
+ and perform a call with them using :
102
+
103
+ `MangoPay.get_config('config1').apply_configuration`
104
+
105
+ The previous method configure() is still working.
106
+
88
107
  ### Accessing RateLimit Headers
89
108
  Along with each request, the rate limiting headers are automatically updated in MangoPay object:
90
109
 
data/lib/mangopay/card.rb CHANGED
@@ -40,6 +40,11 @@ module MangoPay
40
40
  url = "#{MangoPay.api_path}/cards/#{card_id}/validation"
41
41
  MangoPay.request(:post, url, params)
42
42
  end
43
+
44
+ def get_card_validation(card_id, validation_id)
45
+ url = "#{MangoPay.api_path}/cards/#{card_id}/validation/#{validation_id}"
46
+ MangoPay.request(:get, url)
47
+ end
43
48
  end
44
49
  end
45
50
  end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.19.0'
2
+ VERSION = '3.21.0'
3
3
  end
data/lib/mangopay.rb CHANGED
@@ -49,6 +49,8 @@ module MangoPay
49
49
  # temporary
50
50
  autoload :Temp, 'mangopay/temp'
51
51
 
52
+ @configurations = {}
53
+
52
54
  class Configuration
53
55
  attr_accessor :preproduction, :root_url,
54
56
  :client_id, :client_apiKey,
@@ -56,6 +58,20 @@ module MangoPay
56
58
  :http_max_retries, :http_open_timeout,
57
59
  :logger, :use_ssl
58
60
 
61
+ def apply_configuration
62
+ MangoPay.configure do |config|
63
+ config.preproduction = @preproduction
64
+ config.client_id = @client_id
65
+ config.client_apiKey = @client_apiKey
66
+ config.log_file = @log_file
67
+ config.http_timeout = @http_timeout
68
+ config.http_max_retries = @http_max_retries
69
+ config.http_open_timeout = @http_open_timeout
70
+ config.use_ssl = @use_ssl
71
+ config.logger = @logger
72
+ end
73
+ end
74
+
59
75
  def preproduction
60
76
  @preproduction || false
61
77
  end
@@ -138,6 +154,23 @@ module MangoPay
138
154
  @ratelimit = obj
139
155
  end
140
156
 
157
+ # Add MangoPay.Configuration to the list of configs
158
+ def add_config(name, config)
159
+ @configurations[name] = config
160
+ end
161
+
162
+ # Fetch a MangoPay configuration from the list of configs. Throw error if not found
163
+ def get_config(name)
164
+ config = @configurations[name]
165
+ raise "Could not find any configuration with name '#{name}'" unless config
166
+ config
167
+ end
168
+
169
+ def remove_config(name)
170
+ raise "Could not find any configuration with name '#{name}'" unless @configurations[name]
171
+ @configurations[name] = nil
172
+ end
173
+
141
174
  #
142
175
  # - +method+: HTTP method; lowercase symbol, e.g. :get, :post etc.
143
176
  # - +url+: the part after Configuration#root_url
@@ -100,5 +100,13 @@ describe MangoPay::CardRegistration do
100
100
 
101
101
  expect(validated).to_not be_nil
102
102
  end
103
+
104
+ it "fetches card validation" do
105
+ created = new_card_registration_completed
106
+ card_validation = create_card_validation(created['UserId'], created['CardId'])
107
+ fetched_card_validation = MangoPay::Card.get_card_validation(created['CardId'], card_validation['Id'])
108
+
109
+ expect(card_validation['Id']).equal? fetched_card_validation['Id']
110
+ end
103
111
  end
104
112
  end
@@ -13,6 +13,74 @@ describe MangoPay::Configuration do
13
13
  }
14
14
  end
15
15
 
16
+ it 'fails when calling with wrong client credentials, but succeeds after applying a new (correct) config' do
17
+ # create a wrong configuration
18
+ wrong_config = MangoPay::Configuration.new
19
+ wrong_config.client_id = 'placeholder'
20
+ wrong_config.client_apiKey = '0000'
21
+ wrong_config.preproduction = true
22
+
23
+ # create a valid configuration
24
+ valid_config = MangoPay::Configuration.new
25
+ valid_config.client_id = 'sdk-unit-tests'
26
+ valid_config.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
27
+ valid_config.preproduction = true
28
+
29
+ # add the 2 configs to the list of MangoPay configs
30
+ MangoPay.add_config('wrong', wrong_config)
31
+ MangoPay.add_config('valid', valid_config)
32
+
33
+ # apply wrong config
34
+ MangoPay.get_config('wrong').apply_configuration
35
+
36
+ expect {
37
+ MangoPay::User.fetch()
38
+ }.to raise_error { |err|
39
+ expect(err).to be_a MangoPay::ResponseError
40
+ expect(err.code).to eq '401'
41
+ expect(err.message).to eq 'invalid_client'
42
+ }
43
+
44
+ # apply valid configuration
45
+ MangoPay.get_config('valid').apply_configuration
46
+
47
+ # expect success
48
+ users = MangoPay::User.fetch()
49
+ expect(users).to be_kind_of(Array)
50
+ end
51
+
52
+ it 'fails when fetching a config that does not exist' do
53
+ expect {
54
+ MangoPay.get_config('placeholder')
55
+ }.to raise_error { |err|
56
+ expect(err).to be_a RuntimeError
57
+ expect(err.message).to eq "Could not find any configuration with name 'placeholder'"
58
+ }
59
+ end
60
+
61
+ it 'succeeds when removing config' do
62
+ wrong_config = MangoPay::Configuration.new
63
+ wrong_config.client_id = 'placeholder'
64
+ wrong_config.client_apiKey = '0000'
65
+ wrong_config.preproduction = true
66
+
67
+ MangoPay.add_config('wrong', wrong_config)
68
+
69
+ # pass when fetching config before removing it
70
+ MangoPay.get_config('wrong')
71
+
72
+ # remove config
73
+ MangoPay.remove_config('wrong')
74
+
75
+ # fail when trying to fetch after removal
76
+ expect {
77
+ MangoPay.get_config('wrong')
78
+ }.to raise_error { |err|
79
+ expect(err).to be_a RuntimeError
80
+ expect(err.message).to eq "Could not find any configuration with name 'wrong'"
81
+ }
82
+ end
83
+
16
84
  it 'goes ok when calling with correct client credentials' do
17
85
  reset_mangopay_configuration
18
86
  users = MangoPay::User.fetch()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.19.0
4
+ version: 3.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-02 00:00:00.000000000 Z
12
+ date: 2024-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json