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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a056d44fb1baae0f8e7b89c5f78559e98d6e2b1
4
- data.tar.gz: 41b991a72b2a353920e123b93ba930ed3b877d10
3
+ metadata.gz: 96764e702c130abd8c3f9a160011737dabb01cfc
4
+ data.tar.gz: c0046bd54846d65dc01f82ec5f66b7ed0d3c0919
5
5
  SHA512:
6
- metadata.gz: 2b44c059db19324b15fa7e2ad320249163abca9cd0608a0d5a6af92970f245b72c80a7326eadb044e8ede00d2c3c29db624920d624ffd14ffc9731effe5ea2d4
7
- data.tar.gz: 682aac38915281fa81ecb7ae0955bdbd7c228655c86683238ee164e8045825354bcee67c55bef8d57b4d4bd86a83962d4110adff5a0ea89ae76eba29a66562aa
6
+ metadata.gz: 28ca7cc2a2417094c881b06e44de2183fdbf2bc3f5efd7a982bd4b6a7277f1e04fccf8880959ff2fff13162ca5c4018562ec2a94b52599b627ae1ba3e557fb03
7
+ data.tar.gz: fb10761a372e04be9b421a3b035a6d4b51d98d4a40d71f811489f2ce78cc4d59fce7f5b2234f62a79e1682bd4d1d6ebb05b8c391887c117a83c62262597f0f50
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Tokenex
1
+ # Tokenex [![Build Status](https://travis-ci.org/cliffom/tokenex-gem.svg?branch=master)](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["Token"])
31
- # ccnum["Value"] === "4242424242424242"
30
+ ccnum = env.ccnum_from_token(token)
31
+ # ccnum === "4242424242424242"
32
32
  ```
33
33
 
34
34
  ## Development
@@ -18,7 +18,10 @@ module Tokenex
18
18
  "TokenScheme" => 3
19
19
  }
20
20
 
21
- return send_request(action, data)
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
- return send_request(action, data)
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
@@ -1,3 +1,3 @@
1
1
  module Tokenex
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokenex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Clifford