Class: CyberSourceMergedSpec::Passenger

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

Overview

Contains travel-related passenger details used by DM service only.

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(type: SKIP, status: SKIP, phone: SKIP, first_name: SKIP, last_name: SKIP, id: SKIP, email: SKIP, nationality: SKIP, additional_properties: nil) ⇒ Passenger

Returns a new instance of Passenger.



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

def initialize(type: SKIP, status: SKIP, phone: SKIP, first_name: SKIP,
               last_name: SKIP, id: SKIP, email: SKIP, nationality: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @type = type unless type == SKIP
  @status = status unless status == SKIP
  @phone = phone unless phone == SKIP
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @id = id unless id == SKIP
  @email = email unless email == SKIP
  @nationality = nationality unless nationality == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#emailString

Passenger's email address, including the full domain name, such as jdoe@example.com.

Returns:

  • (String)


55
56
57
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 55

def email
  @email
end

#first_nameString

Passenger's first name.

Returns:

  • (String)


40
41
42
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 40

def first_name
  @first_name
end

#idString

ID of the passenger to whom the ticket was issued. For example, you can use this field for the frequent flyer number.

Returns:

  • (String)


50
51
52
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 50

def id
  @id
end

#last_nameString

Passenger's last name.

Returns:

  • (String)


44
45
46
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 44

def last_name
  @last_name
end

#nationalityString

Passenger's nationality country. Use the two character [ISO Standard Country Codes](https://developer.cybersource.com/library/documentation/sbc/quickre f/countries_alpha_list.pdf).

Returns:

  • (String)


62
63
64
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 62

def nationality
  @nationality
end

#phoneString

Passenger's phone number. If the order is from outside the U.S., CyberSource recommends that you include the [ISO Standard Country Codes](https://developer.cybersource.com/library/documentation/sbc/quickre f/countries_alpha_list.pdf).

Returns:

  • (String)


36
37
38
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 36

def phone
  @phone
end

#statusString

Your company's passenger classification, such as with a frequent flyer program. In this case, you might use values such as standard, gold, or platinum.

Returns:

  • (String)


28
29
30
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 28

def status
  @status
end

#typeString

Passenger classification associated with the price of the ticket. You can use one of the following values:

  • ADT: Adult
  • CNN: Child
  • INF: Infant
  • YTH: Youth
  • STU: Student
  • SCR: Senior Citizen
  • MIL: Military

Returns:

  • (String)


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

def type
  @type
end

Class Method Details

.from_element(root) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 147

def self.from_element(root)
  type = XmlUtilities.from_element(root, 'type', String)
  status = XmlUtilities.from_element(root, 'status', String)
  phone = XmlUtilities.from_element(root, 'phone', String)
  first_name = XmlUtilities.from_element(root, 'firstName', String)
  last_name = XmlUtilities.from_element(root, 'lastName', String)
  id = XmlUtilities.from_element(root, 'id', String)
  email = XmlUtilities.from_element(root, 'email', String)
  nationality = XmlUtilities.from_element(root, 'nationality', String)

  new(type: type,
      status: status,
      phone: phone,
      first_name: first_name,
      last_name: last_name,
      id: id,
      email: email,
      nationality: nationality,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
143
144
145
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 115

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  type = hash.key?('type') ? hash['type'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  phone = hash.key?('phone') ? hash['phone'] : SKIP
  first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
  last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  nationality = hash.key?('nationality') ? hash['nationality'] : 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.
  Passenger.new(type: type,
                status: status,
                phone: phone,
                first_name: first_name,
                last_name: last_name,
                id: id,
                email: email,
                nationality: nationality,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['type'] = 'type'
  @_hash['status'] = 'status'
  @_hash['phone'] = 'phone'
  @_hash['first_name'] = 'firstName'
  @_hash['last_name'] = 'lastName'
  @_hash['id'] = 'id'
  @_hash['email'] = 'email'
  @_hash['nationality'] = 'nationality'
  @_hash
end

.nullablesObject

An array for nullable fields



93
94
95
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 93

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    type
    status
    phone
    first_name
    last_name
    id
    email
    nationality
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



194
195
196
197
198
199
200
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 194

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type.inspect}, status: #{@status.inspect}, phone:"\
  " #{@phone.inspect}, first_name: #{@first_name.inspect}, last_name: #{@last_name.inspect},"\
  " id: #{@id.inspect}, email: #{@email.inspect}, nationality: #{@nationality.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



186
187
188
189
190
191
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 186

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} type: #{@type}, status: #{@status}, phone: #{@phone}, first_name:"\
  " #{@first_name}, last_name: #{@last_name}, id: #{@id}, email: #{@email}, nationality:"\
  " #{@nationality}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/cyber_source_merged_spec/models/passenger.rb', line 168

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

  XmlUtilities.add_as_subelement(doc, root, 'type', type)
  XmlUtilities.add_as_subelement(doc, root, 'status', status)
  XmlUtilities.add_as_subelement(doc, root, 'phone', phone)
  XmlUtilities.add_as_subelement(doc, root, 'firstName', first_name)
  XmlUtilities.add_as_subelement(doc, root, 'lastName', last_name)
  XmlUtilities.add_as_subelement(doc, root, 'id', id)
  XmlUtilities.add_as_subelement(doc, root, 'email', email)
  XmlUtilities.add_as_subelement(doc, root, 'nationality', nationality)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end