Class: Tokenex::Environment

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

Instance Method Summary collapse

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, options={})
    @api_base_url = api_base_url
    @tokenex_id = tokenex_id
    @api_key = api_key
end

Instance Method Details

#ccnum_from_token(token) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tokenex/environment.rb', line 27

def ccnum_from_token(token)
    action = "Detokenize"
    data = {
        "Token" => token
    }
    
    response = send_request(action, data)
    throw :tokenex_invalid_token unless is_valid_response(response) 
    
    return response['Value']
end

#token_from_ccnum(ccNum) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tokenex/environment.rb', line 14

def token_from_ccnum(ccNum)
    action = "Tokenize"
    data = {
        "Data" => ccNum,
        "TokenScheme" => 3
    }
    
    response = send_request(action, data)
    throw :tokenex_invalid_ccnum unless is_valid_response(response)  
 
    return response['Token']
end