Class: VisaAcceptanceMergedSpec::Card5

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/models/card5.rb

Overview

Card5 Model.

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(number: SKIP, expiration_month: SKIP, expiration_year: SKIP, type: SKIP, suffix: SKIP, additional_properties: nil) ⇒ Card5

Returns a new instance of Card5.



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 65

def initialize(number: SKIP, expiration_month: SKIP, expiration_year: SKIP,
               type: SKIP, suffix: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @number = number unless number == SKIP
  @expiration_month = expiration_month unless expiration_month == SKIP
  @expiration_year = expiration_year unless expiration_year == SKIP
  @type = type unless type == SKIP
  @suffix = suffix unless suffix == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#expiration_monthString

Two-digit month in which the payment card expires. Format: MM. Possible Values: 01 through 12.

Returns:

  • (String)


21
22
23
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 21

def expiration_month
  @expiration_month
end

#expiration_yearString

Four-digit year in which the credit card expires. Format: YYYY.

Returns:

  • (String)


26
27
28
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 26

def expiration_year
  @expiration_year
end

#numberString

The customer’s payment card number, also known as the Primary Account Number (PAN).

Returns:

  • (String)


15
16
17
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 15

def number
  @number
end

#suffixString

The customer’s latest payment card number suffix.

Returns:

  • (String)


36
37
38
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 36

def suffix
  @suffix
end

#typeString

The type of card (Card Network). Possible Values:

  • 001: visa

Returns:

  • (String)


32
33
34
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 32

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  number = hash.key?('number') ? hash['number'] : SKIP
  expiration_month =
    hash.key?('expirationMonth') ? hash['expirationMonth'] : SKIP
  expiration_year =
    hash.key?('expirationYear') ? hash['expirationYear'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  suffix = hash.key?('suffix') ? hash['suffix'] : SKIP

  # 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.
  Card5.new(number: number,
            expiration_month: expiration_month,
            expiration_year: expiration_year,
            type: type,
            suffix: suffix,
            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['number'] = 'number'
  @_hash['expiration_month'] = 'expirationMonth'
  @_hash['expiration_year'] = 'expirationYear'
  @_hash['type'] = 'type'
  @_hash['suffix'] = 'suffix'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 50

def self.optionals
  %w[
    number
    expiration_month
    expiration_year
    type
    suffix
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



116
117
118
119
120
121
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 116

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} number: #{@number.inspect}, expiration_month: #{@expiration_month.inspect},"\
  " expiration_year: #{@expiration_year.inspect}, type: #{@type.inspect}, suffix:"\
  " #{@suffix.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



108
109
110
111
112
113
# File 'lib/visa_acceptance_merged_spec/models/card5.rb', line 108

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} number: #{@number}, expiration_month: #{@expiration_month},"\
  " expiration_year: #{@expiration_year}, type: #{@type}, suffix: #{@suffix},"\
  " additional_properties: #{@additional_properties}>"
end