Class: MundiApi::CreateCardRequest

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

Overview

Card data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(number = nil, holder_name = nil, exp_month = nil, exp_year = nil, cvv = nil, billing_address = nil, brand = nil, billing_address_id = nil, metadata = nil, type = 'credit', options = nil, holder_document = nil) ⇒ CreateCardRequest

Returns a new instance of CreateCardRequest.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/mundi_api/models/create_card_request.rb', line 75

def initialize(number = nil,
               holder_name = nil,
               exp_month = nil,
               exp_year = nil,
               cvv = nil,
               billing_address = nil,
               brand = nil,
               billing_address_id = nil,
                = nil,
               type = 'credit',
               options = nil,
               holder_document = nil)
  @number = number
  @holder_name = holder_name
  @exp_month = exp_month
  @exp_year = exp_year
  @cvv = cvv
  @billing_address = billing_address
  @brand = brand
  @billing_address_id = billing_address_id
   = 
  @type = type
  @options = options
  @holder_document = holder_document
end

Instance Attribute Details

#billing_addressCreateAddressRequest

Card’s billing address



29
30
31
# File 'lib/mundi_api/models/create_card_request.rb', line 29

def billing_address
  @billing_address
end

#billing_address_idString

The address id for the billing address

Returns:



37
38
39
# File 'lib/mundi_api/models/create_card_request.rb', line 37

def billing_address_id
  @billing_address_id
end

#brandString

Card brand

Returns:



33
34
35
# File 'lib/mundi_api/models/create_card_request.rb', line 33

def brand
  @brand
end

#cvvString

The card’s security code

Returns:



25
26
27
# File 'lib/mundi_api/models/create_card_request.rb', line 25

def cvv
  @cvv
end

#exp_monthInteger

The expiration month

Returns:

  • (Integer)


17
18
19
# File 'lib/mundi_api/models/create_card_request.rb', line 17

def exp_month
  @exp_month
end

#exp_yearInteger

The expiration year, that can be informed with 2 or 4 digits

Returns:

  • (Integer)


21
22
23
# File 'lib/mundi_api/models/create_card_request.rb', line 21

def exp_year
  @exp_year
end

#holder_documentString

Document number for the card’s holder

Returns:



53
54
55
# File 'lib/mundi_api/models/create_card_request.rb', line 53

def holder_document
  @holder_document
end

#holder_nameString

Holder name, as written on the card

Returns:



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

def holder_name
  @holder_name
end

#metadataArray<String, String>

Metadata

Returns:



41
42
43
# File 'lib/mundi_api/models/create_card_request.rb', line 41

def 
  
end

#numberString

Credit card number

Returns:



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

def number
  @number
end

#optionsCreateCardOptionsRequest

Options for creating the card



49
50
51
# File 'lib/mundi_api/models/create_card_request.rb', line 49

def options
  @options
end

#typeString

Card type

Returns:



45
46
47
# File 'lib/mundi_api/models/create_card_request.rb', line 45

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/mundi_api/models/create_card_request.rb', line 102

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  number = hash['number']
  holder_name = hash['holder_name']
  exp_month = hash['exp_month']
  exp_year = hash['exp_year']
  cvv = hash['cvv']
  billing_address = CreateAddressRequest.from_hash(hash['billing_address']) if
    hash['billing_address']
  brand = hash['brand']
  billing_address_id = hash['billing_address_id']
   = hash['metadata']
  type = hash['type'] ||= 'credit'
  options = CreateCardOptionsRequest.from_hash(hash['options']) if
    hash['options']
  holder_document = hash['holder_document']

  # Create object from extracted values.

  CreateCardRequest.new(number,
                        holder_name,
                        exp_month,
                        exp_year,
                        cvv,
                        billing_address,
                        brand,
                        billing_address_id,
                        ,
                        type,
                        options,
                        holder_document)
end

.namesObject

A mapping from model property names to API property names.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/mundi_api/models/create_card_request.rb', line 56

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash['number'] = 'number'
    @_hash['holder_name'] = 'holder_name'
    @_hash['exp_month'] = 'exp_month'
    @_hash['exp_year'] = 'exp_year'
    @_hash['cvv'] = 'cvv'
    @_hash['billing_address'] = 'billing_address'
    @_hash['brand'] = 'brand'
    @_hash['billing_address_id'] = 'billing_address_id'
    @_hash['metadata'] = 'metadata'
    @_hash['type'] = 'type'
    @_hash['options'] = 'options'
    @_hash['holder_document'] = 'holder_document'
  end
  @_hash
end