tokenex 0.1.2 → 0.2.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 +3 -3
- data/lib/tokenex/environment.rb +13 -3
- data/lib/tokenex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96764e702c130abd8c3f9a160011737dabb01cfc
|
4
|
+
data.tar.gz: c0046bd54846d65dc01f82ec5f66b7ed0d3c0919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28ca7cc2a2417094c881b06e44de2183fdbf2bc3f5efd7a982bd4b6a7277f1e04fccf8880959ff2fff13162ca5c4018562ec2a94b52599b627ae1ba3e557fb03
|
7
|
+
data.tar.gz: fb10761a372e04be9b421a3b035a6d4b51d98d4a40d71f811489f2ce78cc4d59fce7f5b2234f62a79e1682bd4d1d6ebb05b8c391887c117a83c62262597f0f50
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Tokenex
|
1
|
+
# Tokenex [](https://travis-ci.org/cliffom/tokenex-gem)
|
2
2
|
|
3
3
|
A convenient Ruby wrapper for the TokenEx API.
|
4
4
|
|
@@ -27,8 +27,8 @@ Let's start with a simple tokenization and detokenization of a credit card recor
|
|
27
27
|
```ruby
|
28
28
|
env = Tokenex::Environment.new(api_base_url, token_ex_id, api_key)
|
29
29
|
token = env.token_from_ccnum(4242424242424242)
|
30
|
-
ccnum = env.ccnum_from_token(token
|
31
|
-
# ccnum
|
30
|
+
ccnum = env.ccnum_from_token(token)
|
31
|
+
# ccnum === "4242424242424242"
|
32
32
|
```
|
33
33
|
|
34
34
|
## Development
|
data/lib/tokenex/environment.rb
CHANGED
@@ -18,7 +18,10 @@ module Tokenex
|
|
18
18
|
"TokenScheme" => 3
|
19
19
|
}
|
20
20
|
|
21
|
-
|
21
|
+
response = send_request(action, data)
|
22
|
+
throw :tokenex_invalid_ccnum unless is_valid_response(response)
|
23
|
+
|
24
|
+
return response['Token']
|
22
25
|
end
|
23
26
|
|
24
27
|
def ccnum_from_token(token)
|
@@ -27,7 +30,10 @@ module Tokenex
|
|
27
30
|
"Token" => token
|
28
31
|
}
|
29
32
|
|
30
|
-
|
33
|
+
response = send_request(action, data)
|
34
|
+
throw :tokenex_invalid_token unless is_valid_response(response)
|
35
|
+
|
36
|
+
return response['Value']
|
31
37
|
end
|
32
38
|
|
33
39
|
private
|
@@ -59,6 +65,10 @@ module Tokenex
|
|
59
65
|
response = http.request(request)
|
60
66
|
return JSON.parse(response.body)
|
61
67
|
end
|
62
|
-
|
68
|
+
|
69
|
+
def is_valid_response(response)
|
70
|
+
return !response['Success'].nil? && response['Success'] === true
|
71
|
+
end
|
72
|
+
|
63
73
|
end
|
64
74
|
end
|
data/lib/tokenex/version.rb
CHANGED