Class: Tokenex::Environment
- Inherits:
-
Object
- Object
- Tokenex::Environment
- Defined in:
- lib/tokenex/environment.rb
Instance Method Summary collapse
- #delete_token(token) ⇒ Object
- #detokenize(token) ⇒ Object
-
#initialize(api_base_url, tokenex_id, api_key, options = {}) ⇒ Environment
constructor
A new instance of Environment.
- #token_from_ccnum(ccnum, token_scheme = TOKEN_SCHEME[:TOKENfour]) ⇒ Object
- #tokenize(data, token_scheme = TOKEN_SCHEME[:GUID]) ⇒ Object
- #tokenize_from_encrypted_value(encrypted_data, token_scheme) ⇒ Object
- #validate_token(token) ⇒ Object
Constructor Details
#initialize(api_base_url, tokenex_id, api_key, options = {}) ⇒ Environment
Returns a new instance of Environment.
8 9 10 11 12 |
# File 'lib/tokenex/environment.rb', line 8 def initialize(api_base_url, tokenex_id, api_key, ={}) @api_base_url = api_base_url @tokenex_id = tokenex_id @api_key = api_key end |
Instance Method Details
#delete_token(token) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/tokenex/environment.rb', line 71 def delete_token(token) action = "DeleteToken" request_parameters = { "Token" => token } response = send_request(action, request_parameters) throw :tokenex_invalid_token unless is_valid_response(response) response['Success'] end |
#detokenize(token) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tokenex/environment.rb', line 47 def detokenize(token) action = "Detokenize" request_parameters = { "Token" => token } response = send_request(action, request_parameters) throw :tokenex_invalid_token unless is_valid_response(response) response['Value'] end |
#token_from_ccnum(ccnum, token_scheme = TOKEN_SCHEME[:TOKENfour]) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/tokenex/environment.rb', line 14 def token_from_ccnum(ccnum, token_scheme = TOKEN_SCHEME[:TOKENfour]) catch (:tokenex_cannot_tokenize_data) do return tokenize(ccnum, token_scheme) end throw :tokenex_invalid_ccnum end |
#tokenize(data, token_scheme = TOKEN_SCHEME[:GUID]) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tokenex/environment.rb', line 21 def tokenize(data, token_scheme = TOKEN_SCHEME[:GUID]) action = "Tokenize" request_parameters = { "Data" => data, "TokenScheme" => token_scheme } response = send_request(action, request_parameters) throw :tokenex_cannot_tokenize_data unless is_valid_response(response) response['Token'] end |
#tokenize_from_encrypted_value(encrypted_data, token_scheme) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tokenex/environment.rb', line 34 def tokenize_from_encrypted_value(encrypted_data, token_scheme) action = "TokenizeFromEncryptedValue" request_parameters = { "EcryptedData" => encrypted_data, "TokenScheme" => token_scheme } response = send_request(action, request_parameters) throw :tokenex_cannot_tokenize_from_encrypted_value unless is_valid_response(response) response['Token'] end |
#validate_token(token) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tokenex/environment.rb', line 59 def validate_token(token) action = "ValidateToken" request_parameters = { "Token" => token } response = send_request(action, request_parameters) throw :tokenex_invalid_token unless is_valid_response(response) response['Valid'] end |