tokenex 0.4.1 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f44d917728afc03538828d627a7ab0e43039cfc0
4
- data.tar.gz: b4a804d98951c854dfa62a9e24e73e0946de5f5b
3
+ metadata.gz: 4672a0ace60e8132c8e064ace265829936ea45c3
4
+ data.tar.gz: bf2bddca1e836838bb39476b8bc7f0315ba61e30
5
5
  SHA512:
6
- metadata.gz: 0e96c22a74e3602dafe94ea18a6b89c01e1f6b7fb63bfad3767b09b5cd414a12ad27ceb48613e9da9ff4d7be7c626906f9e356c751a5e3344e4e1ef7eb2ad024
7
- data.tar.gz: 7e1e551740ed8bb415a7f4af2bd9275cc720b1ef652dae431cb2a25edfcbf74c857f4b86e5e618d73b21ac87b0c73ed1b01d229d202cb66b383af7b8a836060f
6
+ metadata.gz: 317a60967808c3c295137e4a5feee09f284989d1e9db0151fd6e266b89e0043d672685696c412f6102d252623a0356fec479997094bdeaf6b89291a93a555959
7
+ data.tar.gz: 2634b73416da8f12cb776c49091b1b9a3a65c9bb78b8ff14e67f9bfcd37517f2849571e03cd3d231c45972d891363a96b73fa46b3b6e4973f0c98263cb56f27d
data/README.md CHANGED
@@ -22,17 +22,39 @@ Or install it yourself as:
22
22
 
23
23
  ### Tokenization
24
24
 
25
- Let's start with a simple tokenization and detokenization of a credit card record:
25
+ #### Initialize your TokenEx object
26
+
27
+ The examples below require you first instantiate a new TokenEx object
26
28
 
27
29
  ```ruby
28
30
  tokenex = Tokenex::Environment.new(api_base_url, token_ex_id, api_key)
31
+ ```
32
+
33
+ #### Tokenize a credit card number
34
+ ```ruby
35
+ token = tokenex.token_from_ccnum(4242424242424242)
36
+ ```
37
+
38
+ #### Tokenize arbitrary data
39
+ ```ruby
40
+ token = tokenex.tokenize("This is random data containing 3 numbers less than 10")
41
+ ```
42
+
43
+ #### Detokenize a token
44
+ ```ruby
45
+ token = tokenex.token_from_ccnum(4242424242424242)
46
+ data = tokenex.detokenize(token)
47
+ ```
48
+
49
+ #### Validate a token
50
+ ```ruby
51
+ token = tokenex.token_from_ccnum(4242424242424242)
52
+ token_is_valid = tokenex.validate_token(token)
53
+ ```
54
+
55
+ #### Delete a token
56
+ ```ruby
29
57
  token = tokenex.token_from_ccnum(4242424242424242)
30
- ccnum = tokenex.detokenize(token)
31
- is_valid_token = tokenex.validate_token(token)
32
- tokenex.delete_token(token)
33
- arbitrary_data = "This is my string with 3 numbers less than 10"
34
- token = tokenex.tokenize(arbitrary_data)
35
- arbitrary_data = tokenex.detokenize(token)
36
58
  tokenex.delete_token(token)
37
59
  ```
38
60
 
@@ -50,4 +72,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/radpad
50
72
  ## License
51
73
 
52
74
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
53
-
@@ -1,6 +1,7 @@
1
1
  require "tokenex/version"
2
+ require "tokenex/token_scheme"
2
3
  require "tokenex/environment"
3
4
 
4
5
  module Tokenex
5
-
6
+
6
7
  end
@@ -11,14 +11,14 @@ module Tokenex
11
11
  @api_key = api_key
12
12
  end
13
13
 
14
- def token_from_ccnum(ccnum, token_scheme = 3)
14
+ def token_from_ccnum(ccnum, token_scheme = TOKEN_SCHEME[:TOKENfour])
15
15
  catch (:tokenex_cannot_tokenize_data) do
16
16
  return tokenize(ccnum, token_scheme)
17
17
  end
18
18
  throw :tokenex_invalid_ccnum
