Class: CyberSourceMergedSpec::Agency5

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

Overview

Agency5 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(start_date: SKIP, end_date: SKIP, change_of_guest: SKIP, country_code: SKIP, locality: SKIP, postal_code: SKIP, additional_properties: nil) ⇒ Agency5

Returns a new instance of Agency5.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 65

def initialize(start_date: SKIP, end_date: SKIP, change_of_guest: SKIP,
               country_code: SKIP, locality: SKIP, postal_code: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @change_of_guest = change_of_guest unless change_of_guest == SKIP
  @country_code = country_code unless country_code == SKIP
  @locality = locality unless locality == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#change_of_guestString

Indicates if there is a change of guest.

Returns:

  • (String)


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

def change_of_guest
  @change_of_guest
end

#country_codeString

The country code of the agency.

Returns:

  • (String)


26
27
28
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 26

def country_code
  @country_code
end

#end_dateString

The end date of the agency's service.

Returns:

  • (String)


18
19
20
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 18

def end_date
  @end_date
end

#localityString

The locality of the agency.

Returns:

  • (String)


30
31
32
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 30

def locality
  @locality
end

#postal_codeString

The postal code of the agency.

Returns:

  • (String)


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

def postal_code
  @postal_code
end

#start_dateString

The start date of the agency's service.

Returns:

  • (String)


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

def start_date
  @start_date
end

Class Method Details

.from_element(root) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 110

def self.from_element(root)
  start_date = XmlUtilities.from_element(root, 'startDate', String)
  end_date = XmlUtilities.from_element(root, 'endDate', String)
  change_of_guest = XmlUtilities.from_element(root, 'changeOfGuest', String)
  country_code = XmlUtilities.from_element(root, 'countryCode', String)
  locality = XmlUtilities.from_element(root, 'locality', String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)

  new(start_date: start_date,
      end_date: end_date,
      change_of_guest: change_of_guest,
      country_code: country_code,
      locality: locality,
      postal_code: postal_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
106
107
108
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  start_date = hash.key?('startDate') ? hash['startDate'] : SKIP
  end_date = hash.key?('endDate') ? hash['endDate'] : SKIP
  change_of_guest =
    hash.key?('changeOfGuest') ? hash['changeOfGuest'] : SKIP
  country_code = hash.key?('countryCode') ? hash['countryCode'] : SKIP
  locality = hash.key?('locality') ? hash['locality'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : 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.
  Agency5.new(start_date: start_date,
              end_date: end_date,
              change_of_guest: change_of_guest,
              country_code: country_code,
              locality: locality,
              postal_code: postal_code,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['start_date'] = 'startDate'
  @_hash['end_date'] = 'endDate'
  @_hash['change_of_guest'] = 'changeOfGuest'
  @_hash['country_code'] = 'countryCode'
  @_hash['locality'] = 'locality'
  @_hash['postal_code'] = 'postalCode'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    start_date
    end_date
    change_of_guest
    country_code
    locality
    postal_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



152
153
154
155
156
157
158
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 152

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} start_date: #{@start_date.inspect}, end_date: #{@end_date.inspect},"\
  " change_of_guest: #{@change_of_guest.inspect}, country_code: #{@country_code.inspect},"\
  " locality: #{@locality.inspect}, postal_code: #{@postal_code.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



144
145
146
147
148
149
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 144

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} start_date: #{@start_date}, end_date: #{@end_date}, change_of_guest:"\
  " #{@change_of_guest}, country_code: #{@country_code}, locality: #{@locality}, postal_code:"\
  " #{@postal_code}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/cyber_source_merged_spec/models/agency5.rb', line 127

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

  XmlUtilities.add_as_subelement(doc, root, 'startDate', start_date)
  XmlUtilities.add_as_subelement(doc, root, 'endDate', end_date)
  XmlUtilities.add_as_subelement(doc, root, 'changeOfGuest',
                                 change_of_guest)
  XmlUtilities.add_as_subelement(doc, root, 'countryCode', country_code)
  XmlUtilities.add_as_subelement(doc, root, 'locality', locality)
  XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end