Class: UnivapayClientSdk::TokenCreateCardData

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/univapay_client_sdk/models/token_create_card_data.rb

Overview

Token Create Card Data schema.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(card_number:, exp_month:, exp_year:, cardholder: SKIP, cvv: SKIP, line1: SKIP, line2: SKIP, state: SKIP, city: SKIP, country: SKIP, zip: SKIP, phone_number: SKIP, cvv_authorize: SKIP, three_ds: SKIP, additional_properties: nil) ⇒ TokenCreateCardData

Returns a new instance of TokenCreateCardData.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 112

def initialize(card_number:, exp_month:, exp_year:, cardholder: SKIP,
               cvv: SKIP, line1: SKIP, line2: SKIP, state: SKIP, city: SKIP,
               country: SKIP, zip: SKIP, phone_number: SKIP,
               cvv_authorize: SKIP, three_ds: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @cardholder = cardholder unless cardholder == SKIP
  @card_number = card_number
  @exp_month = exp_month
  @exp_year = exp_year
  @cvv = cvv unless cvv == SKIP
  @line1 = line1 unless line1 == SKIP
  @line2 = line2 unless line2 == SKIP
  @state = state unless state == SKIP
  @city = city unless city == SKIP
  @country = country unless country == SKIP
  @zip = zip unless zip == SKIP
  @phone_number = phone_number unless phone_number == SKIP
  @cvv_authorize = cvv_authorize unless cvv_authorize == SKIP
  @three_ds = three_ds unless three_ds == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#card_numberString

Card number.

Returns:

  • (String)


18
19
20
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 18

def card_number
  @card_number
end

#cardholderString

Cardholder name.

Returns:

  • (String)


14
15
16
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 14

def cardholder
  @cardholder
end

#cityString

City or locality.

Returns:

  • (String)


46
47
48
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 46

def city
  @city
end

#countryString

Country code.

Returns:

  • (String)


50
51
52
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 50

def country
  @country
end

#cvvString

Card security code.

Returns:

  • (String)


30
31
32
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 30

def cvv
  @cvv
end

#cvv_authorizeTokenCreateCardDataCvvAuthorize

Token Create Card Data Cvv Authorize schema.



62
63
64
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 62

def cvv_authorize
  @cvv_authorize
end

#exp_monthString

Card expiration month.

Returns:

  • (String)


22
23
24
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 22

def exp_month
  @exp_month
end

#exp_yearString

Card expiration year.

Returns:

  • (String)


26
27
28
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 26

def exp_year
  @exp_year
end

#line1String

Primary street address line.

Returns:

  • (String)


34
35
36
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 34

def line1
  @line1
end

#line2String

Secondary street address line.

Returns:

  • (String)


38
39
40
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 38

def line2
  @line2
end

#phone_numberTokenCreatePhoneNumber

Token Create Phone Number schema.



58
59
60
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 58

def phone_number
  @phone_number
end

#stateString

State or prefecture.

Returns:

  • (String)


42
43
44
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 42

def state
  @state
end

#three_dsTokenCreateCardDataThreeDs

Token Create Card Data Three Ds schema.



66
67
68
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 66

def three_ds
  @three_ds
end

#zipString

Postal code.

Returns:

  • (String)


54
55
56
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 54

def zip
  @zip
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 138

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  card_number = hash.key?('card_number') ? hash['card_number'] : nil
  exp_month = hash.key?('exp_month') ? hash['exp_month'] : nil
  exp_year = hash.key?('exp_year') ? hash['exp_year'] : nil
  cardholder = hash.key?('cardholder') ? hash['cardholder'] : SKIP
  cvv = hash.key?('cvv') ? hash['cvv'] : SKIP
  line1 = hash.key?('line1') ? hash['line1'] : SKIP
  line2 = hash.key?('line2') ? hash['line2'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  zip = hash.key?('zip') ? hash['zip'] : SKIP
  phone_number = TokenCreatePhoneNumber.from_hash(hash['phone_number']) if
    hash['phone_number']
  cvv_authorize = TokenCreateCardDataCvvAuthorize.from_hash(hash['cvv_authorize']) if
    hash['cvv_authorize']
  three_ds = TokenCreateCardDataThreeDs.from_hash(hash['three_ds']) if hash['three_ds']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  TokenCreateCardData.new(card_number: card_number,
                          exp_month: exp_month,
                          exp_year: exp_year,
                          cardholder: cardholder,
                          cvv: cvv,
                          line1: line1,
                          line2: line2,
                          state: state,
                          city: city,
                          country: country,
                          zip: zip,
                          phone_number: phone_number,
                          cvv_authorize: cvv_authorize,
                          three_ds: three_ds,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 69

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['cardholder'] = 'cardholder'
  @_hash['card_number'] = 'card_number'
  @_hash['exp_month'] = 'exp_month'
  @_hash['exp_year'] = 'exp_year'
  @_hash['cvv'] = 'cvv'
  @_hash['line1'] = 'line1'
  @_hash['line2'] = 'line2'
  @_hash['state'] = 'state'
  @_hash['city'] = 'city'
  @_hash['country'] = 'country'
  @_hash['zip'] = 'zip'
  @_hash['phone_number'] = 'phone_number'
  @_hash['cvv_authorize'] = 'cvv_authorize'
  @_hash['three_ds'] = 'three_ds'
  @_hash
end

.nullablesObject

An array for nullable fields



106
107
108
109
110
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 106

def self.nullables
  %w[
    cvv
  ]
end

.optionalsObject

An array for optional fields



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 89

def self.optionals
  %w[
    cardholder
    cvv
    line1
    line2
    state
    city
    country
    zip
    phone_number
    cvv_authorize
    three_ds
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 186

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.card_number,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.exp_month,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.exp_year,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['card_number'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['exp_month'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['exp_year'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



221
222
223
224
225
226
227
228
229
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 221

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cardholder: #{@cardholder.inspect}, card_number: #{@card_number.inspect},"\
  " exp_month: #{@exp_month.inspect}, exp_year: #{@exp_year.inspect}, cvv: #{@cvv.inspect},"\
  " line1: #{@line1.inspect}, line2: #{@line2.inspect}, state: #{@state.inspect}, city:"\
  " #{@city.inspect}, country: #{@country.inspect}, zip: #{@zip.inspect}, phone_number:"\
  " #{@phone_number.inspect}, cvv_authorize: #{@cvv_authorize.inspect}, three_ds:"\
  " #{@three_ds.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



211
212
213
214
215
216
217
218
# File 'lib/univapay_client_sdk/models/token_create_card_data.rb', line 211

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cardholder: #{@cardholder}, card_number: #{@card_number}, exp_month:"\
  " #{@exp_month}, exp_year: #{@exp_year}, cvv: #{@cvv}, line1: #{@line1}, line2: #{@line2},"\
  " state: #{@state}, city: #{@city}, country: #{@country}, zip: #{@zip}, phone_number:"\
  " #{@phone_number}, cvv_authorize: #{@cvv_authorize}, three_ds: #{@three_ds},"\
  " additional_properties: #{@additional_properties}>"
end