wire4_auth 1.0.3 → 1.0.5

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: 4fd2430cb43f273cdee5c8af44d37da774c6c6b30d9ea219f19ed5eeb34475b1
4
- data.tar.gz: 9408b9d5f8a8ed9121dbbb841e51fc8cbe1fbf1c0d7817168eadbb0ade5b3516
3
+ metadata.gz: f5db70a9c65d3027119cba7948f9995deeb2911f6ced3237c01337902f3533eb
4
+ data.tar.gz: e34b2ac873f1ee9ef1651cdbc970a32ae39ac64c882018dc3f06e615b5111fe8
5
5
  SHA512:
6
- metadata.gz: 5d143702786369d5217e53f2dfa9d0bee468477b940f3e02cc915bdc4c83a6c9f770465f87de471491c85ccee302901708ff3db33cad05ae5e7504c7901cff8d
7
- data.tar.gz: 2cd2d6d6ef043213af030b574ed6bd977236572cb5941e7aca6b1883a79fbe8b8e2ddb2b2f6c94d6e78536155d1ddf2e780c9a5cdfd69678316e455a533d5a9b
6
+ metadata.gz: b125d3834cffd9f98b232f1bf2625e8458939cdf8defa7a9b3a2a5905c473b45c7dde4d556059e7208f8c994a319f47998e47ecbfa405816a362563e276794c3
7
+ data.tar.gz: 795cd67e5326cccf36aac67bb9e5f1418c9d0e5b7849c3990839501ad75ec2498472f358617d1f252214db3694975231df9c0f07d735bd0cef413757fee7c35d
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ gemspec
4
4
 
5
5
  group :development, :test do
6
6
  gem 'oauth2', '~> 1.4.3'
7
- gem 'wire4_client', '~> 1.0.3'
7
+ gem 'wire4_client', '~> 1.0.5'
8
8
  end
@@ -47,37 +47,48 @@ module Wire4Auth
47
47
  @tokens_cached_app_user = {}
48
48
  end
49
49
 
50
+ #noinspection DuplicatedCode
50
51
  def obtain_access_token_app(scope = "general")
52
+ key_search = @client_id + scope
53
+ token_cached = @tokens_cached_app_user[key_search]
54
+ if !token_cached.nil? and !token_cached.access_token.nil? and !token_cached.access_token.params.nil? and
55
+ !token_cached.access_token.params['scope'].nil? and !token_cached.access_token.expires_at.nil? and
56
+ token_cached.access_token.expires_at.is_a? Integer and is_valid(token_cached.access_token.expires_at) and
57
+ !token_cached.access_token.token.nil?
51
58
 
52
- if !@token_cached_app.access_token.nil? and !@token_cached_app.access_token.params.nil? and
53
- !@token_cached_app.access_token.params['scope'].nil? and
54
- @token_cached_app.access_token.params['scope'].include? scope and
55
- !@token_cached_app.access_token.expires_at.nil? and @token_cached_app.access_token.expires_at.is_a? Integer and
56
- is_expire(@token_cached_app.access_token.expires_at) and !@token_cached_app.access_token.token.nil?
57
-
58
- return format_to_header(@token_cached_app.access_token.token)
59
+ return format_to_header(token_cached.access_token.token)
59
60
  end
60
61
 
61
62
  begin
62
63
  client = OAuth2::Client.new(@client_id, @client_secret, :token_url => @environment.token_url)
63
- access_token = client.get_token({:grant_type => "client_credentials", :scope => scope})
64
- @token_cached_app.access_token = access_token
64
+ access_token = client.get_token({ :grant_type => "client_credentials", :scope => scope})
65
+
66
+ if @tokens_cached_app_user.length + 1 > MAX_APP_USER_SIZE_CACHED
67
+ @tokens_cached_app_user.each_key do |key|
68
+ @tokens_cached_app_user.delete(key)
69
+ break
70
+ end
71
+ end
72
+
73
+ @tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(@client_id, @client_secret, access_token)
65
74
 
66
75
  return format_to_header(access_token.token)
67
76
  rescue OAuth2::Error => e
68
77
  raise Wire4Client::ApiError.new(:code => e.code,
69
78
  :message => e.description)
70
79
  end
80
+
71
81
  end
72
82
 
83
+ #noinspection DuplicatedCode
73
84
  def obtain_access_token_app_user(user_key, secret_key, scope = "spei_admin")
74
85
 
75
86
  key_search = user_key + scope
76
87
  token_cached = @tokens_cached_app_user[key_search]
77
88
  if !token_cached.nil? and !token_cached.access_token.nil? and !token_cached.access_token.params.nil? and
78
- !token_cached.access_token.params['scope'].nil? and token_cached.access_token.params['scope'].include? scope and
79
- !token_cached.access_token.expires_at.nil? and token_cached.access_token.expires_at.is_a? Integer and
80
- is_expire(token_cached.access_token.expires_at) and !token_cached.access_token.token.nil?
89
+ !token_cached.access_token.params['scope'].nil? and !token_cached.access_token.expires_at.nil? and
90
+ token_cached.access_token.expires_at.is_a? Integer and is_valid(token_cached.access_token.expires_at) and
91
+ !token_cached.access_token.token.nil?
81
92
 
82
93
  return format_to_header(token_cached.access_token.token)
83
94
  end
@@ -107,16 +118,28 @@ module Wire4Auth
107
118
 
108
119
  begin
109
120
  client = OAuth2::Client.new(@client_id, @client_secret, :token_url => @environment.token_url)
110
- access_token = client.get_token({:grant_type => "client_credentials", :scope => scope})
111
- @token_cached_app.access_token = access_token
121
+ access_token = client.get_token({ :grant_type => "client_credentials", :scope => scope})
122
+
123
+ key_search = @client_id + scope
124
+ token_cached = @tokens_cached_app_user[key_search]
125
+ if token_cached.nil? and @tokens_cached_app_user.length + 1 > MAX_APP_USER_SIZE_CACHED
126
+ @tokens_cached_app_user.each_key do |key|
127
+ @tokens_cached_app_user.delete(key)
128
+ break
129
+ end
130
+ end
131
+
132
+ @tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(@client_id, @client_secret, access_token)
112
133
 
113
134
  return format_to_header(access_token.token)
114
135
  rescue OAuth2::Error => e
115
136
  raise Wire4Client::ApiError.new(:code => e.code,
116
137
  :message => e.description)
117
138
  end
139
+
118
140
  end
119
141
 
142
+ #noinspection RubyInstanceMethodNamingConvention
120
143
  def regenerate_access_token_app_user(user_key, secret_key, scope = "spei_admin")
121
144
 
122
145
  begin
@@ -147,16 +170,17 @@ module Wire4Auth
147
170
  Wire4Client.configure do |config|
148
171
  # Configure OAuth2 access token for authorization
149
172
  config.host = @environment.service_url
173
+ config.base_path = @environment.base_path
150
174
  end
151
175
  end
152
176
 
