Class: MundiApi::CreateTokenRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mundi_api/models/create_token_request.rb

Overview

Token data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(type = 'card', card = nil) ⇒ CreateTokenRequest

Returns a new instance of CreateTokenRequest.



25
26
27
28
29
# File 'lib/mundi_api/models/create_token_request.rb', line 25

def initialize(type = 'card',
               card = nil)
  @type = type
  @card = card
end

Instance Attribute Details

#cardCreateCardTokenRequest

Card data



13
14
15
# File 'lib/mundi_api/models/create_token_request.rb', line 13

def card
  @card
end

#typeString

Token type

Returns:



9
10
11
# File 'lib/mundi_api/models/create_token_request.rb', line 9

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mundi_api/models/create_token_request.rb', line 32

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  type = hash['type'] ||= 'card'
  card = CreateCardTokenRequest.from_hash(hash['card']) if hash['card']

  # Create object from extracted values.

  CreateTokenRequest.new(type,
                         card)
end

.namesObject

A mapping from model property names to API property names.



16
17
18
19
20
21
22
23
# File 'lib/mundi_api/models/create_token_request.rb', line 16

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash['type'] = 'type'
    @_hash['card'] = 'card'
  end
  @_hash
end