class CityPayApiClient::AirlineSegment
Attributes
A standard airline routing code (airport code or location identifier) applicable to the arrival portion of this segment.
This field contains the two character airline designator code (air carrier code or airline code) that corresponds to the airline carrier applicable for up to four flight segments of this trip itinerary.
This field contains a code that corresponds to the fare class (A, B, C, D, Premium, Discounted, etc.) within the overall class of service (e.g., First Class, Business, Economy) applicable to this travel segment, as specified in the IATA Standard Code allocation table.
The Departure Date for the travel segment in ISO Date Format (yyyy-MM-dd).
A standard airline routing code (airport code or location identifier) applicable to the departure portion of this segment.
This field contains the carrier-assigned Flight Number for this travel segment.
This field contains the total Fare for this travel segment.
O = Stopover allowed, X = Stopover not allowed.
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/citypay_api_client/models/airline_segment.rb, line 41 def self.attribute_map { :'arrival_location_code' => :'arrival_location_code', :'carrier_code' => :'carrier_code', :'class_service_code' => :'class_service_code', :'departure_date' => :'departure_date', :'departure_location_code' => :'departure_location_code', :'flight_number' => :'flight_number', :'segment_fare' => :'segment_fare', :'stop_over_indicator' => :'stop_over_indicator' } end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/citypay_api_client/models/airline_segment.rb, line 296 def self.build_from_hash(attributes) new.build_from_hash(attributes) end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/citypay_api_client/models/airline_segment.rb, line 76 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::AirlineSegment` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::AirlineSegment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'arrival_location_code') self.arrival_location_code = attributes[:'arrival_location_code'] end if attributes.key?(:'carrier_code') self.carrier_code = attributes[:'carrier_code'] end if attributes.key?(:'class_service_code') self.class_service_code = attributes[:'class_service_code'] end if attributes.key?(:'departure_date') self.departure_date = attributes[:'departure_date'] end if attributes.key?(:'departure_location_code') self.departure_location_code = attributes[:'departure_location_code'] end if attributes.key?(:'flight_number') self.flight_number = attributes[:'flight_number'] end if attributes.key?(:'segment_fare') self.segment_fare = attributes[:'segment_fare'] end if attributes.key?(:'stop_over_indicator') self.stop_over_indicator = attributes[:'stop_over_indicator'] end end
List of attributes with nullable: true
# File lib/citypay_api_client/models/airline_segment.rb, line 69 def self.openapi_nullable Set.new([ ]) end
Attribute type mapping.
# File lib/citypay_api_client/models/airline_segment.rb, line 55 def self.openapi_types { :'arrival_location_code' => :'String', :'carrier_code' => :'String', :'class_service_code' => :'String', :'departure_date' => :'Date', :'departure_location_code' => :'String', :'flight_number' => :'String', :'segment_fare' => :'Integer', :'stop_over_indicator' => :'String' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/citypay_api_client/models/airline_segment.rb, line 268 def ==(o) return true if self.equal?(o) self.class == o.class && arrival_location_code == o.arrival_location_code && carrier_code == o.carrier_code && class_service_code == o.class_service_code && departure_date == o.departure_date && departure_location_code == o.departure_location_code && flight_number == o.flight_number && segment_fare == o.segment_fare && stop_over_indicator == o.stop_over_indicator end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/citypay_api_client/models/airline_segment.rb, line 324 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model CityPayApiClient.const_get(type).build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/citypay_api_client/models/airline_segment.rb, line 393 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
Custom attribute writer method with validation @param [Object] arrival_location_code
Value to be assigned
# File lib/citypay_api_client/models/airline_segment.rb, line 192 def arrival_location_code=(arrival_location_code) if arrival_location_code.nil? fail ArgumentError, 'arrival_location_code cannot be nil' end if arrival_location_code.to_s.length > 3 fail ArgumentError, 'invalid value for "arrival_location_code", the character length must be smaller than or equal to 3.' end @arrival_location_code = arrival_location_code end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/citypay_api_client/models/airline_segment.rb, line 303 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
Custom attribute writer method with validation @param [Object] carrier_code
Value to be assigned
# File lib/citypay_api_client/models/airline_segment.rb, line 206 def carrier_code=(carrier_code) if carrier_code.nil? fail ArgumentError, 'carrier_code cannot be nil' end if carrier_code.to_s.length > 2 fail ArgumentError, 'invalid value for "carrier_code", the character length must be smaller than or equal to 2.' end @carrier_code = carrier_code end
Custom attribute writer method with validation @param [Object] class_service_code
Value to be assigned
# File lib/citypay_api_client/models/airline_segment.rb, line 220 def class_service_code=(class_service_code) if class_service_code.nil? fail ArgumentError, 'class_service_code cannot be nil' end if class_service_code.to_s.length > 2 fail ArgumentError, 'invalid value for "class_service_code", the character length must be smaller than or equal to 2.' end @class_service_code = class_service_code end
Custom attribute writer method with validation @param [Object] departure_location_code
Value to be assigned
# File lib/citypay_api_client/models/airline_segment.rb, line 234 def departure_location_code=(departure_location_code) if !departure_location_code.nil? && departure_location_code.to_s.length > 3 fail ArgumentError, 'invalid value for "departure_location_code", the character length must be smaller than or equal to 3.' end @departure_location_code = departure_location_code end
@see the `==` method @param [Object] Object to be compared
# File lib/citypay_api_client/models/airline_segment.rb, line 283 def eql?(o) self == o end
Custom attribute writer method with validation @param [Object] flight_number
Value to be assigned
# File lib/citypay_api_client/models/airline_segment.rb, line 244 def flight_number=(flight_number) if flight_number.nil? fail ArgumentError, 'flight_number cannot be nil' end if flight_number.to_s.length > 4 fail ArgumentError, 'invalid value for "flight_number", the character length must be smaller than or equal to 4.' end @flight_number = flight_number end
Calculates hash code according to all attributes. @return [Integer] Hash code
# File lib/citypay_api_client/models/airline_segment.rb, line 289 def hash [arrival_location_code, carrier_code, class_service_code, departure_date, departure_location_code, flight_number, segment_fare, stop_over_indicator].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/citypay_api_client/models/airline_segment.rb, line 124 def list_invalid_properties invalid_properties = Array.new if @arrival_location_code.nil? invalid_properties.push('invalid value for "arrival_location_code", arrival_location_code cannot be nil.') end if @arrival_location_code.to_s.length > 3 invalid_properties.push('invalid value for "arrival_location_code", the character length must be smaller than or equal to 3.') end if @carrier_code.nil? invalid_properties.push('invalid value for "carrier_code", carrier_code cannot be nil.') end if @carrier_code.to_s.length > 2 invalid_properties.push('invalid value for "carrier_code", the character length must be smaller than or equal to 2.') end if @class_service_code.nil? invalid_properties.push('invalid value for "class_service_code", class_service_code cannot be nil.') end if @class_service_code.to_s.length > 2 invalid_properties.push('invalid value for "class_service_code", the character length must be smaller than or equal to 2.') end if @departure_date.nil? invalid_properties.push('invalid value for "departure_date", departure_date cannot be nil.') end if !@departure_location_code.nil? && @departure_location_code.to_s.length > 3 invalid_properties.push('invalid value for "departure_location_code", the character length must be smaller than or equal to 3.') end if @flight_number.nil? invalid_properties.push('invalid value for "flight_number", flight_number cannot be nil.') end if @flight_number.to_s.length > 4 invalid_properties.push('invalid value for "flight_number", the character length must be smaller than or equal to 4.') end if !@stop_over_indicator.nil? && @stop_over_indicator.to_s.length > 1 invalid_properties.push('invalid value for "stop_over_indicator", the character length must be smaller than or equal to 1.') end invalid_properties end
Custom attribute writer method with validation @param [Object] stop_over_indicator
Value to be assigned
# File lib/citypay_api_client/models/airline_segment.rb, line 258 def stop_over_indicator=(stop_over_indicator) if !stop_over_indicator.nil? && stop_over_indicator.to_s.length > 1 fail ArgumentError, 'invalid value for "stop_over_indicator", the character length must be smaller than or equal to 1.' end @stop_over_indicator = stop_over_indicator end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/citypay_api_client/models/airline_segment.rb, line 375 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/citypay_api_client/models/airline_segment.rb, line 363 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/citypay_api_client/models/airline_segment.rb, line 175 def valid? return false if @arrival_location_code.nil? return false if @arrival_location_code.to_s.length > 3 return false if @carrier_code.nil? return false if @carrier_code.to_s.length > 2 return false if @class_service_code.nil? return false if @class_service_code.to_s.length > 2 return false if @departure_date.nil? return false if !@departure_location_code.nil? && @departure_location_code.to_s.length > 3 return false if @flight_number.nil? return false if @flight_number.to_s.length > 4 return false if !@stop_over_indicator.nil? && @stop_over_indicator.to_s.length > 1 true end