153
177
  private
154
178
 
155
- def is_expire(expires_at)
179
+ def is_valid(expires_at)
156
180
 
157
181
  time = Time.at(expires_at)
158
182
  # Get current time using the time zone
159
- now = Time.now - 5 * 60 # minus 5 minutes
183
+ now = Time.now + 5 * 60 # plus 5 minutes
160
184
 
161
185
  time > now
162
186
  end
@@ -23,16 +23,19 @@ module Wire4Auth
23
23
 
24
24
  attr_reader :service_url
25
25
 
26
- def initialize(token_url, service_url)
26
+ attr_reader :base_path
27
+
28
+ def initialize(token_url, service_url, base_path)
27
29
  @token_url = token_url
28
30
  @service_url = service_url
31
+ @base_path = base_path
29
32
  end
30
33
 
31
- SANDBOX = new("https://sandbox-api.wire4.mx/token", "sandbox-api.wire4.mx")
34
+ SANDBOX = new('https://sandbox-api.wire4.mx/token', 'sandbox-api.wire4.mx', '/wire4/1.0.0')
32
35
 
33
- DEVELOPMENT = new('https://development-api.wire4.mx/token', 'development-api.wire4.mx')
36
+ DEVELOPMENT = new('https://development-api.wire4.mx/token', 'development-api.wire4.mx', '/wire4/1.0.0')
34
37
 
35
- PRODUCTION = new("https://api.wire4.mx/token", "api.wire4.mx")
38
+ PRODUCTION = new('https://api.wire4.mx/token', 'api.wire4.mx', '/wire4/1.0.0')
36
39
 
37
40
  class << self
38
41
  private :new
@@ -47,7 +47,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
47
47
  oauth_wire4.config_default_api_client
48
48
  authorization = oauth_wire4.obtain_access_token_app('general')
49
49
  rescue Wire4Client::ApiError => e
50
- puts "Exception to obtain access token #{e}"
50
+ puts "Exception to obtain access token #{e.response_body}"
51
51
  # Optional manage exception in access token flow
52
52
  return
53
53
  end
@@ -68,7 +68,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
68
68
  response = api_instance.send_contact_using_post_with_http_info(authorization, body)
69
69
  p response
70
70
  rescue Wire4Client::ApiError => e
71
- puts "Exception to obtain access token #{e}"
71
+ puts "Exception to obtain access token #{e.response_body}"
72
72
  # Optional manage exception in access token flow
73
73
  return
74
74
  end
@@ -86,7 +86,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
86
86
  oauth_wire4.config_default_api_client
87
87
  authorization = oauth_wire4.obtain_access_token_app('general')
88
88
  rescue Wire4Client::ApiError => e
89
- puts "Exception to obtain access token #{e}"
89
+ puts "Exception to obtain access token #{e.response_body}"
90
90
  # Optional manage exception in access token flow
91
91
  return
92
92
  end
@@ -110,7 +110,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
110
110
  response = api_instance.obtain_transaction_cep_using_post(authorization, cep_data)
111
111
  p response
112
112
  rescue Wire4Client::ApiError => e
113
- puts "Exception when calling the API: #{e}"
113
+ puts "Exception when calling the API: #{e.response_body}"
114
114
  # Optional manage exception in call API
115
115
  return
116
116
  end
@@ -128,7 +128,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
128
128
  oauth_wire4.config_default_api_client
129
129
  authorization = oauth_wire4.obtain_access_token_app('general')
130
130
  rescue Wire4Client::ApiError => e
131
- puts "Exception to obtain access token #{e}"
131
+ puts "Exception to obtain access token #{e.response_body}"
132
132
  # Optional manage exception in access token flow
133
133
  return
134
134
  end
@@ -146,7 +146,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
146
146
  response = api_instance.pre_enrollment_monex_user_using_post(authorization, body)
147
147
  p response
148
148
  rescue Wire4Client::ApiError => e
149
- puts "Exception when calling the API: #{e}"
149
+ puts "Exception when calling the API: #{e.response_body}"
150
150
  # Optional manage exception in call API
151
151
  return
152
152
  end
@@ -164,7 +164,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
164
164
  oauth_wire4.config_default_api_client
165
165
  authorization = oauth_wire4.obtain_access_token_app('general')
166
166
  rescue Wire4Client::ApiError => e
167
- puts "Exception to obtain access token #{e}"
167
+ puts "Exception to obtain access token #{e.response_body}"
168
168
  # Optional manage exception in access token flow
169
169
  return
170
170
  end
@@ -180,7 +180,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
180
180
  response = api_instance.remove_subscription_pending_status_using_delete_with_http_info(authorization, subscription)
181
181
  p response
182
182
  rescue Wire4Client::ApiError => e
183
- puts "Exception when calling the API: #{e}"
183
+ puts "Exception when calling the API: #{e.response_body}"
184
184
  # Optional manage exception in call API
185
185
  return
186
186
  end
@@ -203,7 +203,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
203
203
  authorization = oauth_wire4.obtain_access_token_app_user(subscription_to_remove_user_key,
204
204
  subscription_to_remove_user_secret, 'spei_admin')
205
205
  rescue Wire4Client::ApiError => e
206
- puts "Exception to obtain access token #{e}"
206
+ puts "Exception to obtain access token #{e.response_body}"
207
207
  # Optional manage exception in access token flow
208
208
  return
209
209
  end
@@ -219,7 +219,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
219
219
  response = api_instance.remove_enrollment_user_using_delete_with_http_info(authorization, subscription)
220
220
  p response
221
221
  rescue Wire4Client::ApiError => e
222
- puts "Exception when calling the API: #{e}"
222
+ puts "Exception when calling the API: #{e.response_body}"
223
223
  # Optional manage exception in call API
224
224
  return
225
225
  end
@@ -237,7 +237,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
237
237
  oauth_wire4.config_default_api_client
238
238
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
239
239
  rescue Wire4Client::ApiError => e
240
- puts "Exception to obtain access token #{e}"
240
+ puts "Exception to obtain access token #{e.response_body}"
241
241
  # Optional manage exception in access token flow
242
242
  return
243
243
  end
@@ -253,7 +253,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
253
253
  response = api_instance.get_available_relationships_monex_using_get(authorization, subscription)
254
254
  p response
255
255
  rescue Wire4Client::ApiError => e
256
- puts "Exception when calling the API: #{e}"
256
+ puts "Exception when calling the API: #{e.response_body}"
257
257
  # Optional manage exception in call API
258
258
  return
259
259
  end
@@ -272,7 +272,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
272
272
  oauth_wire4.config_default_api_client
273
273
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
274
274
  rescue Wire4Client::ApiError => e
275
- puts "Exception to obtain access token #{e}"
275
+ puts "Exception to obtain access token #{e.response_body}"
276
276
  # Optional manage exception in access token flow
277
277
  return
278
278
  end
@@ -306,7 +306,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
306
306
  response = api_instance.pre_register_accounts_using_post(authorization, body, subscription)
