Class: CyberSourceMergedSpec::Card30

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/card30.rb

Overview

Card30 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(last4: SKIP, expiration_month: SKIP, expiration_year: SKIP, additional_properties: nil) ⇒ Card30

Returns a new instance of Card30.



50
51
52
53
54
55
56
57
58
59
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 50

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

  @last4 = last4 unless last4 == SKIP
  @expiration_month = expiration_month unless expiration_month == SKIP
  @expiration_year = expiration_year unless expiration_year == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#expiration_monthString

The new two-digit month of the card associated to the Tokenized Card. Format: MM. Possible Values: 01 through 12.

Returns:

  • (String)


20
21
22
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 20

def expiration_month
  @expiration_month
end

#expiration_yearString

The new four-digit year of the card associated to the Tokenized Card. Format: YYYY.

Returns:

  • (String)


25
26
27
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 25

def expiration_year
  @expiration_year
end

#last4String

The new last 4 digits of the card number associated to the Tokenized Card.

Returns:

  • (String)


14
15
16
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 14

def last4
  @last4
end

Class Method Details

.from_element(root) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 86

def self.from_element(root)
  last4 = XmlUtilities.from_element(root, 'last4', String)
  expiration_month = XmlUtilities.from_element(root, 'expirationMonth',
                                               String)
  expiration_year = XmlUtilities.from_element(root, 'expirationYear',
                                              String)

  new(last4: last4,
      expiration_month: expiration_month,
      expiration_year: expiration_year,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  last4 = hash.key?('last4') ? hash['last4'] : SKIP
  expiration_month =
    hash.key?('expirationMonth') ? hash['expirationMonth'] : SKIP
  expiration_year =
    hash.key?('expirationYear') ? hash['expirationYear'] : 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.
  Card30.new(last4: last4,
             expiration_month: expiration_month,
             expiration_year: expiration_year,
             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 28

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

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
43
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 37

def self.optionals
  %w[
    last4
    expiration_month
    expiration_year
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



121
122
123
124
125
126
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 121

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

#to_sObject

Provides a human-readable string representation of the object.



114
115
116
117
118
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 114

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

#to_xml_element(doc, root_name) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/cyber_source_merged_spec/models/card30.rb', line 99

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'last4', last4)
  XmlUtilities.add_as_subelement(doc, root, 'expirationMonth',
                                 expiration_month)
  XmlUtilities.add_as_subelement(doc, root, 'expirationYear',
                                 expiration_year)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end