wire4_auth 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +51 -0
- data/lib/wire4_auth.rb +32 -0
- data/lib/wire4_auth/auth/oauth_wire4.rb +169 -0
- data/lib/wire4_auth/core/cached_token.rb +38 -0
- data/lib/wire4_auth/core/environment_enum.rb +42 -0
- data/lib/wire4_auth/testing.rb +1176 -0
- data/lib/wire4_auth/version.rb +19 -0
- data/lib/wire4_auth/webhook_verification_signature/utils_compute.rb +28 -0
- data/wire4_auth.gemspec +42 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4fd2430cb43f273cdee5c8af44d37da774c6c6b30d9ea219f19ed5eeb34475b1
|
4
|
+
data.tar.gz: 9408b9d5f8a8ed9121dbbb841e51fc8cbe1fbf1c0d7817168eadbb0ade5b3516
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d143702786369d5217e53f2dfa9d0bee468477b940f3e02cc915bdc4c83a6c9f770465f87de471491c85ccee302901708ff3db33cad05ae5e7504c7901cff8d
|
7
|
+
data.tar.gz: 2cd2d6d6ef043213af030b574ed6bd977236572cb5941e7aca6b1883a79fbe8b8e2ddb2b2f6c94d6e78536155d1ddf2e780c9a5cdfd69678316e455a533d5a9b
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wire4_auth (1.0.3)
|
5
|
+
oauth2 (~> 1.4, >= 1.4.3)
|
6
|
+
wire4_client (~> 1.0, >= 1.0.3)
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: /Users/saintiago/tcpip/git-repositories/speiok/wire4-api-sdk-ruby/sdk-client
|
10
|
+
specs:
|
11
|
+
wire4_client (1.0.3)
|
12
|
+
json (~> 2.1, >= 2.1.0)
|
13
|
+
typhoeus (~> 1.0, >= 1.0.1)
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: https://rubygems.org/
|
17
|
+
specs:
|
18
|
+
ethon (0.12.0)
|
19
|
+
ffi (>= 1.3.0)
|
20
|
+
faraday (1.0.0)
|
21
|
+
multipart-post (>= 1.2, < 3)
|
22
|
+
ffi (1.12.1)
|
23
|
+
json (2.3.0)
|
24
|
+
jwt (2.2.1)
|
25
|
+
multi_json (1.14.1)
|
26
|
+
multi_xml (0.6.0)
|
27
|
+
multipart-post (2.1.1)
|
28
|
+
oauth2 (1.4.3)
|
29
|
+
faraday (>= 0.8, < 2.0)
|
30
|
+
jwt (>= 1.0, < 3.0)
|
31
|
+
multi_json (~> 1.3)
|
32
|
+
multi_xml (~> 0.5)
|
33
|
+
rack (>= 1.2, < 3)
|
34
|
+
power_assert (1.1.3)
|
35
|
+
rack (2.1.2)
|
36
|
+
test-unit (3.3.5)
|
37
|
+
power_assert
|
38
|
+
typhoeus (1.3.1)
|
39
|
+
ethon (>= 0.9.0)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
oauth2 (~> 1.4.3)
|
46
|
+
test-unit (~> 3.3, >= 3.3.5)
|
47
|
+
wire4_auth!
|
48
|
+
wire4_client (~> 1.0.3)!
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
1.17.3
|
data/lib/wire4_auth.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# COPYRIGHT © 2017. TCPIP.
|
4
|
+
# PATENT PENDING. ALL RIGHTS RESERVED.
|
5
|
+
# SPEI GATEWAY IS REGISTERED TRADEMARKS OF TCPIP.
|
6
|
+
#
|
7
|
+
# This software is confidential and proprietary information of TCPIP.
|
8
|
+
# You shall not disclose such Confidential Information and shall use it only
|
9
|
+
# in accordance with the company policy.
|
10
|
+
|
11
|
+
=begin
|
12
|
+
#Wire4Auth
|
13
|
+
|
14
|
+
Fecha de creación: 11 de diciembre, 2019
|
15
|
+
author: Saintiago García
|
16
|
+
version: 1.0
|
17
|
+
=end
|
18
|
+
|
19
|
+
require 'wire4_auth/version'
|
20
|
+
|
21
|
+
require 'wire4_auth/auth/oauth_wire4'
|
22
|
+
|
23
|
+
require 'wire4_auth/core/cached_token'
|
24
|
+
require 'wire4_auth/core/environment_enum'
|
25
|
+
|
26
|
+
require 'wire4_auth/webhook_verification_signature/utils_compute'
|
27
|
+
|
28
|
+
module Wire4Auth
|
29
|
+
class << self
|
30
|
+
# Nothing more to do now
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# COPYRIGHT © 2017. TCPIP.
|
4
|
+
# PATENT PENDING. ALL RIGHTS RESERVED.
|
5
|
+
# SPEI GATEWAY IS REGISTERED TRADEMARKS OF TCPIP.
|
6
|
+
#
|
7
|
+
# This software is confidential and proprietary information of TCPIP.
|
8
|
+
# You shall not disclose such Confidential Information and shall use it only
|
9
|
+
# in accordance with the company policy.
|
10
|
+
|
11
|
+
=begin
|
12
|
+
#Wire4Auth
|
13
|
+
|
14
|
+
Fecha de creación: 11 de diciembre, 2019
|
15
|
+
author: Saintiago García
|
16
|
+
version: 1.0
|
17
|
+
=end
|
18
|
+
|
19
|
+
require 'oauth2'
|
20
|
+
require 'wire4_client'
|
21
|
+
require 'wire4_auth/core/cached_token'
|
22
|
+
require 'wire4_auth/core/environment_enum'
|
23
|
+
|
24
|
+
module Wire4Auth
|
25
|
+
class OAuthWire4
|
26
|
+
|
27
|
+
MAX_APP_USER_SIZE_CACHED = 100
|
28
|
+
|
29
|
+
# accessor get method
|
30
|
+
attr_reader :client_id
|
31
|
+
|
32
|
+
# accessor get method
|
33
|
+
attr_reader :client_secret
|
34
|
+
|
35
|
+
# accessor get method
|
36
|
+
attr_reader :environment
|
37
|
+
|
38
|
+
def initialize(client_id, client_secret, environment)
|
39
|
+
|
40
|
+
raise 'Not EnvironmentEnum class instance' unless environment.is_a? Wire4Auth::EnvironmentEnum
|
41
|
+
|
42
|
+
@client_id = client_id
|
43
|
+
@client_secret = client_secret
|
44
|
+
@environment = environment
|
45
|
+
|
46
|
+
@token_cached_app = Wire4Auth::CachedToken.new(nil, nil, nil)
|
47
|
+
@tokens_cached_app_user = {}
|
48
|
+
end
|
49
|
+
|
50
|
+
def obtain_access_token_app(scope = "general")
|
51
|
+
|
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
|
+
end
|
60
|
+
|
61
|
+
begin
|
62
|
+
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
|
65
|
+
|
66
|
+
return format_to_header(access_token.token)
|
67
|
+
rescue OAuth2::Error => e
|
68
|
+
raise Wire4Client::ApiError.new(:code => e.code,
|
69
|
+
:message => e.description)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def obtain_access_token_app_user(user_key, secret_key, scope = "spei_admin")
|
74
|
+
|
75
|
+
key_search = user_key + scope
|
76
|
+
token_cached = @tokens_cached_app_user[key_search]
|
77
|
+
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?
|
81
|
+
|
82
|
+
return format_to_header(token_cached.access_token.token)
|
83
|
+
end
|
84
|
+
|
85
|
+
begin
|
86
|
+
client = OAuth2::Client.new(@client_id, @client_secret, :token_url => @environment.token_url)
|
87
|
+
access_token = client.get_token({ :grant_type => "password", :scope => scope,
|
88
|
+
:username => user_key, :password => secret_key })
|
89
|
+
|
90
|
+
if @tokens_cached_app_user.length + 1 > MAX_APP_USER_SIZE_CACHED
|
91
|
+
@tokens_cached_app_user.each_key do |key|
|
92
|
+
@tokens_cached_app_user.delete(key)
|
93
|
+
break
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
@tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(user_key, secret_key, access_token)
|
98
|
+
|
99
|
+
return format_to_header(access_token.token)
|
100
|
+
rescue OAuth2::Error => e
|
101
|
+
raise Wire4Client::ApiError.new(:code => e.code,
|
102
|
+
:message => e.description)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def regenerate_access_token_app(scope = "general")
|
107
|
+
|
108
|
+
begin
|
109
|
+
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
|
112
|
+
|
113
|
+
return format_to_header(access_token.token)
|
114
|
+
rescue OAuth2::Error => e
|
115
|
+
raise Wire4Client::ApiError.new(:code => e.code,
|
116
|
+
:message => e.description)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def regenerate_access_token_app_user(user_key, secret_key, scope = "spei_admin")
|
121
|
+
|
122
|
+
begin
|
123
|
+
client = OAuth2::Client.new(@client_id, @client_secret, :token_url => @environment.token_url)
|
124
|
+
access_token = client.get_token({ :grant_type => "password", :scope => scope,
|
125
|
+
:username => user_key, :password => secret_key })
|
126
|
+
|
127
|
+
key_search = user_key + scope
|
128
|
+
token_cached = @tokens_cached_app_user[key_search]
|
129
|
+
if token_cached.nil? and @tokens_cached_app_user.length + 1 > MAX_APP_USER_SIZE_CACHED
|
130
|
+
@tokens_cached_app_user.each_key do |key|
|
131
|
+
@tokens_cached_app_user.delete(key)
|
132
|
+
break
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
@tokens_cached_app_user[key_search] = Wire4Auth::CachedToken.new(user_key, secret_key, access_token)
|
137
|
+
|
138
|
+
return format_to_header(access_token.token)
|
139
|
+
rescue OAuth2::Error => e
|
140
|
+
raise Wire4Client::ApiError.new(:code => e.code,
|
141
|
+
:message => e.description)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def config_default_api_client
|
146
|
+
# Setup authorization
|
147
|
+
Wire4Client.configure do |config|
|
148
|
+
# Configure OAuth2 access token for authorization
|
149
|
+
config.host = @environment.service_url
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
private
|
154
|
+
|
155
|
+
def is_expire(expires_at)
|
156
|
+
|
157
|
+
time = Time.at(expires_at)
|
158
|
+
# Get current time using the time zone
|
159
|
+
now = Time.now - 5 * 60 # minus 5 minutes
|
160
|
+
|
161
|
+
time > now
|
162
|
+
end
|
163
|
+
|
164
|
+
def format_to_header(token)
|
165
|
+
|
166
|
+
"Bearer " + token
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# COPYRIGHT © 2017. TCPIP.
|
4
|
+
# PATENT PENDING. ALL RIGHTS RESERVED.
|
5
|
+
# SPEI GATEWAY IS REGISTERED TRADEMARKS OF TCPIP.
|
6
|
+
#
|
7
|
+
# This software is confidential and proprietary information of TCPIP.
|
8
|
+
# You shall not disclose such Confidential Information and shall use it only
|
9
|
+
# in accordance with the company policy.
|
10
|
+
|
11
|
+
=begin
|
12
|
+
#Wire4Auth
|
13
|
+
|
14
|
+
Fecha de creación: 13 de diciembre, 2019
|
15
|
+
author: Saintiago García
|
16
|
+
version: 1.0
|
17
|
+
=end
|
18
|
+
|
19
|
+
require 'oauth2'
|
20
|
+
|
21
|
+
module Wire4Auth
|
22
|
+
class CachedToken
|
23
|
+
attr_reader :user_key
|
24
|
+
|
25
|
+
attr_reader :user_secret
|
26
|
+
|
27
|
+
attr_accessor :access_token
|
28
|
+
|
29
|
+
def initialize(user_key, user_secret, access_token)
|
30
|
+
|
31
|
+
raise 'Not OAuth2::AccessToken class instance' unless access_token.nil? or access_token.is_a? OAuth2::AccessToken
|
32
|
+
|
33
|
+
@user_key = user_key
|
34
|
+
@user_secret = user_secret
|
35
|
+
@access_token = access_token
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# COPYRIGHT © 2017. TCPIP.
|
4
|
+
# PATENT PENDING. ALL RIGHTS RESERVED.
|
5
|
+
# SPEI GATEWAY IS REGISTERED TRADEMARKS OF TCPIP.
|
6
|
+
#
|
7
|
+
# This software is confidential and proprietary information of TCPIP.
|
8
|
+
# You shall not disclose such Confidential Information and shall use it only
|
9
|
+
# in accordance with the company policy.
|
10
|
+
|
11
|
+
=begin
|
12
|
+
#Wire4Auth
|
13
|
+
|
14
|
+
Fecha de creación: 11 de diciembre, 2019
|
15
|
+
author: Saintiago García
|
16
|
+
version: 1.0
|
17
|
+
=end
|
18
|
+
|
19
|
+
module Wire4Auth
|
20
|
+
class EnvironmentEnum
|
21
|
+
|
22
|
+
attr_reader :token_url
|
23
|
+
|
24
|
+
attr_reader :service_url
|
25
|
+
|
26
|
+
def initialize(token_url, service_url)
|
27
|
+
@token_url = token_url
|
28
|
+
@service_url = service_url
|
29
|
+
end
|
30
|
+
|
31
|
+
SANDBOX = new("https://sandbox-api.wire4.mx/token", "sandbox-api.wire4.mx")
|
32
|
+
|
33
|
+
DEVELOPMENT = new('https://development-api.wire4.mx/token', 'development-api.wire4.mx')
|
34
|
+
|
35
|
+
PRODUCTION = new("https://api.wire4.mx/token", "api.wire4.mx")
|
36
|
+
|
37
|
+
class << self
|
38
|
+
private :new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,1176 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
|
4
|
+
# COPYRIGHT © 2017. TCPIP.
|
5
|
+
# PATENT PENDING. ALL RIGHTS RESERVED.
|
6
|
+
# SPEI GATEWAY IS REGISTERED TRADEMARKS OF TCPIP.
|
7
|
+
#
|
8
|
+
# This software is confidential and proprietary information of TCPIP.
|
9
|
+
# You shall not disclose such Confidential Information and shall use it only
|
10
|
+
# in accordance with the company policy.
|
11
|
+
|
12
|
+
=begin
|
13
|
+
#Wire4Auth
|
14
|
+
|
15
|
+
Fecha de creación: 11 de diciembre, 2019
|
16
|
+
author: Saintiago García
|
17
|
+
version: 1.0
|
18
|
+
=end
|
19
|
+
|
20
|
+
require 'test/unit'
|
21
|
+
require 'wire4_auth/auth/oauth_wire4'
|
22
|
+
require 'wire4_auth/webhook_verification_signature/utils_compute'
|
23
|
+
require 'wire4_client'
|
24
|
+
|
25
|
+
#noinspection RubyTooManyMethodsInspection
|
26
|
+
class Wire4ExamplesTest < Test::Unit::TestCase
|
27
|
+
|
28
|
+
CLIENT_ID = "FxUWmqYGZuv8O1qjxstvIyJothMa"
|
29
|
+
|
30
|
+
CLIENT_SECRET = "kjwbkrPVgXsnaUGzthj55dsFhx4a"
|
31
|
+
|
32
|
+
USER_KEY = "071e2b59b354186b3a0158de493536@sandbox.wire4.mx"
|
33
|
+
|
34
|
+
SECRET_KEY = "0d1e33e94604f01b4e00d2fcb6b48f"
|
35
|
+
|
36
|
+
SUBSCRIPTION = "f1504fea-3a8f-475a-a50a-90d3c40efc59"
|
37
|
+
|
38
|
+
def test_send_contact
|
39
|
+
omit('Reason')
|
40
|
+
# Create the authenticator to obtain access token
|
41
|
+
# The token URL and Service URL are defined for this environment enum value.
|
42
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
43
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
44
|
+
|
45
|
+
begin
|
46
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
47
|
+
oauth_wire4.config_default_api_client
|
48
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
49
|
+
rescue Wire4Client::ApiError => e
|
50
|
+
puts "Exception to obtain access token #{e}"
|
51
|
+
# Optional manage exception in access token flow
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
# create an instance of the API class
|
56
|
+
api_instance = Wire4Client::ContactoApi.new
|
57
|
+
|
58
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
59
|
+
body = Wire4Client::ContactRequest.new
|
60
|
+
body.address = "Calle Falsa 123, Col Fantasía"
|
61
|
+
body.company = "Compu Mundo Hiper Mega Red"
|
62
|
+
body.contact_person = "Homer J Simpson"
|
63
|
+
body.email = "homer.simpson@compumundohipermegared.com"
|
64
|
+
body.phone_number = "4422102030"
|
65
|
+
|
66
|
+
begin
|
67
|
+
# Call the API
|
68
|
+
response = api_instance.send_contact_using_post_with_http_info(authorization, body)
|
69
|
+
p response
|
70
|
+
rescue Wire4Client::ApiError => e
|
71
|
+
puts "Exception to obtain access token #{e}"
|
72
|
+
# Optional manage exception in access token flow
|
73
|
+
return
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_obtain_cep
|
78
|
+
omit('Reason')
|
79
|
+
# Create the authenticator to obtain access token
|
80
|
+
# The token URL and Service URL are defined for this environment enum value.
|
81
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
82
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
83
|
+
|
84
|
+
begin
|
85
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
86
|
+
oauth_wire4.config_default_api_client
|
87
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
88
|
+
rescue Wire4Client::ApiError => e
|
89
|
+
puts "Exception to obtain access token #{e}"
|
90
|
+
# Optional manage exception in access token flow
|
91
|
+
return
|
92
|
+
end
|
93
|
+
|
94
|
+
# create an instance of the API class
|
95
|
+
api_instance = Wire4Client::ComprobanteElectrnicoDePagoCEPApi.new
|
96
|
+
|
97
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
98
|
+
cep_data = Wire4Client::CepSearchBanxico.new # CepSearchBanxico | Información para buscar un CEP
|
99
|
+
cep_data.amount = 8963.25
|
100
|
+
cep_data.beneficiary_account = '072680004657656853'
|
101
|
+
cep_data.beneficiary_bank_key = '40072'
|
102
|
+
cep_data.clave_rastreo = '58735618'
|
103
|
+
cep_data.operation_date = '05-12-2018'
|
104
|
+
cep_data.reference = '1122334'
|
105
|
+
cep_data.sender_account = '112680000156896531'
|
106
|
+
cep_data.sender_bank_key = '40112'
|
107
|
+
|
108
|
+
begin
|
109
|
+
# Call the API
|
110
|
+
response = api_instance.obtain_transaction_cep_using_post(authorization, cep_data)
|
111
|
+
p response
|
112
|
+
rescue Wire4Client::ApiError => e
|
113
|
+
puts "Exception when calling the API: #{e}"
|
114
|
+
# Optional manage exception in call API
|
115
|
+
return
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_make_pre_subscription
|
120
|
+
omit('Reason')
|
121
|
+
# Create the authenticator to obtain access token
|
122
|
+
# The token URL and Service URL are defined for this environment enum value.
|
123
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
124
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
125
|
+
|
126
|
+
begin
|
127
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
128
|
+
oauth_wire4.config_default_api_client
|
129
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
130
|
+
rescue Wire4Client::ApiError => e
|
131
|
+
puts "Exception to obtain access token #{e}"
|
132
|
+
# Optional manage exception in access token flow
|
133
|
+
return
|
134
|
+
end
|
135
|
+
|
136
|
+
# create an instance of the API class
|
137
|
+
api_instance = Wire4Client::SuscripcionesApi.new
|
138
|
+
|
139
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
140
|
+
body = Wire4Client::PreEnrollmentData.new
|
141
|
+
body.cancel_return_url = "https://your-app-url.mx/return"
|
142
|
+
body.return_url = "https://your-app-url.mx/cancel"
|
143
|
+
|
144
|
+
begin
|
145
|
+
# Call the API
|
146
|
+
response = api_instance.pre_enrollment_monex_user_using_post(authorization, body)
|
147
|
+
p response
|
148
|
+
rescue Wire4Client::ApiError => e
|
149
|
+
puts "Exception when calling the API: #{e}"
|
150
|
+
# Optional manage exception in call API
|
151
|
+
return
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_delete_pre_subscription
|
156
|
+
omit('Reason')
|
157
|
+
# Create the authenticator to obtain access token
|
158
|
+
# The token URL and Service URL are defined for this environment enum value.
|
159
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
160
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
161
|
+
|
162
|
+
begin
|
163
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
164
|
+
oauth_wire4.config_default_api_client
|
165
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
166
|
+
rescue Wire4Client::ApiError => e
|
167
|
+
puts "Exception to obtain access token #{e}"
|
168
|
+
# Optional manage exception in access token flow
|
169
|
+
return
|
170
|
+
end
|
171
|
+
|
172
|
+
# create an instance of the API class
|
173
|
+
api_instance = Wire4Client::SuscripcionesApi.new
|
174
|
+
|
175
|
+
# build body with info (check references for more info, types, required fields)
|
176
|
+
subscription = "55af515a-43ec-4537-96a4-489d1deef127"
|
177
|
+
|
178
|
+
begin
|
179
|
+
# Call the API
|
180
|
+
response = api_instance.remove_subscription_pending_status_using_delete_with_http_info(authorization, subscription)
|
181
|
+
p response
|
182
|
+
rescue Wire4Client::ApiError => e
|
183
|
+
puts "Exception when calling the API: #{e}"
|
184
|
+
# Optional manage exception in call API
|
185
|
+
return
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
#noinspection RubyLocalVariableNamingConvention
|
190
|
+
def test_delete_subscription
|
191
|
+
omit('Reason')
|
192
|
+
subscription_to_remove_user_key = "e7446202e95421dbb3c1b914e15c74@sandbox.wire4.mx"
|
193
|
+
subscription_to_remove_user_secret = "8617fa525ca4140b545b66c5adcbb1"
|
194
|
+
|
195
|
+
# Create the authenticator to obtain access token
|
196
|
+
# The token URL and Service URL are defined for this environment enum value.
|
197
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
198
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
199
|
+
|
200
|
+
begin
|
201
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
202
|
+
oauth_wire4.config_default_api_client
|
203
|
+
authorization = oauth_wire4.obtain_access_token_app_user(subscription_to_remove_user_key,
|
204
|
+
subscription_to_remove_user_secret, 'spei_admin')
|
205
|
+
rescue Wire4Client::ApiError => e
|
206
|
+
puts "Exception to obtain access token #{e}"
|
207
|
+
# Optional manage exception in access token flow
|
208
|
+
return
|
209
|
+
end
|
210
|
+
|
211
|
+
# create an instance of the API class
|
212
|
+
api_instance = Wire4Client::SuscripcionesApi.new
|
213
|
+
|
214
|
+
# build body with info (check references for more info, types, required fields)
|
215
|
+
subscription = "5873240b-cf69-456a-ab5a-88f5e79ab4b8"
|
216
|
+
|
217
|
+
begin
|
218
|
+
# Call the API
|
219
|
+
response = api_instance.remove_enrollment_user_using_delete_with_http_info(authorization, subscription)
|
220
|
+
p response
|
221
|
+
rescue Wire4Client::ApiError => e
|
222
|
+
puts "Exception when calling the API: #{e}"
|
223
|
+
# Optional manage exception in call API
|
224
|
+
return
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_obtain_relationships
|
229
|
+
omit('Reason')
|
230
|
+
# Create the authenticator to obtain access token
|
231
|
+
# The token URL and Service URL are defined for this environment enum value.
|
232
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
233
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
234
|
+
|
235
|
+
begin
|
236
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
237
|
+
oauth_wire4.config_default_api_client
|
238
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
239
|
+
rescue Wire4Client::ApiError => e
|
240
|
+
puts "Exception to obtain access token #{e}"
|
241
|
+
# Optional manage exception in access token flow
|
242
|
+
return
|
243
|
+
end
|
244
|
+
|
245
|
+
# create an instance of the API class
|
246
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
|
247
|
+
|
248
|
+
# build body with info (check references for more info, types, required fields)
|
249
|
+
subscription = SUBSCRIPTION
|
250
|
+
|
251
|
+
begin
|
252
|
+
# Call the API
|
253
|
+
response = api_instance.get_available_relationships_monex_using_get(authorization, subscription)
|
254
|
+
p response
|
255
|
+
rescue Wire4Client::ApiError => e
|
256
|
+
puts "Exception when calling the API: #{e}"
|
257
|
+
# Optional manage exception in call API
|
258
|
+
return
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
#noinspection RubyInstanceMethodNamingConvention
|
263
|
+
def test_pre_register_beneficiaries
|
264
|
+
omit('Reason')
|
265
|
+
# Create the authenticator to obtain access token
|
266
|
+
# The token URL and Service URL are defined for this environment enum value.
|
267
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
268
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
269
|
+
|
270
|
+
begin
|
271
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
272
|
+
oauth_wire4.config_default_api_client
|
273
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
274
|
+
rescue Wire4Client::ApiError => e
|
275
|
+
puts "Exception to obtain access token #{e}"
|
276
|
+
# Optional manage exception in access token flow
|
277
|
+
return
|
278
|
+
end
|
279
|
+
|
280
|
+
# create an instance of the API class
|
281
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
|
282
|
+
|
283
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
284
|
+
subscription = SUBSCRIPTION
|
285
|
+
body = Wire4Client::AccountRequest.new
|
286
|
+
body.return_url = "https://your-app-url.mx/return"
|
287
|
+
body.cancel_return_url = "https://your-app-url.mx/cancel"
|
288
|
+
account = Wire4Client::Account.new
|
289
|
+
account.amount_limit = 10000.00
|
290
|
+
account.beneficiary_account = "112680000156896531"
|
291
|
+
account.email = ["beneficiary@wire4.mx"]
|
292
|
+
account.kind_of_relationship = "RECURRENTE"
|
293
|
+
account.numeric_reference_spei = "1234567"
|
294
|
+
account.payment_concept_spei = "concept spei"
|
295
|
+
person = Wire4Client::Person.new
|
296
|
+
person.last_name = "Simpson"
|
297
|
+
person.middle_name = "Jay"
|
298
|
+
person.name = "Bartolomeo"
|
299
|
+
account.person = person
|
300
|
+
account.relationship = "ACREEDOR"
|
301
|
+
account.rfc = "SJBA920125AB1"
|
302
|
+
body.accounts = [account]
|
303
|
+
|
304
|
+
begin
|
305
|
+
# Call the API
|
306
|
+
response = api_instance.pre_register_accounts_using_post(authorization, body, subscription)
|
307
|
+
p response
|
308
|
+
rescue Wire4Client::ApiError => e
|
309
|
+
puts "Exception when calling the API: #{e}"
|
310
|
+
# Optional manage exception in call API
|
311
|
+
return
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
#noinspection RubyInstanceMethodNamingConvention
|
316
|
+
def test_remove_beneficiaries_pending
|
317
|
+
omit('Reason')
|
318
|
+
# Create the authenticator to obtain access token
|
319
|
+
# The token URL and Service URL are defined for this environment enum value.
|
320
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
321
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
322
|
+
|
323
|
+
begin
|
324
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
325
|
+
oauth_wire4.config_default_api_client
|
326
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
327
|
+
rescue Wire4Client::ApiError => e
|
328
|
+
puts "Exception to obtain access token #{e}"
|
329
|
+
# Optional manage exception in access token flow
|
330
|
+
return
|
331
|
+
end
|
332
|
+
|
333
|
+
# create an instance of the API class
|
334
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
|
335
|
+
|
336
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
337
|
+
subscription = SUBSCRIPTION
|
338
|
+
request_id = "b782a20b-d92c-4fd9-a5cc-33a88e9b0a79"
|
339
|
+
|
340
|
+
begin
|
341
|
+
# Call the API
|
342
|
+
response = api_instance.remove_beneficiaries_pending_using_delete_with_http_info(authorization, request_id, subscription)
|
343
|
+
p response
|
344
|
+
rescue Wire4Client::ApiError => e
|
345
|
+
puts "Exception when calling the API: #{e}"
|
346
|
+
# Optional manage exception in call API
|
347
|
+
return
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_obtain_beneficiaries
|
352
|
+
omit('Reason')
|
353
|
+
# Create the authenticator to obtain access token
|
354
|
+
# The token URL and Service URL are defined for this environment enum value.
|
355
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
356
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
357
|
+
|
358
|
+
begin
|
359
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
360
|
+
oauth_wire4.config_default_api_client
|
361
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
362
|
+
rescue Wire4Client::ApiError => e
|
363
|
+
puts "Exception to obtain access token #{e}"
|
364
|
+
# Optional manage exception in access token flow
|
365
|
+
return
|
366
|
+
end
|
367
|
+
|
368
|
+
# create an instance of the API class
|
369
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
|
370
|
+
|
371
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
372
|
+
subscription = SUBSCRIPTION
|
373
|
+
|
374
|
+
begin
|
375
|
+
# Call the API
|
376
|
+
# response = api_instance.get_beneficiaries_for_account_using_get(subscription, rfc: "RFCE010980AR3")
|
377
|
+
# response = api_instance.get_beneficiaries_for_account_using_get(subscription, account: "RFCE010980AR3")
|
378
|
+
# response = api_instance.get_beneficiaries_for_account_using_get(subscription, rfc: "RFCE010980AR3, account: "RFCE010980AR3")
|
379
|
+
response = api_instance.get_beneficiaries_for_account_using_get(authorization, subscription)
|
380
|
+
p response
|
381
|
+
rescue Wire4Client::ApiError => e
|
382
|
+
puts "Exception when calling the API: #{e}"
|
383
|
+
# Optional manage exception in call API
|
384
|
+
return
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
def test_obtain_beneficiaries_by_request_id
|
389
|
+
#omit('Reason')
|
390
|
+
# Create the authenticator to obtain access token
|
391
|
+
# The token URL and Service URL are defined for this environment enum value.
|
392
|
+
# 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)
|
395
|
+
|
396
|
+
begin
|
397
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
398
|
+
oauth_wire4.config_default_api_client
|
399
|
+
authorization = oauth_wire4.obtain_access_token_app_user("0bb13bfb99d461a8a0e18746b25e7d@develop.wire4.mx", "0b6ea839f33467a81631b380d37472", 'spei_admin')
|
400
|
+
# USER_KEY, SECRET_KEY, 'spei_admin')
|
401
|
+
rescue Wire4Client::ApiError => e
|
402
|
+
puts "Exception to obtain access token #{e}"
|
403
|
+
# Optional manage exception in access token flow
|
404
|
+
return
|
405
|
+
end
|
406
|
+
|
407
|
+
# create an instance of the API class
|
408
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
|
409
|
+
|
410
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
411
|
+
subscription = SUBSCRIPTION
|
412
|
+
request_id = ""
|
413
|
+
|
414
|
+
begin
|
415
|
+
# Call the API
|
416
|
+
response = api_instance.get_beneficiaries_by_request_id(authorization, request_id, subscription)
|
417
|
+
p response
|
418
|
+
rescue Wire4Client::ApiError => e
|
419
|
+
puts "Exception when calling the API: #{e}"
|
420
|
+
# Optional manage exception in call API
|
421
|
+
return
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
#noinspection RubyInstanceMethodNamingConvention
|
426
|
+
def test_change_amount_limit_beneficiary
|
427
|
+
omit('Reason')
|
428
|
+
# Create the authenticator to obtain access token
|
429
|
+
# The token URL and Service URL are defined for this environment enum value.
|
430
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
431
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
432
|
+
|
433
|
+
begin
|
434
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
435
|
+
oauth_wire4.config_default_api_client
|
436
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
437
|
+
rescue Wire4Client::ApiError => e
|
438
|
+
puts "Exception to obtain access token #{e}"
|
439
|
+
# Optional manage exception in access token flow
|
440
|
+
return
|
441
|
+
end
|
442
|
+
|
443
|
+
# create an instance of the API class
|
444
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
|
445
|
+
|
446
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
447
|
+
subscription = SUBSCRIPTION
|
448
|
+
account = "112680000156896531"
|
449
|
+
body = Wire4Client::AmountRequest.new
|
450
|
+
body.amount_limit = 20000.00
|
451
|
+
body.currency_code = "MXP"
|
452
|
+
body.previous_amount_limit = 10000.00
|
453
|
+
|
454
|
+
begin
|
455
|
+
# Call the API
|
456
|
+
response = api_instance.update_amount_limit_account_using_put_with_http_info(authorization, account, body, subscription)
|
457
|
+
p response
|
458
|
+
rescue Wire4Client::ApiError => e
|
459
|
+
puts "Exception when calling the API: #{e}"
|
460
|
+
# Optional manage exception in call API
|
461
|
+
return
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
def test_delete_beneficiary
|
466
|
+
# Create the authenticator to obtain access token
|
467
|
+
# The token URL and Service URL are defined for this environment enum value.
|
468
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
469
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
470
|
+
|
471
|
+
begin
|
472
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
473
|
+
oauth_wire4.config_default_api_client
|
474
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
475
|
+
rescue Wire4Client::ApiError => e
|
476
|
+
puts "Exception to obtain access token #{e}"
|
477
|
+
# Optional manage exception in access token flow
|
478
|
+
return
|
479
|
+
end
|
480
|
+
|
481
|
+
# create an instance of the API class
|
482
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPEIApi.new
|
483
|
+
|
484
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
485
|
+
subscription = SUBSCRIPTION
|
486
|
+
account = "112680000156896531"
|
487
|
+
|
488
|
+
begin
|
489
|
+
# Call the API
|
490
|
+
response = api_instance.delete_account_using_delete_with_http_info(authorization, account, subscription)
|
491
|
+
p response
|
492
|
+
rescue Wire4Client::ApiError => e
|
493
|
+
puts "Exception when calling the API: #{e}"
|
494
|
+
# Optional manage exception in call API
|
495
|
+
return
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
def test_obtain_institutions
|
500
|
+
omit('Reason')
|
501
|
+
# Create the authenticator to obtain access token
|
502
|
+
# The token URL and Service URL are defined for this environment enum value.
|
503
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
504
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
505
|
+
|
506
|
+
begin
|
507
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
508
|
+
oauth_wire4.config_default_api_client
|
509
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
510
|
+
rescue Wire4Client::ApiError => e
|
511
|
+
puts "Exception to obtain access token #{e}"
|
512
|
+
# Optional manage exception in access token flow
|
513
|
+
return
|
514
|
+
end
|
515
|
+
|
516
|
+
# create an instance of the API class
|
517
|
+
api_instance = Wire4Client::InstitucionesApi.new
|
518
|
+
|
519
|
+
begin
|
520
|
+
# Call the API
|
521
|
+
response = api_instance.get_all_institutions_using_get(authorization)
|
522
|
+
p response
|
523
|
+
rescue Wire4Client::ApiError => e
|
524
|
+
puts "Exception when calling the API: #{e}"
|
525
|
+
# Optional manage exception in call API
|
526
|
+
return
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
def test_obtain_balance
|
531
|
+
omit('Reason')
|
532
|
+
# Create the authenticator to obtain access token
|
533
|
+
# The token URL and Service URL are defined for this environment enum value.
|
534
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
535
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
536
|
+
|
537
|
+
begin
|
538
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
539
|
+
oauth_wire4.config_default_api_client
|
540
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
541
|
+
rescue Wire4Client::ApiError => e
|
542
|
+
puts "Exception to obtain access token #{e}"
|
543
|
+
# Optional manage exception in access token flow
|
544
|
+
return
|
545
|
+
end
|
546
|
+
|
547
|
+
# create an instance of the API class
|
548
|
+
api_instance = Wire4Client::SaldoApi.new
|
549
|
+
|
550
|
+
# build body with info (check references for more info, types, required fields)
|
551
|
+
subscription = SUBSCRIPTION
|
552
|
+
|
553
|
+
begin
|
554
|
+
# Call the API
|
555
|
+
response = api_instance.get_balance_using_get(authorization, subscription)
|
556
|
+
p response
|
557
|
+
rescue Wire4Client::ApiError => e
|
558
|
+
puts "Exception when calling the API: #{e}"
|
559
|
+
# Optional manage exception in call API
|
560
|
+
return
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
#noinspection RubyInstanceMethodNamingConvention
|
565
|
+
def test_obtain_SPID_classifications
|
566
|
+
omit('Reason')
|
567
|
+
# Create the authenticator to obtain access token
|
568
|
+
# The token URL and Service URL are defined for this environment enum value.
|
569
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
570
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
571
|
+
|
572
|
+
begin
|
573
|
+
# Obtain an access token use application flow and scope "spid_admin" and add to request
|
574
|
+
oauth_wire4.config_default_api_client
|
575
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
|
576
|
+
rescue Wire4Client::ApiError => e
|
577
|
+
puts "Exception to obtain access token #{e}"
|
578
|
+
# Optional manage exception in access token flow
|
579
|
+
return
|
580
|
+
end
|
581
|
+
|
582
|
+
# create an instance of the API class
|
583
|
+
api_instance = Wire4Client::TransferenciasSPIDApi.new
|
584
|
+
|
585
|
+
# build body with info (check references for more info, types, required fields)
|
586
|
+
subscription = SUBSCRIPTION
|
587
|
+
|
588
|
+
begin
|
589
|
+
# Call the API
|
590
|
+
response = api_instance.get_spid_classifications_using_get(authorization, subscription)
|
591
|
+
p response
|
592
|
+
rescue Wire4Client::ApiError => e
|
593
|
+
puts "Exception when calling the API: #{e}"
|
594
|
+
# Optional manage exception in call API
|
595
|
+
return
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
#noinspection RubyInstanceMethodNamingConvention
|
600
|
+
def test_pre_register_beneficiaries_SPID
|
601
|
+
omit('Reason')
|
602
|
+
# Create the authenticator to obtain access token
|
603
|
+
# The token URL and Service URL are defined for this environment enum value.
|
604
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
605
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
606
|
+
|
607
|
+
begin
|
608
|
+
# Obtain an access token use application flow and scope "spid_admin" and add to request
|
609
|
+
oauth_wire4.config_default_api_client
|
610
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
|
611
|
+
rescue Wire4Client::ApiError => e
|
612
|
+
puts "Exception to obtain access token #{e}"
|
613
|
+
# Optional manage exception in access token flow
|
614
|
+
return
|
615
|
+
end
|
616
|
+
|
617
|
+
# create an instance of the API class
|
618
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPIDApi.new
|
619
|
+
|
620
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
621
|
+
subscription = SUBSCRIPTION
|
622
|
+
body = Wire4Client::AccountSpid.new
|
623
|
+
body.return_url = "https://your-app-url.mx/return"
|
624
|
+
body.cancel_return_url = "https://your-app-url.mx/cancel"
|
625
|
+
body.amount_limit = 10000.00
|
626
|
+
body.beneficiary_account = "112680000156896531"
|
627
|
+
body.email = ["beneficiary.spid@wire4.mx"]
|
628
|
+
body.institution = Wire4Client::BeneficiaryInstitution.new(name: "BMONEX")
|
629
|
+
body.kind_of_relationship = "RECURRENTE"
|
630
|
+
body.numeric_reference = "1234567"
|
631
|
+
body.payment_concept = "concept spei"
|
632
|
+
body.relationship = "ACREEDOR"
|
633
|
+
body.rfc = "SJBA920125AB1"
|
634
|
+
|
635
|
+
begin
|
636
|
+
# Call the API
|
637
|
+
response = api_instance.pre_register_accounts_using_post1(authorization, body, subscription)
|
638
|
+
p response
|
639
|
+
rescue Wire4Client::ApiError => e
|
640
|
+
puts "Exception when calling the API: #{e}"
|
641
|
+
# Optional manage exception in call API
|
642
|
+
return
|
643
|
+
end
|
644
|
+
end
|
645
|
+
|
646
|
+
def test_obtain_beneficiaries_spid
|
647
|
+
omit('Reason')
|
648
|
+
# Create the authenticator to obtain access token
|
649
|
+
# The token URL and Service URL are defined for this environment enum value.
|
650
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
651
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
652
|
+
|
653
|
+
begin
|
654
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
655
|
+
oauth_wire4.config_default_api_client
|
656
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
|
657
|
+
rescue Wire4Client::ApiError => e
|
658
|
+
puts "Exception to obtain access token #{e}"
|
659
|
+
# Optional manage exception in access token flow
|
660
|
+
return
|
661
|
+
end
|
662
|
+
|
663
|
+
# create an instance of the API class
|
664
|
+
api_instance = Wire4Client::CuentasDeBeneficiariosSPIDApi.new
|
665
|
+
|
666
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
667
|
+
subscription = SUBSCRIPTION
|
668
|
+
|
669
|
+
begin
|
670
|
+
# Call the API
|
671
|
+
# response = api_instance.get_beneficiaries_for_account_using_get(subscription, rfc: "RFCE010980AR3")
|
672
|
+
# response = api_instance.get_beneficiaries_for_account_using_get(subscription, account: "RFCE010980AR3")
|
673
|
+
# response = api_instance.get_beneficiaries_for_account_using_get(subscription, rfc: "RFCE010980AR3, account: "RFCE010980AR3")
|
674
|
+
response = api_instance.get_spid_beneficiaries_for_account(authorization, subscription)
|
675
|
+
p response
|
676
|
+
rescue Wire4Client::ApiError => e
|
677
|
+
puts "Exception when calling the API: #{e}"
|
678
|
+
# Optional manage exception in call API
|
679
|
+
return
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
def test_get_depositants
|
684
|
+
omit('Reason')
|
685
|
+
# Create the authenticator to obtain access token
|
686
|
+
# The token URL and Service URL are defined for this environment enum value.
|
687
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
688
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
689
|
+
|
690
|
+
begin
|
691
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
692
|
+
oauth_wire4.config_default_api_client
|
693
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
694
|
+
rescue Wire4Client::ApiError => e
|
695
|
+
puts "Exception to obtain access token #{e}"
|
696
|
+
# Optional manage exception in access token flow
|
697
|
+
return
|
698
|
+
end
|
699
|
+
|
700
|
+
# create an instance of the API class
|
701
|
+
api_instance = Wire4Client::DepositantesApi.new
|
702
|
+
|
703
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
704
|
+
subscription = SUBSCRIPTION
|
705
|
+
|
706
|
+
begin
|
707
|
+
# Call the API
|
708
|
+
response = api_instance.get_depositants_using_get(authorization, subscription)
|
709
|
+
p response
|
710
|
+
rescue Wire4Client::ApiError => e
|
711
|
+
puts "Exception when calling the API: #{e}"
|
712
|
+
# Optional manage exception in call API
|
713
|
+
return
|
714
|
+
end
|
715
|
+
end
|
716
|
+
|
717
|
+
def test_register_depositants
|
718
|
+
omit('Reason')
|
719
|
+
# Create the authenticator to obtain access token
|
720
|
+
# The token URL and Service URL are defined for this environment enum value.
|
721
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
722
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
723
|
+
|
724
|
+
begin
|
725
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
726
|
+
oauth_wire4.config_default_api_client
|
727
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
728
|
+
rescue Wire4Client::ApiError => e
|
729
|
+
puts "Exception to obtain access token #{e}"
|
730
|
+
# Optional manage exception in access token flow
|
731
|
+
return
|
732
|
+
end
|
733
|
+
|
734
|
+
# create an instance of the API class
|
735
|
+
api_instance = Wire4Client::DepositantesApi.new
|
736
|
+
|
737
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
738
|
+
subscription = SUBSCRIPTION
|
739
|
+
body = Wire4Client::DepositantsRegister.new
|
740
|
+
body._alias = "Depositant 0292921"
|
741
|
+
body.currency_code = "MXP"
|
742
|
+
body.email = ["depositant@wire4.mx"]
|
743
|
+
body.name = "Marge Bouvier"
|
744
|
+
|
745
|
+
begin
|
746
|
+
# Call the API
|
747
|
+
response = api_instance.register_depositants_using_post(authorization, body, subscription)
|
748
|
+
p response
|
749
|
+
rescue Wire4Client::ApiError => e
|
750
|
+
puts "Exception when calling the API: #{e}"
|
751
|
+
# Optional manage exception in call API
|
752
|
+
return
|
753
|
+
end
|
754
|
+
end
|
755
|
+
|
756
|
+
#noinspection RubyInstanceMethodNamingConvention
|
757
|
+
def test_incoming_SPEI_transactions_report
|
758
|
+
omit('Reason')
|
759
|
+
# Create the authenticator to obtain access token
|
760
|
+
# The token URL and Service URL are defined for this environment enum value.
|
761
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
762
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
763
|
+
|
764
|
+
begin
|
765
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
766
|
+
oauth_wire4.config_default_api_client
|
767
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
768
|
+
rescue Wire4Client::ApiError => e
|
769
|
+
puts "Exception to obtain access token #{e}"
|
770
|
+
# Optional manage exception in access token flow
|
771
|
+
return
|
772
|
+
end
|
773
|
+
|
774
|
+
# create an instance of the API class
|
775
|
+
api_instance = Wire4Client::TransferenciasSPEIApi.new
|
776
|
+
|
777
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
778
|
+
subscription = SUBSCRIPTION
|
779
|
+
|
780
|
+
begin
|
781
|
+
# Call the API
|
782
|
+
response = api_instance.incoming_spei_transactions_report_using_get(authorization, subscription)
|
783
|
+
p response
|
784
|
+
rescue Wire4Client::ApiError => e
|
785
|
+
puts "Exception when calling the API: #{e}"
|
786
|
+
# Optional manage exception in call API
|
787
|
+
return
|
788
|
+
end
|
789
|
+
end
|
790
|
+
|
791
|
+
#noinspection RubyInstanceMethodNamingConvention
|
792
|
+
def test_outgoing_SPEI_transactions_report
|
793
|
+
omit('Reason')
|
794
|
+
# Create the authenticator to obtain access token
|
795
|
+
# The token URL and Service URL are defined for this environment enum value.
|
796
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
797
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
798
|
+
|
799
|
+
begin
|
800
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
801
|
+
oauth_wire4.config_default_api_client
|
802
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
803
|
+
rescue Wire4Client::ApiError => e
|
804
|
+
puts "Exception to obtain access token #{e}"
|
805
|
+
# Optional manage exception in access token flow
|
806
|
+
return
|
807
|
+
end
|
808
|
+
|
809
|
+
# create an instance of the API class
|
810
|
+
api_instance = Wire4Client::TransferenciasSPEIApi.new
|
811
|
+
|
812
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
813
|
+
subscription = SUBSCRIPTION
|
814
|
+
|
815
|
+
begin
|
816
|
+
# Call the API
|
817
|
+
response = api_instance.outgoing_spei_transactions_report_using_get(authorization, subscription)
|
818
|
+
p response
|
819
|
+
rescue Wire4Client::ApiError => e
|
820
|
+
puts "Exception when calling the API: #{e}"
|
821
|
+
# Optional manage exception in call API
|
822
|
+
return
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
826
|
+
#noinspection RubyInstanceMethodNamingConvention
|
827
|
+
def test_out_comming_spei_request_id_transactions_report_using_get
|
828
|
+
omit('Reason')
|
829
|
+
# Create the authenticator to obtain access token
|
830
|
+
# The token URL and Service URL are defined for this environment enum value.
|
831
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
832
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
833
|
+
|
834
|
+
begin
|
835
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
836
|
+
oauth_wire4.config_default_api_client
|
837
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
838
|
+
rescue Wire4Client::ApiError => e
|
839
|
+
puts "Exception to obtain access token #{e}"
|
840
|
+
# Optional manage exception in access token flow
|
841
|
+
return
|
842
|
+
end
|
843
|
+
|
844
|
+
# create an instance of the API class
|
845
|
+
api_instance = Wire4Client::TransferenciasSPEIApi.new
|
846
|
+
|
847
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
848
|
+
subscription = SUBSCRIPTION
|
849
|
+
request_id = '6a9efe39-a795-4e09-8f7f-197e647a0f8b'
|
850
|
+
|
851
|
+
begin
|
852
|
+
# Call the API
|
853
|
+
response = api_instance.out_comming_spei_request_id_transactions_report_using_get(authorization, request_id, subscription)
|
854
|
+
p response
|
855
|
+
rescue Wire4Client::ApiError => e
|
856
|
+
puts "Exception when calling TransferenciasSPEIApi->out_comming_spei_request_id_transactions_report_using_get: #{e}"
|
857
|
+
# Optional manage exception in call API
|
858
|
+
return
|
859
|
+
end
|
860
|
+
end
|
861
|
+
|
862
|
+
#noinspection RubyInstanceMethodNamingConvention
|
863
|
+
def test_register_outgoing_SPEI_transaction
|
864
|
+
omit('Reason')
|
865
|
+
# Create the authenticator to obtain access token
|
866
|
+
# The token URL and Service URL are defined for this environment enum value.
|
867
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
868
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
869
|
+
|
870
|
+
begin
|
871
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
872
|
+
oauth_wire4.config_default_api_client
|
873
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
874
|
+
rescue Wire4Client::ApiError => e
|
875
|
+
puts "Exception to obtain access token #{e}"
|
876
|
+
# Optional manage exception in access token flow
|
877
|
+
return
|
878
|
+
end
|
879
|
+
|
880
|
+
# create an instance of the API class
|
881
|
+
api_instance = Wire4Client::TransferenciasSPEIApi.new
|
882
|
+
|
883
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
884
|
+
subscription = SUBSCRIPTION
|
885
|
+
body = Wire4Client::TransactionsOutgoingRegister.new
|
886
|
+
body.return_url = "https://your-app-url.mx/return"
|
887
|
+
body.cancel_return_url = "https://your-app-url.mx/cancel"
|
888
|
+
transaction = Wire4Client::TransactionOutgoing.new
|
889
|
+
transaction.order_id = "137f14a4-9e12-4a98-bbd1-ab347753e68a"
|
890
|
+
transaction.amount = 1259.69
|
891
|
+
transaction.beneficiary_account = "112680000156896531"
|
892
|
+
transaction.currency_code = "MXP"
|
893
|
+
transaction.email = ["notificar@wire4.mx"]
|
894
|
+
transaction.reference = 1234567
|
895
|
+
transaction.concept = "Transfer out test 1"
|
896
|
+
body.transactions = [transaction]
|
897
|
+
|
898
|
+
begin
|
899
|
+
# Call the API
|
900
|
+
response = api_instance.register_outgoing_spei_transaction_using_post(authorization, subscription, body)
|
901
|
+
p response
|
902
|
+
rescue Wire4Client::ApiError => e
|
903
|
+
puts "Exception when calling the API: #{e}"
|
904
|
+
# Optional manage exception in call API
|
905
|
+
return
|
906
|
+
end
|
907
|
+
end
|
908
|
+
|
909
|
+
#noinspection RubyInstanceMethodNamingConvention
|
910
|
+
def test_delete_outgoing_pending_SPEI_transaction
|
911
|
+
omit('Reason')
|
912
|
+
# Create the authenticator to obtain access token
|
913
|
+
# The token URL and Service URL are defined for this environment enum value.
|
914
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
915
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
916
|
+
|
917
|
+
begin
|
918
|
+
# Obtain an access token use application flow and scope "spei_admin" and add to request
|
919
|
+
oauth_wire4.config_default_api_client
|
920
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spei_admin')
|
921
|
+
rescue Wire4Client::ApiError => e
|
922
|
+
puts "Exception to obtain access token #{e}"
|
923
|
+
# Optional manage exception in access token flow
|
924
|
+
return
|
925
|
+
end
|
926
|
+
|
927
|
+
# create an instance of the API class
|
928
|
+
api_instance = Wire4Client::TransferenciasSPEIApi.new
|
929
|
+
|
930
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
931
|
+
subscription = SUBSCRIPTION
|
932
|
+
request_id = "8abc184f-c3ac-4abd-9045-a9b4a501f007"
|
933
|
+
|
934
|
+
begin
|
935
|
+
# Call the API
|
936
|
+
response = api_instance.drop_transactions_pending_using_delete_with_http_info(authorization, request_id, subscription)
|
937
|
+
p response
|
938
|
+
rescue Wire4Client::ApiError => e
|
939
|
+
puts "Exception when calling the API: #{e}"
|
940
|
+
# Optional manage exception in call API
|
941
|
+
return
|
942
|
+
end
|
943
|
+
end
|
944
|
+
|
945
|
+
#noinspection RubyInstanceMethodNamingConvention
|
946
|
+
def test_register_outgoing_SPID_transaction
|
947
|
+
omit('Reason')
|
948
|
+
# Create the authenticator to obtain access token
|
949
|
+
# The token URL and Service URL are defined for this environment enum value.
|
950
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
951
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
952
|
+
|
953
|
+
begin
|
954
|
+
# Obtain an access token use application flow and scope "spid_admin" and add to request
|
955
|
+
oauth_wire4.config_default_api_client
|
956
|
+
authorization = oauth_wire4.obtain_access_token_app_user(USER_KEY, SECRET_KEY, 'spid_admin')
|
957
|
+
rescue Wire4Client::ApiError => e
|
958
|
+
puts "Exception to obtain access token #{e}"
|
959
|
+
# Optional manage exception in access token flow
|
960
|
+
return
|
961
|
+
end
|
962
|
+
|
963
|
+
# create an instance of the API class
|
964
|
+
api_instance = Wire4Client::TransferenciasSPIDApi.new
|
965
|
+
|
966
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
967
|
+
subscription = SUBSCRIPTION
|
968
|
+
body = Wire4Client::TransactionOutgoingSpid.new
|
969
|
+
body.return_url = "https://your-app-url.mx/return"
|
970
|
+
body.cancel_return_url = "https://your-app-url.mx/cancel"
|
971
|
+
body.amount = 1259.69
|
972
|
+
body.beneficiary_account = "112680000156896531"
|
973
|
+
body.classification_id = "01"
|
974
|
+
body.currency_code = "USD"
|
975
|
+
body.email = ["notificar@wire4.mx"]
|
976
|
+
body.numeric_reference_spid = 1234567
|
977
|
+
body.order_id = "77baa78f-be22-4f6a-b79e-60b20a198324"
|
978
|
+
body.payment_concept_spid = "Transfer out test 1"
|
979
|
+
|
980
|
+
begin
|
981
|
+
# Call the API
|
982
|
+
response = api_instance.register_outgoing_spid_transaction_using_post(authorization, subscription, body)
|
983
|
+
p response
|
984
|
+
rescue Wire4Client::ApiError => e
|
985
|
+
puts "Exception when calling the API: #{e}"
|
986
|
+
# Optional manage exception in call API
|
987
|
+
return
|
988
|
+
end
|
989
|
+
end
|
990
|
+
|
991
|
+
def test_register_web_hook
|
992
|
+
omit('Reason')
|
993
|
+
# Create the authenticator to obtain access token
|
994
|
+
# The token URL and Service URL are defined for this environment enum value.
|
995
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
996
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
997
|
+
|
998
|
+
begin
|
999
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
1000
|
+
oauth_wire4.config_default_api_client
|
1001
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
1002
|
+
rescue Wire4Client::ApiError => e
|
1003
|
+
puts "Exception to obtain access token #{e}"
|
1004
|
+
# Optional manage exception in access token flow
|
1005
|
+
return
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
# create an instance of the API class
|
1009
|
+
api_instance = Wire4Client::WebhooksApi.new
|
1010
|
+
|
1011
|
+
# build body with info (check references for more info: types, required fields, etc.)
|
1012
|
+
body = Wire4Client::WebhookRequest.new # CepSearchBanxico | Información para buscar un CEP
|
1013
|
+
body.events = %w(ACCOUNT.CREATED TRANSACTION.OUTGOING.RECEIVED ENROLLMENT.CREATED)
|
1014
|
+
body.name = "RUBY TEST SDK WEBHOOK-REGISTER"
|
1015
|
+
body.url = "https://www.webhook.site/39034a03-8faf-424e-bb4a-7c3fee2bbfd3"
|
1016
|
+
|
1017
|
+
begin
|
1018
|
+
# Call the API
|
1019
|
+
response = api_instance.register_webhook(authorization, body)
|
1020
|
+
p response
|
1021
|
+
rescue Wire4Client::ApiError => e
|
1022
|
+
puts "Exception when calling the API: #{e}"
|
1023
|
+
# Optional manage exception in call API
|
1024
|
+
return
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
def test_get_web_hooks
|
1029
|
+
omit('Reason')
|
1030
|
+
# Create the authenticator to obtain access token
|
1031
|
+
# The token URL and Service URL are defined for this environment enum value.
|
1032
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
1033
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
1034
|
+
|
1035
|
+
begin
|
1036
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
1037
|
+
oauth_wire4.config_default_api_client
|
1038
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
1039
|
+
rescue Wire4Client::ApiError => e
|
1040
|
+
puts "Exception to obtain access token #{e}"
|
1041
|
+
# Optional manage exception in access token flow
|
1042
|
+
return
|
1043
|
+
end
|
1044
|
+
|
1045
|
+
# create an instance of the API class
|
1046
|
+
api_instance = Wire4Client::WebhooksApi.new
|
1047
|
+
|
1048
|
+
begin
|
1049
|
+
# Call the API
|
1050
|
+
response = api_instance.get_webhooks(authorization)
|
1051
|
+
p response
|
1052
|
+
rescue Wire4Client::ApiError => e
|
1053
|
+
puts "Exception when calling the API: #{e}"
|
1054
|
+
# Optional manage exception in call API
|
1055
|
+
return
|
1056
|
+
end
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
def test_get_web_hook_by_id
|
1060
|
+
omit('Reason')
|
1061
|
+
# Create the authenticator to obtain access token
|
1062
|
+
# The token URL and Service URL are defined for this environment enum value.
|
1063
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
1064
|
+
oauth_wire4 = Wire4Auth::OAuthWire4.new(CLIENT_ID, CLIENT_SECRET, Wire4Auth::EnvironmentEnum::SANDBOX)
|
1065
|
+
|
1066
|
+
begin
|
1067
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
1068
|
+
oauth_wire4.config_default_api_client
|
1069
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
1070
|
+
rescue Wire4Client::ApiError => e
|
1071
|
+
puts "Exception to obtain access token #{e}"
|
1072
|
+
# Optional manage exception in access token flow
|
1073
|
+
return
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
# create an instance of the API class
|
1077
|
+
api_instance = Wire4Client::WebhooksApi.new
|
1078
|
+
|
1079
|
+
begin
|
1080
|
+
# Call the API
|
1081
|
+
response = api_instance.get_webhook(authorization, "wh_3fe3e5f4849f4cabb147804fd55c86fc")
|
1082
|
+
p response
|
1083
|
+
rescue Wire4Client::ApiError => e
|
1084
|
+
puts "Exception when calling the API: #{e}"
|
1085
|
+
# Optional manage exception in call API
|
1086
|
+
return
|
1087
|
+
end
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
def test_get_facturas
|
1091
|
+
omit('Reason')
|
1092
|
+
# Create the authenticator to obtain access token
|
1093
|
+
# The token URL and Service URL are defined for this environment enum value.
|
1094
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
1095
|
+
|
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
|
+
|
1100
|
+
begin
|
1101
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
1102
|
+
oauth_wire4.config_default_api_client
|
1103
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
1104
|
+
rescue Wire4Client::ApiError => e
|
1105
|
+
puts "Exception to obtain access token #{e}"
|
1106
|
+
# Optional manage exception in access token flow
|
1107
|
+
return
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
# create an instance of the API class
|
1111
|
+
api_instance = Wire4Client::FacturasApi.new
|
1112
|
+
|
1113
|
+
begin
|
1114
|
+
# Call the API
|
1115
|
+
response = api_instance.billings_report_using_get(authorization, period: "2019-10")
|
1116
|
+
p response
|
1117
|
+
rescue Wire4Client::ApiError => e
|
1118
|
+
puts "Exception when calling the API: #{e}"
|
1119
|
+
# Optional manage exception in call API
|
1120
|
+
return
|
1121
|
+
end
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
def test_get_facturas_by_id
|
1125
|
+
omit('Reason')
|
1126
|
+
# Create the authenticator to obtain access token
|
1127
|
+
# The token URL and Service URL are defined for this environment enum value.
|
1128
|
+
# e.g. for Sandbox environment: Wire4Auth::EnvironmentEnum::SANDBOX
|
1129
|
+
|
1130
|
+
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
|
+
|
1134
|
+
begin
|
1135
|
+
# Obtain an access token use application flow and scope "general" and add to request
|
1136
|
+
oauth_wire4.config_default_api_client
|
1137
|
+
authorization = oauth_wire4.obtain_access_token_app('general')
|
1138
|
+
rescue Wire4Client::ApiError => e
|
1139
|
+
puts "Exception to obtain access token #{e}"
|
1140
|
+
# Optional manage exception in access token flow
|
1141
|
+
return
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
# create an instance of the API class
|
1145
|
+
api_instance = Wire4Client::FacturasApi.new
|
1146
|
+
|
1147
|
+
begin
|
1148
|
+
# Call the API
|
1149
|
+
response = api_instance.billings_report_by_id_using_get(authorization, "834BA74A-BBBB-43C4-8400-A4528153C2BD")
|
1150
|
+
p response
|
1151
|
+
rescue Wire4Client::ApiError => e
|
1152
|
+
puts "Exception when calling the API: #{e}"
|
1153
|
+
# Optional manage exception in call API
|
1154
|
+
return
|
1155
|
+
end
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
def test_check_web_hook_sign
|
1159
|
+
|
1160
|
+
omit('Reason')
|
1161
|
+
puts `cd .. && cd .. && find *`.split("\n").uniq.sort.select { |f| !f.empty? }
|
1162
|
+
|
1163
|
+
payload = "{ \"responseCode\":0, \n" + \
|
1164
|
+
" \"message\":\"Ya existe este beneficiario de pago a ctas nacionales en el contrato\",\n" + \
|
1165
|
+
" \"statusCode\":\"ERROR\",\n" + \
|
1166
|
+
" \"externalReference\":\"8939TR\"\n" + \
|
1167
|
+
"}"
|
1168
|
+
expected_key = "8e63e88434679473bdb28546d7d91537601f4588e801972376d5c5addcb8fd706e6c92421b73151de3c1945ce000a8a" + \
|
1169
|
+
+"5aa1d5cc3cdd73f2769ee9980db420db9"
|
1170
|
+
|
1171
|
+
result = Wire4Auth::UtilsCompute.compare_webhook_msg_signatures(payload, "9ie93030?=", expected_key)
|
1172
|
+
puts "WebHook signature verification, correct: #{result}"
|
1173
|
+
|
1174
|
+
assert result
|
1175
|
+
end
|
1176
|
+
end
|