307
307
  p response
308
308
  rescue Wire4Client::ApiError => e
309
- puts "Exception when calling the API: #{e}"
309
+ puts "Exception when calling the API: #{e.response_body}"
310
310
  # Optional manage exception in call API
311
311
  return
312
312
  end
@@ -325,7 +325,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
325
325
  oauth_wire4.config_default_api_client
326
326
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
327
327
  rescue Wire4Client::ApiError => e
328
- puts "Exception to obtain access token #{e}"
328
+ puts "Exception to obtain access token #{e.response_body}"
329
329
  # Optional manage exception in access token flow
330
330
  return
331
331
  end
@@ -342,7 +342,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
342
342
  response = api_instance.remove_beneficiaries_pending_using_delete_with_http_info(authorization, request_id, subscription)
343
343
  p response
344
344
  rescue Wire4Client::ApiError => e
345
- puts "Exception when calling the API: #{e}"
345
+ puts "Exception when calling the API: #{e.response_body}"
346
346
  # Optional manage exception in call API
347
347
  return
348
348
  end
@@ -360,7 +360,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
360
360
  oauth_wire4.config_default_api_client
361
361
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
362
362
  rescue Wire4Client::ApiError => e
363
- puts "Exception to obtain access token #{e}"
363
+ puts "Exception to obtain access token #{e.response_body}"
364
364
  # Optional manage exception in access token flow
365
365
  return
366
366
  end
@@ -379,19 +379,19 @@ class Wire4ExamplesTest < Test::Unit::TestCase
379
379
  response = api_instance.get_beneficiaries_for_account_using_get(authorization, subscription)
380
380
  p response
381
381
  rescue Wire4Client::ApiError => e
382
- puts "Exception when calling the API: #{e}"
382
+ puts "Exception when calling the API: #{e.response_body}"
383
383
  # Optional manage exception in call API
384
384
  return
385
385
  end
386
386
  end
387
387
 
388
+ #noinspection RubyInstanceMethodNamingConvention
388
389
  def test_obtain_beneficiaries_by_request_id
389
- #omit('Reason')
390
+ omit('Reason')
390
391
  # Create the authenticator to obtain access token
391
392
  # The token URL and Service URL are defined for this environment enum value.
392
393
  # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
393
- oauth_wire4 = Wire4Auth::OAuthWire4.new("kIinyEIYWUIF3pflFxhRdKft2_ga", "A_ffMFosMhm5j7l0L7Ptvbfrp9Ma", Wire4Auth::EnvironmentEnum::DEVELOPMENT)
394
- #CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
394
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
395
395
 
396
396
  begin
397
397
  # Obtain an access token use application flow and scope "spei_admin" and add to request
@@ -399,7 +399,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
399
399
  authorization = oauth_wire4.obtain_access_token_app_user("0bb13bfb99d461a8a0e18746b25e7d@develop.wire4.mx", "0b6ea839f33467a81631b380d37472", 'spei_admin')
400
400
  # USER_KEY, SECRET_KEY, 'spei_admin')
401
401
  rescue Wire4Client::ApiError => e
402
- puts "Exception to obtain access token #{e}"
402
+ puts "Exception to obtain access token #{e.response_body}"
403
403
  # Optional manage exception in access token flow
404
404
  return
405
405
  end
@@ -416,7 +416,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
416
416
  response = api_instance.get_beneficiaries_by_request_id(authorization, request_id, subscription)
417
417
  p response
418
418
  rescue Wire4Client::ApiError => e
419
- puts "Exception when calling the API: #{e}"
419
+ puts "Exception when calling the API: #{e.response_body}"
420
420
  # Optional manage exception in call API
421
421
  return
422
422
  end
@@ -435,7 +435,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
435
435
  oauth_wire4.config_default_api_client
436
436
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
437
437
  rescue Wire4Client::ApiError => e
438
- puts "Exception to obtain access token #{e}"
438
+ puts "Exception to obtain access token #{e.response_body}"
439
439
  # Optional manage exception in access token flow
440
440
  return
441
441
  end
@@ -450,19 +450,22 @@ class Wire4ExamplesTest < Test::Unit::TestCase
450
450
  body.amount_limit = 20000.00
451
451
  body.currency_code = "MXP"
452
452
  body.previous_amount_limit = 10000.00
453
+ body.return_url = "https://your-app-url.mx/return"
454
+ body.cancel_return_url = "https://your-app-url.mx/cancel"
453
455
 
454
456
  begin
455
457
  # Call the API
456
458
  response = api_instance.update_amount_limit_account_using_put_with_http_info(authorization, account, body, subscription)
457
459
  p response
458
460
  rescue Wire4Client::ApiError => e
459
- puts "Exception when calling the API: #{e}"
461
+ puts "Exception when calling the API: #{e.response_body}"
460
462
  # Optional manage exception in call API
461
463
  return
462
464
  end
463
465
  end
464
466
 
465
467
  def test_delete_beneficiary
468
+ omit('Reason')
466
469
  # Create the authenticator to obtain access token
467
470
  # The token URL and Service URL are defined for this environment enum value.
468
471
  # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
@@ -473,7 +476,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
473
476
  oauth_wire4.config_default_api_client
474
477
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
475
478
  rescue Wire4Client::ApiError => e
476
- puts "Exception to obtain access token #{e}"
479
+ puts "Exception to obtain access token #{e.response_body}"
477
480
  # Optional manage exception in access token flow
478
481
  return
479
482
  end
@@ -490,7 +493,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
490
493
  response = api_instance.delete_account_using_delete_with_http_info(authorization, account, subscription)
491
494
  p response
492
495
  rescue Wire4Client::ApiError => e
493
- puts "Exception when calling the API: #{e}"
496
+ puts "Exception when calling the API: #{e.response_body}"
494
497
  # Optional manage exception in call API
495
498
  return
496
499
  end
@@ -508,7 +511,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
508
511
  oauth_wire4.config_default_api_client
509
512
  authorization = oauth_wire4.obtain_access_token_app('general')
510
513
  rescue Wire4Client::ApiError => e
511
- puts "Exception to obtain access token #{e}"
514
+ puts "Exception to obtain access token #{e.response_body}"
512
515
  # Optional manage exception in access token flow
513
516
  return
514
517
  end
@@ -521,7 +524,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
521
524
  response = api_instance.get_all_institutions_using_get(authorization)
522
525
  p response
523
526
  rescue Wire4Client::ApiError => e
524
- puts "Exception when calling the API: #{e}"
527
+ puts "Exception when calling the API: #{e.response_body}"
525
528
  # Optional manage exception in call API
526
529
  return
527
530
  end
@@ -539,7 +542,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
539
542
  oauth_wire4.config_default_api_client
540
543
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
541
544
  rescue Wire4Client::ApiError => e
542
- puts "Exception to obtain access token #{e}"
545
+ puts "Exception to obtain access token #{e.response_body}"
543
546
  # Optional manage exception in access token flow
