tokenex 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/tokenex/environment.rb +50 -37
- data/lib/tokenex/version.rb +1 -1
- data/tokenex.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff4bcba1d6482c72cb1e9e5a11e1803ade77d766
|
4
|
+
data.tar.gz: e4956fda857419d04c7ac26349bcc89d9e3eaceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7d8b700449633e60ecddfec93f0a32f3295aecd34d827b619ff9721b02ada245a62dc2b22735a64040064e82f09b2b7ab1d5616c3ffa7e3ce07911ee5746141
|
7
|
+
data.tar.gz: 22ea369574c4b25ed1af68e60f5423d5531e9d32328fc53d3ef681b23b69ba1398ae27098ea49123473ba1a7262a10d28252d3a219c29aac9bb0806c5aadac60
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Tokenex [](https://travis-ci.org/RadPad/tokenex-gem) [](https://badge.fury.io/rb/tokenex)
|
2
2
|
|
3
3
|
A convenient Ruby wrapper for the TokenEx API.
|
4
4
|
|
@@ -44,7 +44,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/radpad/tokenex-gem.
|
48
48
|
|
49
49
|
|
50
50
|
## License
|
data/lib/tokenex/environment.rb
CHANGED
@@ -4,69 +4,82 @@ require "uri"
|
|
4
4
|
|
5
5
|
module Tokenex
|
6
6
|
class Environment
|
7
|
-
|
7
|
+
|
8
8
|
def initialize(api_base_url, tokenex_id, api_key, options={})
|
9
9
|
@api_base_url = api_base_url
|
10
10
|
@tokenex_id = tokenex_id
|
11
11
|
@api_key = api_key
|
12
12
|
end
|
13
|
-
|
14
|
-
def token_from_ccnum(
|
13
|
+
|
14
|
+
def token_from_ccnum(ccnum, token_scheme = 3)
|
15
15
|
catch (:tokenex_cannot_tokenize_data) do
|
16
|
-
return tokenize(
|
16
|
+
return tokenize(ccnum, token_scheme)
|
17
17
|
end
|
18
18
|
throw :tokenex_invalid_ccnum
|
19
19
|
end
|
20
|
-
|
21
|
-
def tokenize(
|
20
|
+
|
21
|
+
def tokenize(data, token_scheme = 4)
|
22
22
|
action = "Tokenize"
|
23
|
-
|
24
|
-
"Data" =>
|
23
|
+
request_parameters = {
|
24
|
+
"Data" => data,
|
25
25
|
"TokenScheme" => token_scheme
|
26
26
|
}
|
27
|
-
|
28
|
-
response = send_request(action,
|
27
|
+
|
28
|
+
response = send_request(action, request_parameters)
|
29
29
|
throw :tokenex_cannot_tokenize_data unless is_valid_response(response)
|
30
|
-
|
30
|
+
|
31
|
+
return response['Token']
|
32
|
+
end
|
33
|
+
|
34
|
+
def tokenize_from_encrypted_value(encrypted_data, token_scheme)
|
35
|
+
action = "TokenizeFromEncryptedValue"
|
36
|
+
request_parameters = {
|
37
|
+
"EcryptedData" => encrypted_data,
|
38
|
+
"TokenScheme" => token_scheme
|
39
|
+
}
|
40
|
+
|
41
|
+
response = send_request(action, request_parameters)
|
42
|
+
throw :tokenex_cannot_tokenize_from_encrypted_value unless is_valid_response(response)
|
43
|
+
|
31
44
|
return response['Token']
|
32
45
|
end
|
33
|
-
|
46
|
+
|
34
47
|
def detokenize(token)
|
35
48
|
action = "Detokenize"
|
36
|
-
|
49
|
+
request_parameters = {
|
37
50
|
"Token" => token
|
38
51
|
}
|
39
|
-
|
40
|
-
response = send_request(action,
|
41
|
-
throw :tokenex_invalid_token unless is_valid_response(response)
|
42
|
-
|
52
|
+
|
53
|
+
response = send_request(action, request_parameters)
|
54
|
+
throw :tokenex_invalid_token unless is_valid_response(response)
|
55
|
+
|
43
56
|
return response['Value']
|
44
57
|
end
|
45
|
-
|
58
|
+
|
46
59
|
def validate_token(token)
|
47
60
|
action = "ValidateToken"
|
48
|
-
|
61
|
+
request_parameters = {
|
49
62
|
"Token" => token
|
50
63
|
}
|
51
|
-
|
52
|
-
response = send_request(action,
|
53
|
-
throw :tokenex_invalid_token unless is_valid_response(response)
|
54
|
-
|
64
|
+
|
65
|
+
response = send_request(action, request_parameters)
|
66
|
+
throw :tokenex_invalid_token unless is_valid_response(response)
|
67
|
+
|
55
68
|
return response['Valid']
|
56
69
|
end
|
57
|
-
|
70
|
+
|
58
71
|
def delete_token(token)
|
59
72
|
action = "DeleteToken"
|
60
|
-
|
73
|
+
request_parameters = {
|
61
74
|
"Token" => token
|
62
75
|
}
|
63
|
-
|
64
|
-
response = send_request(action,
|
65
|
-
throw :tokenex_invalid_token unless is_valid_response(response)
|
66
|
-
|
76
|
+
|
77
|
+
response = send_request(action, request_parameters)
|
78
|
+
throw :tokenex_invalid_token unless is_valid_response(response)
|
79
|
+
|
67
80
|
return response['Success']
|
68
81
|
end
|
69
|
-
|
82
|
+
|
70
83
|
private
|
71
84
|
def headers
|
72
85
|
{
|
@@ -74,32 +87,32 @@ module Tokenex
|
|
74
87
|
'Accept' => 'application/json'
|
75
88
|
}
|
76
89
|
end
|
77
|
-
|
90
|
+
|
78
91
|
def build_request_array(data)
|
79
92
|
request_array = {
|
80
93
|
"APIKey" => @api_key,
|
81
94
|
"TokenExID" => @tokenex_id
|
82
95
|
}.merge(data)
|
83
|
-
|
96
|
+
|
84
97
|
return request_array
|
85
98
|
end
|
86
99
|
|
87
100
|
def send_request(action, data)
|
88
101
|
request_body = build_request_array(data).to_json
|
89
|
-
|
102
|
+
|
90
103
|
uri = URI.parse("#{@api_base_url}#{action}")
|
91
104
|
http = Net::HTTP.new(uri.host, uri.port)
|
92
105
|
http.use_ssl = true
|
93
|
-
|
106
|
+
|
94
107
|
request = Net::HTTP::Post.new(uri, initheader = headers)
|
95
108
|
request.body = request_body
|
96
109
|
response = http.request(request)
|
97
110
|
return JSON.parse(response.body)
|
98
111
|
end
|
99
|
-
|
112
|
+
|
100
113
|
def is_valid_response(response)
|
101
114
|
return !response['Success'].nil? && response['Success'] === true
|
102
115
|
end
|
103
|
-
|
116
|
+
|
104
117
|
end
|
105
|
-
end
|
118
|
+
end
|
data/lib/tokenex/version.rb
CHANGED
data/tokenex.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = "Provides a Ruby wrapper for the TokenEx API"
|
13
13
|
spec.description = "The TokenEx gem provides a convenient Ruby wrapper for the TokenEx API."
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/radpad/tokenex-gem"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tokenex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Clifford
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,7 +84,7 @@ files:
|
|
84
84
|
- lib/tokenex/environment.rb
|
85
85
|
- lib/tokenex/version.rb
|
86
86
|
- tokenex.gemspec
|
87
|
-
homepage: https://github.com/
|
87
|
+
homepage: https://github.com/radpad/tokenex-gem
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata:
|