Class: Io::Flow::V0::Models::TokenType

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ TokenType

Returns a new instance of TokenType.



13509
13510
13511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13509

def initialize(value)
  @value = HttpClient::Preconditions.assert_class('value', value, String)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



13507
13508
13509
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13507

def value
  @value
end

Class Method Details

.ALLObject



13529
13530
13531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13529

def TokenType.ALL
  @@all ||= [TokenType.permanent, TokenType.one_time]
end

.apply(value) ⇒ Object

Returns the instance of TokenType for this value, creating a new instance for an unknown value



13514
13515
13516
13517
13518
13519
13520
13521
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13514

def TokenType.apply(value)
  if value.instance_of?(TokenType)
    value
  else
    HttpClient::Preconditions.assert_class_or_nil('value', value, String)
    value.nil? ? nil : (from_string(value) || TokenType.new(value))
  end
end

.from_string(value) ⇒ Object

Returns the instance of TokenType for this value, or nil if not found



13524
13525
13526
13527
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13524

def TokenType.from_string(value)
  HttpClient::Preconditions.assert_class('value', value, String)
  TokenType.ALL.find { |v| v.value == value }
end

.one_timeObject

Create a one time token for the card. This token can be used to either authorized payment or later exchange for a permanent token. Once used, this token cannot be used for future activity.



13541
13542
13543
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13541

def TokenType.one_time
  @@_one_time ||= TokenType.new('one_time')
end

.permanentObject

Create a permanent token for the card (stored up until normal purge interval)



13534
13535
13536
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13534

def TokenType.permanent
  @@_permanent ||= TokenType.new('permanent')
end

Instance Method Details

#to_hashObject



13545
13546
13547
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13545

def to_hash
  value
end