Class: Tokenex::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/tokenex/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_base_url, tokenex_id, api_key, proxy_url = '', options = {}) ⇒ Environment

Returns a new instance of Environment.



9
10
11
12
13
14
# File 'lib/tokenex/environment.rb', line 9

def initialize(api_base_url, tokenex_id, api_key, proxy_url = '', options={})
    @api_base_url = api_base_url
    @tokenex_id = tokenex_id
    @api_key = api_key
    @proxy_url = proxy_url
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'lib/tokenex/environment.rb', line 7

def error
  @error
end

#reference_numberObject (readonly)

Returns the value of attribute reference_number.



7
8
9
# File 'lib/tokenex/environment.rb', line 7

def reference_number
  @reference_number
end

Instance Method Details

#delete_token(token) ⇒ Object



69
70
71
72
73
74
75
76
77
78
# File 'lib/tokenex/environment.rb', line 69

def delete_token(token)
    request_parameters = {
        REQUEST_PARAMS[:Token] => token
    }

    catch (:tokenex_invalid_response) do
        return send_request(TOKEN_ACTION[:DeleteToken], request_parameters)
    end
    throw :tokenex_invalid_token
end

#detokenize(token) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/tokenex/environment.rb', line 47

def detokenize(token)
    request_parameters = {
        REQUEST_PARAMS[:Token] => token
    }

    catch (:tokenex_invalid_response) do
        return send_request(TOKEN_ACTION[:Detokenize], request_parameters)
    end
    throw :tokenex_invalid_token
end

#token_from_ccnum(ccnum, token_scheme = TOKEN_SCHEME[:TOKENfour]) ⇒ Object



16
17
18
19
20
21
# File 'lib/tokenex/environment.rb', line 16

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



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tokenex/environment.rb', line 23

def tokenize(data, token_scheme = TOKEN_SCHEME[:GUID])
    request_parameters = {
        REQUEST_PARAMS[:Data] => data,
        REQUEST_PARAMS[:TokenScheme] => token_scheme
    }

    catch (:tokenex_invalid_response) do
        return send_request(TOKEN_ACTION[:Tokenize], request_parameters)
    end
    throw :tokenex_cannot_tokenize_data
end

#tokenize_from_encrypted_value(encrypted_data, token_scheme) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/tokenex/environment.rb', line 35

def tokenize_from_encrypted_value(encrypted_data, token_scheme)
    request_parameters = {
        REQUEST_PARAMS[:EncryptedData] => encrypted_data,
        REQUEST_PARAMS[:TokenScheme] => token_scheme
    }

    catch (:tokenex_invalid_response) do
        return send_request(TOKEN_ACTION[:TokenizeFromEncryptedValue], request_parameters)
    end
    throw :tokenex_cannot_tokenize_from_encrypted_value
end

#validate_token(token) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/tokenex/environment.rb', line 58

def validate_token(token)
    request_parameters = {
        REQUEST_PARAMS[:Token] => token
    }

    catch (:tokenex_invalid_response) do
        return send_request(TOKEN_ACTION[:ValidateToken], request_parameters)
    end
    throw :tokenex_invalid_token
end