19
19
  end
20
20
 
21
- def tokenize(data, token_scheme = 4)
21
+ def tokenize(data, token_scheme = TOKEN_SCHEME[:GUID])
22
22
  action = "Tokenize"
23
23
  request_parameters = {
24
24
  "Data" => data,
@@ -28,7 +28,7 @@ module Tokenex
28
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']
31
+ response['Token']
32
32
  end
33
33
 
34
34
  def tokenize_from_encrypted_value(encrypted_data, token_scheme)
@@ -41,7 +41,7 @@ module Tokenex
41
41
  response = send_request(action, request_parameters)
42
42
  throw :tokenex_cannot_tokenize_from_encrypted_value unless is_valid_response(response)
43
43
 
44
- return response['Token']
44
+ response['Token']
45
45
  end
46
46
 
47
47
  def detokenize(token)
@@ -53,7 +53,7 @@ module Tokenex
53
53
  response = send_request(action, request_parameters)
54
54
  throw :tokenex_invalid_token unless is_valid_response(response)
55
55
 
56
- return response['Value']
56
+ response['Value']
57
57
  end
58
58
 
59
59
  def validate_token(token)
@@ -65,7 +65,7 @@ module Tokenex
65
65
  response = send_request(action, request_parameters)
66
66
  throw :tokenex_invalid_token unless is_valid_response(response)
67
67
 
68
- return response['Valid']
68
+ response['Valid']
69
69
  end
70
70
 
71
71
  def delete_token(token)
@@ -77,7 +77,7 @@ module Tokenex
77
77
  response = send_request(action, request_parameters)
78
78
  throw :tokenex_invalid_token unless is_valid_response(response)
79
79
 
80
- return response['Success']
80
+ response['Success']
81
81
  end
82
82
 
83
83
  private
@@ -94,7 +94,7 @@ module Tokenex
94
94
  "TokenExID" => @tokenex_id
95
95
  }.merge(data)
96
96
 
97
- return request_array
97
+ request_array
98
98
  end
99
99
 
100
100
  def send_request(action, data)
@@ -108,11 +108,11 @@ module Tokenex
108
108
  request = Net::HTTP::Post.new(uri, initheader = headers)
109
109
  request.body = request_body
110
110
  response = http.request(request)
111
- return JSON.parse(response.body)
111
+ JSON.parse(response.body)
112
112
  end
113
113
 
114
114
  def is_valid_response(response)
115
- return !response['Success'].nil? && response['Success'] === true
115
+ !response['Success'].nil? && response['Success'] == true
116
116
  end
117
117
 
118
118
  end
@@ -0,0 +1,23 @@
1
+ module Tokenex
2
+ # http://docs.tokenex.com/#appendix-token-schemes
3
+ TOKEN_SCHEME = {
4
+ sixTokenfour: 1,
5
+ fourTOKENfour: 2,
6
+ TOKENfour: 3,
7
+ GUID: 4,
8
+ SSN: 5,
9
+ nGUID: 6,
10
+ nTOKENfour: 7,
11
+ nTOKEN: 8,
12
+ sixANTOKENfour: 9,
13
+ fourANTOKENfour: 10,
14
+ ANTOKENfour: 11,
15
+ ANTOKEN: 12,
16
+ ANTOKENAUTO: 13,
17
+ ASCIITOKENfour: 14,
18
+ ASCIITOKEN: 15,
19
+ sixASCIITOKENfour: 16,
20
+ fourASCIITOKENfour: 17,
21
+ ASCIITOKENAUTO: 18
22
+ }
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Tokenex
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.1"
3
3
  end
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.1
4
+ version: 0.5.1
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-29 00:00:00.000000000 Z
11
+ date: 2016-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,6 +83,7 @@ files:
83
83
  - bin/setup
84
84
  - lib/tokenex.rb
85
85
  - lib/tokenex/environment.rb
86
+ - lib/tokenex/token_scheme.rb
86
87
  - lib/tokenex/version.rb
87
88
  - tokenex.gemspec
88
89
  homepage: https://github.com/radpad/tokenex-gem