Class: ConektaMotion::Token
- Inherits:
-
Object
- Object
- ConektaMotion::Token
- Defined in:
- lib/conekta-motion/token.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#token_id ⇒ Object
readonly
Returns the value of attribute token_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(token_id, error) ⇒ Token
constructor
A new instance of Token.
- #valid? ⇒ Boolean
Constructor Details
#initialize(token_id, error) ⇒ Token
5 6 7 8 |
# File 'lib/conekta-motion/token.rb', line 5 def initialize(token_id, error) @token_id = token_id @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/conekta-motion/token.rb', line 3 def error @error end |
#token_id ⇒ Object (readonly)
Returns the value of attribute token_id.
3 4 5 |
# File 'lib/conekta-motion/token.rb', line 3 def token_id @token_id end |
Class Method Details
.init_from(response) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/conekta-motion/token.rb', line 15 def init_from(response) token_id = nil error = nil if response token_id = response[:id] if response[:object] == 'token' error = response[:message_to_purchaser] if response[:object] == 'error' end Token.new token_id, error end |
Instance Method Details
#valid? ⇒ Boolean
10 11 12 |
# File 'lib/conekta-motion/token.rb', line 10 def valid? error.nil? end |