544
547
  return
545
548
  end
@@ -555,7 +558,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
555
558
  response = api_instance.get_balance_using_get(authorization, subscription)
556
559
  p response
557
560
  rescue Wire4Client::ApiError => e
558
- puts "Exception when calling the API: #{e}"
561
+ puts "Exception when calling the API: #{e.response_body}"
559
562
  # Optional manage exception in call API
560
563
  return
561
564
  end
@@ -574,7 +577,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
574
577
  oauth_wire4.config_default_api_client
575
578
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
576
579
  rescue Wire4Client::ApiError => e
577
- puts "Exception to obtain access token #{e}"
580
+ puts "Exception to obtain access token #{e.response_body}"
578
581
  # Optional manage exception in access token flow
579
582
  return
580
583
  end
@@ -590,7 +593,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
590
593
  response = api_instance.get_spid_classifications_using_get(authorization, subscription)
591
594
  p response
592
595
  rescue Wire4Client::ApiError => e
593
- puts "Exception when calling the API: #{e}"
596
+ puts "Exception when calling the API: #{e.response_body}"
594
597
  # Optional manage exception in call API
595
598
  return
596
599
  end
@@ -609,7 +612,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
609
612
  oauth_wire4.config_default_api_client
610
613
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
611
614
  rescue Wire4Client::ApiError => e
612
- puts "Exception to obtain access token #{e}"
615
+ puts "Exception to obtain access token #{e.response_body}"
613
616
  # Optional manage exception in access token flow
614
617
  return
615
618
  end
@@ -637,7 +640,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
637
640
  response = api_instance.pre_register_accounts_using_post1(authorization, body, subscription)
638
641
  p response
639
642
  rescue Wire4Client::ApiError => e
640
- puts "Exception when calling the API: #{e}"
643
+ puts "Exception when calling the API: #{e.response_body}"
641
644
  # Optional manage exception in call API
642
645
  return
643
646
  end
@@ -655,7 +658,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
655
658
  oauth_wire4.config_default_api_client
656
659
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
657
660
  rescue Wire4Client::ApiError => e
658
- puts "Exception to obtain access token #{e}"
661
+ puts "Exception to obtain access token #{e.response_body}"
659
662
  # Optional manage exception in access token flow
660
663
  return
661
664
  end
@@ -674,7 +677,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
674
677
  response = api_instance.get_spid_beneficiaries_for_account(authorization, subscription)
675
678
  p response
676
679
  rescue Wire4Client::ApiError => e
677
- puts "Exception when calling the API: #{e}"
680
+ puts "Exception when calling the API: #{e.response_body}"
678
681
  # Optional manage exception in call API
679
682
  return
680
683
  end
@@ -692,7 +695,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
692
695
  oauth_wire4.config_default_api_client
693
696
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
694
697
  rescue Wire4Client::ApiError => e
695
- puts "Exception to obtain access token #{e}"
698
+ puts "Exception to obtain access token #{e.response_body}"
696
699
  # Optional manage exception in access token flow
697
700
  return
698
701
  end
@@ -708,7 +711,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
708
711
  response = api_instance.get_depositants_using_get(authorization, subscription)
709
712
  p response
710
713
  rescue Wire4Client::ApiError => e
711
- puts "Exception when calling the API: #{e}"
714
+ puts "Exception when calling the API: #{e.response_body}"
712
715
  # Optional manage exception in call API
713
716
  return
714
717
  end
@@ -726,7 +729,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
726
729
  oauth_wire4.config_default_api_client
727
730
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
728
731
  rescue Wire4Client::ApiError => e
729
- puts "Exception to obtain access token #{e}"
732
+ puts "Exception to obtain access token #{e.response_body}"
730
733
  # Optional manage exception in access token flow
731
734
  return
732
735
  end
@@ -747,7 +750,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
747
750
  response = api_instance.register_depositants_using_post(authorization, body, subscription)
748
751
  p response
749
752
  rescue Wire4Client::ApiError => e
750
- puts "Exception when calling the API: #{e}"
753
+ puts "Exception when calling the API: #{e.response_body}"
751
754
  # Optional manage exception in call API
752
755
  return
753
756
  end
@@ -766,7 +769,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
766
769
  oauth_wire4.config_default_api_client
767
770
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
768
771
  rescue Wire4Client::ApiError => e
769
- puts "Exception to obtain access token #{e}"
772
+ puts "Exception to obtain access token #{e.response_body}"
770
773
  # Optional manage exception in access token flow
771
774
  return
772
775
  end
@@ -782,7 +785,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
782
785
  response = api_instance.incoming_spei_transactions_report_using_get(authorization, subscription)
783
786
  p response
784
787
  rescue Wire4Client::ApiError => e
785
- puts "Exception when calling the API: #{e}"
788
+ puts "Exception when calling the API: #{e.response_body}"
786
789
  # Optional manage exception in call API
787
790
  return
788
791
  end
@@ -801,7 +804,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
801
804
  oauth_wire4.config_default_api_client
802
805
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
803
806
  rescue Wire4Client::ApiError => e
804
- puts "Exception to obtain access token #{e}"
807
+ puts "Exception to obtain access token #{e.response_body}"
805
808
  # Optional manage exception in access token flow
806
809
  return
807
810
  end
@@ -817,7 +820,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
817
820
  response = api_instance.outgoing_spei_transactions_report_using_get(authorization, subscription)
818
821
  p response
819
822
  rescue Wire4Client::ApiError => e
820
- puts "Exception when calling the API: #{e}"
823
+ puts "Exception when calling the API: #{e.response_body}"
821
824
  # Optional manage exception in call API
822
825
  return
823
826
  end
@@ -836,7 +839,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
836
839
  oauth_wire4.config_default_api_client
837
840
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
838
841
  rescue Wire4Client::ApiError => e
839
- puts "Exception to obtain access token #{e}"
842
+ puts "Exception to obtain access token #{e.response_body}"
840
843
  # Optional manage exception in access token flow
841
844
  return
842
845
  end
@@ -853,7 +856,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
853
856
  response = api_instance.out_comming_spei_request_id_transactions_report_using_get(authorization, request_id, subscription)
854
857
  p response
855
858
  rescue Wire4Client::ApiError => e
856
- puts "Exception when calling TransferenciasSPEIApi->out_comming_spei_request_id_transactions_report_using_get: #{e}"
859
+ puts "Exception when calling TransferenciasSPEIApi->out_comming_spei_request_id_transactions_report_using_get: #{e.response_body}"
857
860
  # Optional manage exception in call API
858
861
  return
859
862
  end
@@ -872,7 +875,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
872
875
  oauth_wire4.config_default_api_client
873
876
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
874
877
  rescue Wire4Client::ApiError => e
875
- puts "Exception to obtain access token #{e}"
878
+ puts "Exception to obtain access token #{e.response_body}"
876
879
  # Optional manage exception in access token flow
877
880
  return
878
881
  end
