Class: MassPayRubySdk::GetWalletCardInfo200Response

Inherits:
Object
  • Object
show all
Defined in:
lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb

Overview

MassPay Card Information

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ GetWalletCardInfo200Response

Initializes the object



100
101
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
135
136
137
138
139
140
141
142
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 100

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `MassPayRubySdk::GetWalletCardInfo200Response` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `MassPayRubySdk::GetWalletCardInfo200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'card_number')
    self.card_number = attributes[:'card_number']
  end

  if attributes.key?(:'cvv')
    self.cvv = attributes[:'cvv']
  end

  if attributes.key?(:'expiration_date')
    self.expiration_date = attributes[:'expiration_date']
  end

  if attributes.key?(:'pin_number')
    self.pin_number = attributes[:'pin_number']
  end

  if attributes.key?(:'balance')
    self.balance = attributes[:'balance']
  end

  if attributes.key?(:'type')
    self.type = attributes[:'type']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  else
    self.status = 'ACTIVE'
  end
end

Instance Attribute Details

#balanceObject

Available balance on the card



31
32
33
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 31

def balance
  @balance
end

#card_numberObject

16 Digits card number



19
20
21
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 19

def card_number
  @card_number
end

#cvvObject

3 Digits cvv code



22
23
24
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 22

def cvv
  @cvv
end

#expiration_dateObject

Card expiration date



25
26
27
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 25

def expiration_date
  @expiration_date
end

#pin_numberObject

Card pin number (used in ATM machines)



28
29
30
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 28

def pin_number
  @pin_number
end

#statusObject

Status of the card



37
38
39
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 37

def status
  @status
end

#typeObject

Card type



34
35
36
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 34

def type
  @type
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



75
76
77
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 75

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 62

def self.attribute_map
  {
    :'card_number' => :'card_number',
    :'cvv' => :'cvv',
    :'expiration_date' => :'expiration_date',
    :'pin_number' => :'pin_number',
    :'balance' => :'balance',
    :'type' => :'type',
    :'status' => :'status'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash



342
343
344
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 342

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



93
94
95
96
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 93

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 80

def self.openapi_types
  {
    :'card_number' => :'Integer',
    :'cvv' => :'String',
    :'expiration_date' => :'Date',
    :'pin_number' => :'String',
    :'balance' => :'Float',
    :'type' => :'String',
    :'status' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



315
316
317
318
319
320
321
322
323
324
325
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 315

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      card_number == o.card_number &&
      cvv == o.cvv &&
      expiration_date == o.expiration_date &&
      pin_number == o.pin_number &&
      balance == o.balance &&
      type == o.type &&
      status == o.status
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 373

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = MassPayRubySdk.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value



444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 444

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 349

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

See Also:

  • `==` method


329
330
331
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 329

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.



335
336
337
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 335

def hash
  [card_number, cvv, expiration_date, pin_number, balance, type, status].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?



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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 146

def list_invalid_properties
  invalid_properties = Array.new
  if @card_number.nil?
    invalid_properties.push('invalid value for "card_number", card_number cannot be nil.')
  end

  if @cvv.nil?
    invalid_properties.push('invalid value for "cvv", cvv cannot be nil.')
  end

  if @cvv.to_s.length > 3
    invalid_properties.push('invalid value for "cvv", the character length must be smaller than or equal to 3.')
  end

  if @cvv.to_s.length < 3
    invalid_properties.push('invalid value for "cvv", the character length must be great than or equal to 3.')
  end

  pattern = Regexp.new(/^[0-9]{3}$/)
  if @cvv !~ pattern
    invalid_properties.push("invalid value for \"cvv\", must conform to the pattern #{pattern}.")
  end

  if @expiration_date.nil?
    invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.')
  end

  if @pin_number.nil?
    invalid_properties.push('invalid value for "pin_number", pin_number cannot be nil.')
  end

  if @pin_number.to_s.length > 4
    invalid_properties.push('invalid value for "pin_number", the character length must be smaller than or equal to 4.')
  end

  if @pin_number.to_s.length < 4
    invalid_properties.push('invalid value for "pin_number", the character length must be great than or equal to 4.')
  end

  pattern = Regexp.new(/^[0-9]{4}$/)
  if @pin_number !~ pattern
    invalid_properties.push("invalid value for \"pin_number\", must conform to the pattern #{pattern}.")
  end

  if @balance.nil?
    invalid_properties.push('invalid value for "balance", balance cannot be nil.')
  end

  if @balance < 0
    invalid_properties.push('invalid value for "balance", must be greater than or equal to 0.')
  end

  if @type.nil?
    invalid_properties.push('invalid value for "type", type cannot be nil.')
  end

  if @status.nil?
    invalid_properties.push('invalid value for "status", status cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



420
421
422
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 420

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 426

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object



414
415
416
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 414

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/masspay_ruby_sdk/models/get_wallet_card_info200_response.rb', line 211

def valid?
  return false if @card_number.nil?
  return false if @cvv.nil?
  return false if @cvv.to_s.length > 3
  return false if @cvv.to_s.length < 3
  return false if @cvv !~ Regexp.new(/^[0-9]{3}$/)
  return false if @expiration_date.nil?
  return false if @pin_number.nil?
  return false if @pin_number.to_s.length > 4
  return false if @pin_number.to_s.length < 4
  return false if @pin_number !~ Regexp.new(/^[0-9]{4}$/)
  return false if @balance.nil?
  return false if @balance < 0
  return false if @type.nil?
  type_validator = EnumAttributeValidator.new('String', ["VISA", "MASTERCARD", "DISCOVER", "AMEX", "UNIONPAY"])
  return false unless type_validator.valid?(@type)
  return false if @status.nil?
  status_validator = EnumAttributeValidator.new('String', ["ACTIVE", "INACTIVE", "CLOSED"])
  return false unless status_validator.valid?(@status)
  true
end