Class: CyberSourceMergedSpec::Card24

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

Overview

Card24 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, additional_properties: nil) ⇒ Card24

Returns a new instance of Card24.



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 61

def initialize(number: SKIP, expiration_month: SKIP, expiration_year: SKIP,
               type: 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
  @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)


22
23
24
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 22

def expiration_month
  @expiration_month
end

#expiration_yearString

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

Returns:

  • (String)


27
28
29
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 27

def expiration_year
  @expiration_year
end

#numberString

The customer’s payment card number, also known as the Primary Account Number (PAN). You can also use this field for encoded account numbers.

Returns:

  • (String)


16
17
18
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 16

def number
  @number
end

#typeString

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

  • 001: visa Required when source is ISSUER.

Returns:

  • (String)


34
35
36
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 34

def type
  @type
end

Class Method Details

.from_element(root) ⇒ Object



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

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

  new(number: number,
      expiration_month: expiration_month,
      expiration_year: expiration_year,
      type: type,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

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

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

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



47
48
49
50
51
52
53
54
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 47

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



139
140
141
142
143
144
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 139

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},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



131
132
133
134
135
136
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 131

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

#to_xml_element(doc, root_name) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/cyber_source_merged_spec/models/card24.rb', line 115

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

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

  root
end