Class: CyberSourceMergedSpec::Leg5

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

Overview

Leg5 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(origination: SKIP, destination: SKIP, carrier_code: SKIP, departure_date: SKIP, departure_time: SKIP, additional_properties: nil) ⇒ Leg5

Returns a new instance of Leg5.



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 106

def initialize(origination: SKIP, destination: SKIP, carrier_code: SKIP,
               departure_date: SKIP, departure_time: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @origination = origination unless origination == SKIP
  @destination = destination unless destination == SKIP
  @carrier_code = carrier_code unless carrier_code == SKIP
  @departure_date = departure_date unless departure_date == SKIP
  @departure_time = departure_time unless departure_time == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#carrier_codeString

International Air Transport Association (IATA) code for the carrier for this leg of the trip. Required for each leg. Required for American Express SafeKey (U.S.) for travel-related requests.

Returns:

  • (String)


63
64
65
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 63

def carrier_code
  @carrier_code
end

#departure_dateString

Departure date for the first leg of the trip. Format: YYYYMMDD. Required for American Express SafeKey (U.S.) for travel-related requests.

Returns:

  • (String)


68
69
70
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 68

def departure_date
  @departure_date
end

#departure_timeInteger

Time of departure for this leg of the trip. The format is military time and HHMM: If not all zeros, then the hours must be 00-23 and the minutes must be 00-59. Format: English characters only. Optional request field for travel legs.

Returns:

  • (Integer)


77
78
79
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 77

def departure_time
  @departure_time
end

#destinationString

Use to specify the airport code for the destination of the leg of the trip, which is designated by the pound (#) symbol in the field name. This code is usually three digits long, for example: SFO = San Francisco. Do not use the colon (:) or the dash (-). For airport codes, see IATA Airline and Airport Code Search. The leg number can be a positive integer from 0 to N. For example: travelInformation.legs.0.destination=SFO travelInformation.legs.1.destination=SFO Note In your request, send either the complete route or the individual legs (legs.0.origination and legs.n.destination). If you send all the fields, the complete route takes precedence over the individual legs. For details, see the decision_manager_travel_leg#_dest field description in Decision Manager Using the SCMP API Developer Guide on the CyberSource Business Center. Click Decision Manager > Documentation > Guides > Decision Manager Using the SCMP API Developer Guide (PDF link).

Returns:

  • (String)


56
57
58
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 56

def destination
  @destination
end

#originationString

Use to specify the airport code for the origin of the leg of the trip, which is designated by the pound (#) symbol in the field name. This code is usually three digits long, for example: SFO = San Francisco. Do not use the colon (:) or the dash (-). For airport codes, see the IATA Airline and Airport Code Search. The leg number can be a positive integer from 0 to N. For example: travelInformation.legs.0.origination=SFO travelInformation.legs.1.origination=SFO Note In your request, send either the complete route or the individual legs (legs.0.origination and legs.n.destination). If you send all the fields, the complete route takes precedence over the individual legs. For details, see the decision_manager_travel_leg#_orig field description in Decision Manager Using the SCMP API Developer Guide on the CyberSource Business Center. Click Decision Manager > Documentation > Guides > Decision Manager Using the SCMP API Developer Guide (PDF link).

Returns:

  • (String)


32
33
34
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 32

def origination
  @origination
end

Class Method Details

.from_element(root) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 147

def self.from_element(root)
  origination = XmlUtilities.from_element(root, 'origination', String)
  destination = XmlUtilities.from_element(root, 'destination', String)
  carrier_code = XmlUtilities.from_element(root, 'carrierCode', String)
  departure_date = XmlUtilities.from_element(root, 'departureDate', String)
  departure_time = XmlUtilities.from_element(root, 'departureTime', Integer)

  new(origination: origination,
      destination: destination,
      carrier_code: carrier_code,
      departure_date: departure_date,
      departure_time: departure_time,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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/leg5.rb', line 121

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  origination = hash.key?('origination') ? hash['origination'] : SKIP
  destination = hash.key?('destination') ? hash['destination'] : SKIP
  carrier_code = hash.key?('carrierCode') ? hash['carrierCode'] : SKIP
  departure_date = hash.key?('departureDate') ? hash['departureDate'] : SKIP
  departure_time = hash.key?('departureTime') ? hash['departureTime'] : 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.
  Leg5.new(origination: origination,
           destination: destination,
           carrier_code: carrier_code,
           departure_date: departure_date,
           departure_time: departure_time,
           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['origination'] = 'origination'
  @_hash['destination'] = 'destination'
  @_hash['carrier_code'] = 'carrierCode'
  @_hash['departure_date'] = 'departureDate'
  @_hash['departure_time'] = 'departureTime'
  @_hash
end

.nullablesObject

An array for nullable fields



102
103
104
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 102

def self.nullables
  []
end

.optionalsObject

An array for optional fields



91
92
93
94
95
96
97
98
99
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 91

def self.optionals
  %w[
    origination
    destination
    carrier_code
    departure_date
    departure_time
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} origination: #{@origination.inspect}, destination: #{@destination.inspect},"\
  " carrier_code: #{@carrier_code.inspect}, departure_date: #{@departure_date.inspect},"\
  " departure_time: #{@departure_time.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



177
178
179
180
181
182
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 177

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} origination: #{@origination}, destination: #{@destination}, carrier_code:"\
  " #{@carrier_code}, departure_date: #{@departure_date}, departure_time: #{@departure_time},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/cyber_source_merged_spec/models/leg5.rb', line 162

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

  XmlUtilities.add_as_subelement(doc, root, 'origination', origination)
  XmlUtilities.add_as_subelement(doc, root, 'destination', destination)
  XmlUtilities.add_as_subelement(doc, root, 'carrierCode', carrier_code)
  XmlUtilities.add_as_subelement(doc, root, 'departureDate', departure_date)
  XmlUtilities.add_as_subelement(doc, root, 'departureTime', departure_time)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end