@@ -900,7 +903,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
900
903
  response = api_instance.register_outgoing_spei_transaction_using_post(authorization, subscription, body)
901
904
  p response
902
905
  rescue Wire4Client::ApiError => e
903
- puts "Exception when calling the API: #{e}"
906
+ puts "Exception when calling the API: #{e.response_body}"
904
907
  # Optional manage exception in call API
905
908
  return
906
909
  end
@@ -919,7 +922,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
919
922
  oauth_wire4.config_default_api_client
920
923
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
921
924
  rescue Wire4Client::ApiError => e
922
- puts "Exception to obtain access token #{e}"
925
+ puts "Exception to obtain access token #{e.response_body}"
923
926
  # Optional manage exception in access token flow
924
927
  return
925
928
  end
@@ -936,7 +939,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
936
939
  response = api_instance.drop_transactions_pending_using_delete_with_http_info(authorization, request_id, subscription)
937
940
  p response
938
941
  rescue Wire4Client::ApiError => e
939
- puts "Exception when calling the API: #{e}"
942
+ puts "Exception when calling the API: #{e.response_body}"
940
943
  # Optional manage exception in call API
941
944
  return
942
945
  end
@@ -955,7 +958,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
955
958
  oauth_wire4.config_default_api_client
956
959
  authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
957
960
  rescue Wire4Client::ApiError => e
958
- puts "Exception to obtain access token #{e}"
961
+ puts "Exception to obtain access token #{e.response_body}"
959
962
  # Optional manage exception in access token flow
960
963
  return
961
964
  end
@@ -982,7 +985,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
982
985
  response = api_instance.register_outgoing_spid_transaction_using_post(authorization, subscription, body)
983
986
  p response
984
987
  rescue Wire4Client::ApiError => e
985
- puts "Exception when calling the API: #{e}"
988
+ puts "Exception when calling the API: #{e.response_body}"
986
989
  # Optional manage exception in call API
987
990
  return
988
991
  end
@@ -1000,7 +1003,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1000
1003
  oauth_wire4.config_default_api_client
1001
1004
  authorization = oauth_wire4.obtain_access_token_app('general')
1002
1005
  rescue Wire4Client::ApiError => e
1003
- puts "Exception to obtain access token #{e}"
1006
+ puts "Exception to obtain access token #{e.response_body}"
1004
1007
  # Optional manage exception in access token flow
1005
1008
  return
1006
1009
  end
@@ -1019,7 +1022,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1019
1022
  response = api_instance.register_webhook(authorization, body)
1020
1023
  p response
1021
1024
  rescue Wire4Client::ApiError => e
1022
- puts "Exception when calling the API: #{e}"
1025
+ puts "Exception when calling the API: #{e.response_body}"
1023
1026
  # Optional manage exception in call API
1024
1027
  return
1025
1028
  end
@@ -1037,7 +1040,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1037
1040
  oauth_wire4.config_default_api_client
1038
1041
  authorization = oauth_wire4.obtain_access_token_app('general')
1039
1042
  rescue Wire4Client::ApiError => e
1040
- puts "Exception to obtain access token #{e}"
1043
+ puts "Exception to obtain access token #{e.response_body}"
1041
1044
  # Optional manage exception in access token flow
1042
1045
  return
1043
1046
  end
@@ -1050,7 +1053,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1050
1053
  response = api_instance.get_webhooks(authorization)
1051
1054
  p response
1052
1055
  rescue Wire4Client::ApiError => e
1053
- puts "Exception when calling the API: #{e}"
1056
+ puts "Exception when calling the API: #{e.response_body}"
1054
1057
  # Optional manage exception in call API
1055
1058
  return
1056
1059
  end
@@ -1068,7 +1071,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1068
1071
  oauth_wire4.config_default_api_client
1069
1072
  authorization = oauth_wire4.obtain_access_token_app('general')
1070
1073
  rescue Wire4Client::ApiError => e
1071
- puts "Exception to obtain access token #{e}"
1074
+ puts "Exception to obtain access token #{e.response_body}"
1072
1075
  # Optional manage exception in access token flow
1073
1076
  return
1074
1077
  end
@@ -1081,7 +1084,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1081
1084
  response = api_instance.get_webhook(authorization, "wh_3fe3e5f4849f4cabb147804fd55c86fc")
1082
1085
  p response
1083
1086
  rescue Wire4Client::ApiError => e
1084
- puts "Exception when calling the API: #{e}"
1087
+ puts "Exception when calling the API: #{e.response_body}"
1085
1088
  # Optional manage exception in call API
1086
1089
  return
1087
1090
  end
@@ -1093,16 +1096,14 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1093
1096
  # The token URL and Service URL are defined for this environment enum value.
1094
1097
  # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1095
1098
 
1096
- #oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1097
- oauth_wire4 = Wire4Auth::OAuthWire4.new("kIinyEIYWUIF3pflFxhRdKft2_ga",
1098
- "gca6FwUE_9Dk23UhWoM81pZkNgEa", Wire4Auth::EnvironmentEnum::DEVELOPMENT)
1099
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1099
1100
 
1100
1101
  begin
1101
1102
  # Obtain an access token use application flow and scope "general" and add to request
1102
1103
  oauth_wire4.config_default_api_client
1103
1104
  authorization = oauth_wire4.obtain_access_token_app('general')
1104
1105
  rescue Wire4Client::ApiError => e
1105
- puts "Exception to obtain access token #{e}"
1106
+ puts "Exception to obtain access token #{e.response_body}"
1106
1107
  # Optional manage exception in access token flow
1107
1108
  return
1108
1109
  end
@@ -1115,7 +1116,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1115
1116
  response = api_instance.billings_report_using_get(authorization, period: "2019-10")
1116
1117
  p response
1117
1118
  rescue Wire4Client::ApiError => e
1118
- puts "Exception when calling the API: #{e}"
1119
+ puts "Exception when calling the API: #{e.response_body}"
1119
1120
  # Optional manage exception in call API
1120
1121
  return
1121
1122
  end
@@ -1128,15 +1129,13 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1128
1129
  # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1129
1130
 
1130
1131
  oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1131
- #oauth_wire4 = Wire4Auth::OAuthWire4.new("kIinyEIYWUIF3pflFxhRdKft2_ga",
1132
- # "gca6FwUE_9Dk23UhWoM81pZkNgEa", Wire4Auth::EnvironmentEnum::DEVELOPMENT)
1133
1132
 
1134
1133
  begin
1135
1134
  # Obtain an access token use application flow and scope "general" and add to request
1136
1135
  oauth_wire4.config_default_api_client
1137
1136
  authorization = oauth_wire4.obtain_access_token_app('general')
1138
1137
  rescue Wire4Client::ApiError => e
1139
- puts "Exception to obtain access token #{e}"
1138
+ puts "Exception to obtain access token #{e.response_body}"
1140
1139
  # Optional manage exception in access token flow
1141
1140
  return
1142
1141
  end
@@ -1149,7 +1148,7 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1149
1148
  response = api_instance.billings_report_by_id_using_get(authorization, "834BA74A-BBBB-43C4-8400-A4528153C2BD")
1150
1149
  p response
1151
1150
  rescue Wire4Client::ApiError => e
1152
- puts "Exception when calling the API: #{e}"
1151
+ puts "Exception when calling the API: #{e.response_body}"
1153
1152
  # Optional manage exception in call API
1154
1153
  return
1155
1154
  end
@@ -1173,4 +1172,478 @@ class Wire4ExamplesTest < Test::Unit::TestCase
1173
1172
 
1174
1173
  assert result
1175
1174
  end
1176
- end
1175
+
1176
+ #noinspection RubyInstanceMethodNamingConvention
1177
+ def test_authorize_accounts_pending
1178
+ omit('Reason')
1179
+ # Create the authenticator to obtain access token
1180
+ # The token URL and Service URL are defined for this environment enum value.
1181
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1182
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1183
+
1184
+ begin
1185
+ # Obtain an access token use application flow and scope "spei_admin" and add to request
1186
+ oauth_wire4.config_default_api_client
1187
+ authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
1188
+ rescue Wire4Client::ApiError => e
1189
+ puts "Exception to obtain access token #{e.response_body}"
1190
+ # Optional manage exception in access token flow
1191
+ return
1192
+ end
1193
+
1194
+ # create an instance of the API class
1195
+ api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
1196
+
1197
+ # build body with info (check references for more info, types, required fields)
1198
+ subscription = SUBSCRIPTION
1199
+ body = Wire4Client::UrlsRedirect.new
1200
+ body.cancel_return_url = "https://your-app-url.mx/return"
1201
+ body.return_url = "https://your-app-url.mx/cancel"
1202
+
1203
+ begin
1204
+ # Call the API
1205
+ response = api_instance.authorize_accounts_pending_put(authorization, subscription, body)
1206
+ p response
1207
+ rescue Wire4Client::ApiError => e
1208
+ puts "Exception when calling the API: #{e.response_body}"
1209
+ # Optional manage exception in call API
1210
+ return
1211
+ end
1212
+ end
1213
+
1214
+ #noinspection RubyInstanceMethodNamingConvention
1215
+ def test_create_authorization_transactions_group
1216
+ omit('Reason')
1217
+ # Create the authenticator to obtain access token
1218
+ # The token URL and Service URL are defined for this environment enum value.
1219
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1220
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1221
+
1222
+ begin
1223
+ # Obtain an access token use application flow and scope "spei_admin" and add to request
1224
+ oauth_wire4.config_default_api_client
1225
+ authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
1226
+ rescue Wire4Client::ApiError => e
1227
+ puts "Exception to obtain access token #{e.response_body}"
1228
+ # Optional manage exception in access token flow
1229
+ return
1230
+ end
1231
+
1232
+ # create an instance of the API class
1233
+ api_instance = Wire4Client::TransferenciasSPEIApi.new
1234
+
1235
+ # build body with info (check references for more info, types, required fields)
1236
+ subscription = SUBSCRIPTION
1237
+ body = Wire4Client::AuthorizationTransactionGroup.new
1238
+ body.transactions = ["2454ffb2-a699-408f-9812-9a12eed11bfc"] # Add N transactions order identifiers
1239
+
1240
+ body.redirect_urls = Wire4Client::UrlsRedirect.new
1241
+ body.redirect_urls.cancel_return_url = "https://your-app-url.mx/return"
1242
+ body.redirect_urls.return_url = "https://your-app-url.mx/cancel"
1243
+
1244
+ begin
1245
+ # Call the API
1246
+ response = api_instance.create_authorization_transactions_group(authorization, body, subscription)
1247
+ p response
1248
+ rescue Wire4Client::ApiError => e
1249
+ puts "Exception when calling the API: #{e.response_body}"
1250
+ # Optional manage exception in call API
1251
+ return
1252
+ end
1253
+ end
1254
+
1255
+ def test_register_company_using
1256
+ omit('Reason')
1257
+ # Create the authenticator to obtain access token
1258
+ # The token URL and Service URL are defined for this environment enum value.
1259
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1260
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1261
+
1262
+ begin
1263
+ # Obtain an access token use application flow and scope "codi_general" and add to request
1264
+ oauth_wire4.config_default_api_client
1265
+ authorization = oauth_wire4.obtain_access_token_app('codi_general')
1266
+ rescue Wire4Client::ApiError => e
1267
+ puts "Exception to obtain access token #{e.response_body}"
1268
+ # Optional manage exception in access token flow
1269
+ return
1270
+ end
1271
+
1272
+ # create an instance of the API class
1273
+ api_instance = Wire4Client::EmpresasCoDiApi.new
1274
+
1275
+ # build body with info (check references for more info, types, required fields)
1276
+ body = Wire4Client::CompanyRequested.new
1277
+ body.business_name = "Tacos"
1278
+ body.comercial_name = "Tacos el Compa"
1279
+ body.rfc = "TACO580926LA1"
1280
+ body.certificate = Wire4Client::CertificateRequest.new
1281
+ body.certificate.certificate_number = "4908439084390849084"
1282
+ body.certificate._alias = "00040390904903904909"
1283
+ body.certificate.check_digit = "1"
1284
+ body.certificate.cipher_data = "4309jij3490j43jf0j3490fFFFDSDS4393490"
1285
+
1286
+ begin
1287
+ # Call the API
1288
+ response = api_instance.register_company_using_post(authorization, body)
1289
+ p response
1290
+ rescue Wire4Client::ApiError => e
1291
+ puts "Exception when calling the API: #{e.response_body}"
1292
+ # Optional manage exception in call API
1293
+ return
1294
+ end
1295
+ end
1296
+
1297
+ def test_obtain_companies
1298
+ #omit('Reason')
1299
+ # Create the authenticator to obtain access token
1300
+ # The token URL and Service URL are defined for this environment enum value.
1301
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1302
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1303
+
1304
+ begin
1305
+ # Obtain an access token use application flow and scope "codi_general" and add to request
1306
+ oauth_wire4.config_default_api_client
1307
+ authorization = oauth_wire4.obtain_access_token_app('codi_general')
1308
+ rescue Wire4Client::ApiError => e
1309
+ puts "Exception to obtain access token #{e.response_body}"
1310
+ # Optional manage exception in access token flow
1311
+ return
1312
+ end
1313
+
1314
+ # create an instance of the API class
1315
+ api_instance = Wire4Client::EmpresasCoDiApi.new
1316
+
1317
+ begin
1318
+ # Call the API
1319
+ response = api_instance.obtain_companies(authorization)
1320
+ p response
1321
+ rescue Wire4Client::ApiError => e
1322
+ puts "Exception when calling the API: #{e.response_body}"
1323
+ # Optional manage exception in call API
1324
+ return
1325
+ end
1326
+ end
1327
+
1328
+ COMPANY_ID = "0b43cbd2-2a86-4eb5-a51c-49a53d521295"
1329
+
1330
+ def test_create_sales_point
1331
+ omit('Reason')
1332
+ # Create the authenticator to obtain access token
1333
+ # The token URL and Service URL are defined for this environment enum value.
1334
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1335
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1336
+
1337
+ begin
1338
+ # Obtain an access token use application flow and scope "spei_admin" and add to request
1339
+ oauth_wire4.config_default_api_client
1340
+ authorization = oauth_wire4.obtain_access_token_app('codi_general')
1341
+ rescue Wire4Client::ApiError => e
1342
+ puts "Exception to obtain access token #{e.response_body}"
1343
+ # Optional manage exception in access token flow
1344
+ return
1345
+ end
1346
+
1347
+ # create an instance of the API class
1348
+ api_instance = Wire4Client::PuntosDeVentaCoDiApi.new
1349
+
1350
+ # build body with info (check references for more info, types, required fields)
1351
+ company_id = COMPANY_ID
1352
+ body = Wire4Client::SalesPointRequest.new
1353
+ body.name = "Taqueria Sur, caja 1"
1354
+ body.access_ip = "189.180.255.229"
1355
+ body.notifications_url = "https://webhook.site/3e32e1c4-1346-4f5a-92d5-2a921c5c85df"
1356
+ body.account = "044680035044988526"
1357
+
1358
+ begin
1359
+ # Call the API
1360
+ response = api_instance.create_sales_point(authorization, company_id, body)
1361
+ p response
1362
+ rescue Wire4Client::ApiError => e
1363
+ puts "Exception when calling the API: #{e.response_body}"
1364
+ # Optional manage exception in call API
1365
+ return
1366
+ end
1367
+ end
1368
+
1369
+ def test_obtain_sale_points
1370
+ omit('Reason')
1371
+ # Create the authenticator to obtain access token
1372
+ # The token URL and Service URL are defined for this environment enum value.
1373
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1374
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1375
+
1376
+ begin
1377
+ # Obtain an access token use application flow and scope "codi_general" and add to request
1378
+ oauth_wire4.config_default_api_client
1379
+ authorization = oauth_wire4.obtain_access_token_app('codi_general')
1380
+ rescue Wire4Client::ApiError => e
1381
+ puts "Exception to obtain access token #{e.response_body}"
1382
+ # Optional manage exception in access token flow
1383
+ return
1384
+ end
1385
+
1386
+ # create an instance of the API class
1387
+ api_instance = Wire4Client::PuntosDeVentaCoDiApi.new
1388
+
1389
+ # build body with info (check references for more info, types, required fields)
1390
+ company_id = COMPANY_ID
1391
+
1392
+ begin
1393
+ # Call the API
1394
+ response = api_instance.obtain_sale_points(authorization, company_id)
1395
+ p response
1396
+ rescue Wire4Client::ApiError => e
1397
+ puts "Exception when calling the API: #{e.response_body}"
1398
+ # Optional manage exception in call API
1399
+ return
1400
+ end
1401
+ end
1402
+
1403
+ SALES_POINT_ID = "465ffc2c-10b5-4475-8d64-bc58e4ff098d"
1404
+ SALES_POINT_KEY = "097db4157b74619b88f40550e7c1ee@develop.wire4.mx"
1405
+ SALES_POINT_SECRET = "b722b8c8fc24d4bae0b1cd41b4c6af"
1406
+
1407
+ def test_generate_codi_code_qr
1408
+ omit('Reason')
1409
+ # Create the authenticator to obtain access token
1410
+ # The token URL and Service URL are defined for this environment enum value.
1411
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1412
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1413
+
1414
+ begin
1415
+ # Obtain an access token use application flow and scope "codi_admin" and add to request
1416
+ oauth_wire4.config_default_api_client
1417
+ authorization = oauth_wire4.obtain_access_token_app_user(SALES_POINT_KEY, SALES_POINT_SECRET, 'codi_admin')
1418
+ rescue Wire4Client::ApiError => e
1419
+ puts "Exception to obtain access token #{e.response_body}"
1420
+ # Optional manage exception in access token flow
1421
+ return
1422
+ end
1423
+
1424
+ # create an instance of the API class
1425
+ api_instance = Wire4Client::PeticionesDePagoPorCoDiApi.new
1426
+
1427
+ # build body with info (check references for more info, types, required fields)
1428
+ sales_point_id = SALES_POINT_ID
1429
+ body = Wire4Client::CodiCodeRequestDTO.new
1430
+ body.amount = 178.8
1431
+ body.concept = "consumo saintiago"
1432
+ body.order_id = "b4408b4d-17a0-4d39-85f2-f3da1e2825e9"
1433
+ body.due_date = "2020-08-25T13:45:00"
1434
+ body.type = "QR_CODE"
1435
+
1436
+ begin
1437
+ # Call the API
1438
+ response = api_instance.generate_codi_code_qr(authorization, body, sales_point_id)
1439
+ p response
1440
+ rescue Wire4Client::ApiError => e
1441
+ puts "Exception when calling the API: #{e.response_body}"
1442
+ # Optional manage exception in call API
1443
+ return
1444
+ end
1445
+ end
1446
+
1447
+ ORDER_ID = "b4408b4d-17a0-4d39-85f2-f3da1e2825e9"
1448
+
1449
+ #noinspection RubyInstanceMethodNamingConvention
1450
+ def test_consult_codi_request_by_order_id
1451
+ omit('Reason')
1452
+ # Create the authenticator to obtain access token
1453
+ # The token URL and Service URL are defined for this environment enum value.
1454
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1455
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1456
+
1457
+ begin
1458
+ # Obtain an access token use application flow and scope "codi_admin" and add to request
1459
+ oauth_wire4.config_default_api_client
1460
+ authorization = oauth_wire4.obtain_access_token_app_user(SALES_POINT_KEY, SALES_POINT_SECRET, 'codi_admin')
1461
+ rescue Wire4Client::ApiError => e
1462
+ puts "Exception to obtain access token #{e.response_body}"
1463
+ # Optional manage exception in access token flow
1464
+ return
1465
+ end
1466
+
1467
+ # create an instance of the API class
1468
+ api_instance = Wire4Client::PeticionesDePagoPorCoDiApi.new
1469
+
1470
+ # build body with info (check references for more info, types, required fields)
1471
+ sales_point_id = SALES_POINT_ID # Sales point identifier
1472
+ order_id = ORDER_ID # Order identifier
1473
+
1474
+ begin
1475
+ # Call the API
1476
+ response = api_instance.consult_codi_request_by_order_id(authorization, order_id, sales_point_id)
1477
+ p response
1478
+ rescue Wire4Client::ApiError => e
1479
+ puts "Exception when calling the API: #{e.response_body}"
1480
+ # Optional manage exception in call API
1481
+ return
1482
+ end
1483
+ end
1484
+
1485
+ def test_consult_codi_operations
1486
+ omit('Reason')
1487
+ # Create the authenticator to obtain access token
1488
+ # The token URL and Service URL are defined for this environment enum value.
1489
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1490
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1491
+
1492
+ begin
1493
+ # Obtain an access token use application flow and scope "codi_report" and add to request
1494
+ oauth_wire4.config_default_api_client
1495
+ authorization = oauth_wire4.obtain_access_token_app_user(SALES_POINT_KEY, SALES_POINT_SECRET, 'codi_report')
1496
+ rescue Wire4Client::ApiError => e
1497
+ puts "Exception to obtain access token #{e.response_body}"
1498
+ # Optional manage exception in access token flow
1499
+ return
1500
+ end
1501
+
1502
+ # create an instance of the API class
1503
+ api_instance = Wire4Client::OperacionesCoDiApi.new
1504
+
1505
+ # build body with info (check references for more info, types, required fields)
1506
+ company_id = COMPANY_ID # Company identifier
1507
+ sales_point_id = SALES_POINT_ID # Sales point identifier
1508
+
1509
+ body = Wire4Client::CodiOperationsFiltersRequestDTO.new
1510
+ # All filters options are optional
1511
+ # order_id,
1512
+ # operation_date_from, operation_date_to,
1513
+ # request_date_from, request_date_to,
1514
+ # status (RECEIVED, COMPLETED, CANCELLED),
1515
+ # amount_from, amount_to
1516
+ body.order_id = ORDER_ID
1517
+
1518
+ begin
1519
+ # Call the API
1520
+ # consult_codi_operations(authorization, company_id: company_id, sales_point_id: sales_point_id,
1521
+ # page: "0", size: "20")
1522
+ # With filters:
1523
+ # consult_codi_operations(authorization, company_id: company_id, sales_point_id: sales_point_id,
1524
+ # page: "0", size: "20", request_filters: body)
1525
+ response = api_instance.consult_codi_operations(authorization, company_id: company_id, sales_point_id: sales_point_id,
1526
+ page: "0", size: "20", request_filters: body)
1527
+ p response
1528
+ rescue Wire4Client::ApiError => e
1529
+ puts "Exception when calling the API: #{e.response_body}"
1530
+ # Optional manage exception in call API
1531
+ return
1532
+ end
1533
+ end
1534
+
1535
+ ACCESS_KEY = "AccessK3y!" #"YOUR_ACCESS_KEY_HERE"
1536
+ def test_obtain_contract_details
1537
+ omit('Reason')
1538
+ # Create the authenticator to obtain access token
1539
+ # The token URL and Service URL are defined for this environment enum value.
1540
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1541
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1542
+
1543
+ begin
1544
+ # Obtain an access token use application flow and scope "general" and add to request
1545
+ oauth_wire4.config_default_api_client
1546
+ authorization = oauth_wire4.obtain_access_token_app('general')
1547
+ rescue Wire4Client::ApiError => e
1548
+ puts "Exception to obtain access token #{e.response_body}"
1549
+ # Optional manage exception in access token flow
1550
+ return
1551
+ end
1552
+
1553
+ # create an instance of the API class
1554
+ api_instance = Wire4Client::ContractsDetailsApi.new
1555
+
1556
+ # build body with info (check references for more info, types, required fields)
1557
+ x_access_key = ACCESS_KEY
1558
+ body = Wire4Client::ContractDetailRequest.new
1559
+ body.contract = "1234567"
1560
+ body.user_name = "amolina"
1561
+ body.password = "whatever"
1562
+ body.token_code = "258963"
1563
+
1564
+ begin
1565
+ # Call the API
1566
+ response = api_instance.obtain_contract_details(authorization, x_access_key, body)
1567
+ p response
1568
+ rescue Wire4Client::ApiError => e
1569
+ puts "Exception when calling the API: #{e.response_body}"
1570
+ # Optional manage exception in call API
1571
+ return
1572
+ end
1573
+ end
1574
+
1575
+ def test_create_authorization
1576
+ omit('Reason')
1577
+ # Create the authenticator to obtain access token
1578
+ # The token URL and Service URL are defined for this environment enum value.
1579
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1580
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1581
+
1582
+ begin
1583
+ # Obtain an access token use application flow and scope "general" and add to request
1584
+ oauth_wire4.config_default_api_client
1585
+ authorization = oauth_wire4.obtain_access_token_app('general')
1586
+ rescue Wire4Client::ApiError => e
1587
+ puts "Exception to obtain access token #{e.response_body}"
1588
+ # Optional manage exception in access token flow
1589
+ return
1590
+ end
1591
+
1592
+ # create an instance of the API class
1593
+ api_instance = Wire4Client::ContractsDetailsApi.new
1594
+
1595
+ # build body with info (check references for more info, types, required fields)
1596
+ body = Wire4Client::PreMonexAuthorization.new
1597
+ body.return_url = "https://your-app-url.mx/return"
1598
+ body.cancel_return_url = "https://your-app-url.mx/cancel"
1599
+ body.rfc = "TACO890101LO0"
1600
+ body.business_name = "Compa Tacos"
1601
+
1602
+ begin
1603
+ # Call the API
1604
+ response = api_instance.create_authorization(authorization, body)
1605
+ p response
1606
+ rescue Wire4Client::ApiError => e
1607
+ puts "Exception when calling the API: #{e.response_body}"
1608
+ # Optional manage exception in call API
1609
+ return
1610
+ end
1611
+ end
1612
+
1613
+ REQUEST_ID = "17fa79db-759f-4105-bc47-688fed75ddac"
1614
+
1615
+ def test_obtain_authorized_users
1616
+ omit('Reason')
1617
+ # Create the authenticator to obtain access token
1618
+ # The token URL and Service URL are defined for this environment enum value.
1619
+ # e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
1620
+ oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
1621
+
1622
+ begin
1623
+ # Obtain an access token use application flow and scope "general" and add to request
1624
+ oauth_wire4.config_default_api_client
1625
+ authorization = oauth_wire4.obtain_access_token_app('general')
1626
+ rescue Wire4Client::ApiError => e
1627
+ puts "Exception to obtain access token #{e.response_body}"
1628
+ # Optional manage exception in access token flow
1629
+ return
1630
+ end
1631
+
1632
+ # create an instance of the API class
1633
+ api_instance = Wire4Client::ContractsDetailsApi.new
1634
+
1635
+ # build body with info (check references for more info, types, required fields)
1636
+ x_access_key = ACCESS_KEY; # This ACCESS_KEY is provider from Wire4, contact support
1637
+ request_id = REQUEST_ID
1638
+
1639
+ begin
1640
+ # Call the API
1641
+ response = api_instance.obtain_authorized_users(authorization, x_access_key, request_id)
1642
+ p response
1643
+ rescue Wire4Client::ApiError => e
1644
+ puts "Exception when calling the API: #{e.response_body}"
1645
+ # Optional manage exception in call API
1646
+ return
1647
+ end
1648
+ end
1649
+ end