class ShipEngine::AdvancedShipmentOptions
Advanced shipment options
Attributes
This field is used to [bill shipping costs to a third party](www.shipengine.com/docs/shipping/bill-to-third-party/). This field must be used in conjunction with the `bill_to_country_code`, `bill_to_party`, and `bill_to_postal_code` fields.
The two-letter [ISO 3166-1 country code](en.wikipedia.org/wiki/ISO_3166-1) of the third-party that is responsible for shipping costs.
Indicates whether to bill shipping costs to the recipient or to a third-party. When billing to a third-party, the `bill_to_account`, `bill_to_country_code`, and `bill_to_postal_code` fields must also be set.
The postal code of the third-party that is responsible for shipping costs.
Indicates that the shipment contains alcohol.
An arbitrary field that can be used to store information about the shipment.
An arbitrary field that can be used to store information about the shipment.
An arbitrary field that can be used to store information about the shipment.
Indicates that the shipper is paying the international delivery duties for this shipment. This option is supported by UPS, FedEx, and DHL Express.
Indicates if the shipment contain dry ice
The weight of the dry ice in the shipment
The National Motor Freight Traffic Association [freight class](www.nmfta.org/pages/nmfc?AspxAutoDetectCookieSupport=1), such as "77.5", "110", or "250".
Indicates that the package cannot be processed automatically because it is too large or irregularly shaped. This is primarily for USPS shipments. See [Section 1.2 of the USPS parcel standards](pe.usps.com/text/dmm300/101.htm#ep1047495) for details.
Enables Saturday delivery, if supported by the carrier.
Whether to use [UPS Ground Freight pricing](www.shipengine.com/docs/shipping/ups-ground-freight/). If enabled, then a `freight_class` must also be specified.
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/ship_engine/models/advanced_shipment_options.rb, line 66 def self.attribute_map { :'bill_to_account' => :'bill_to_account', :'bill_to_country_code' => :'bill_to_country_code', :'bill_to_party' => :'bill_to_party', :'bill_to_postal_code' => :'bill_to_postal_code', :'contains_alcohol' => :'contains_alcohol', :'delivered_duty_paid' => :'delivered_duty_paid', :'dry_ice' => :'dry_ice', :'dry_ice_weight' => :'dry_ice_weight', :'non_machinable' => :'non_machinable', :'saturday_delivery' => :'saturday_delivery', :'use_ups_ground_freight_pricing' => :'use_ups_ground_freight_pricing', :'freight_class' => :'freight_class', :'custom_field1' => :'custom_field1', :'custom_field2' => :'custom_field2', :'custom_field3' => :'custom_field3', :'collect_on_delivery' => :'collect_on_delivery' } end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/ship_engine/models/advanced_shipment_options.rb, line 321 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/ship_engine/models/advanced_shipment_options.rb, line 127 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `ShipEngine::AdvancedShipmentOptions` 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| h[k.to_sym] = v } if attributes.key?(:'bill_to_account') self.bill_to_account = attributes[:'bill_to_account'] else self.bill_to_account = 'null' end if attributes.key?(:'bill_to_country_code') self.bill_to_country_code = attributes[:'bill_to_country_code'] end if attributes.key?(:'bill_to_party') self.bill_to_party = attributes[:'bill_to_party'] end if attributes.key?(:'bill_to_postal_code') self.bill_to_postal_code = attributes[:'bill_to_postal_code'] else self.bill_to_postal_code = 'null' end if attributes.key?(:'contains_alcohol') self.contains_alcohol = attributes[:'contains_alcohol'] else self.contains_alcohol = false end if attributes.key?(:'delivered_duty_paid') self.delivered_duty_paid = attributes[:'delivered_duty_paid'] else self.delivered_duty_paid = false end if attributes.key?(:'dry_ice') self.dry_ice = attributes[:'dry_ice'] else self.dry_ice = false end if attributes.key?(:'dry_ice_weight') self.dry_ice_weight = attributes[:'dry_ice_weight'] end if attributes.key?(:'non_machinable') self.non_machinable = attributes[:'non_machinable'] else self.non_machinable = false end if attributes.key?(:'saturday_delivery') self.saturday_delivery = attributes[:'saturday_delivery'] else self.saturday_delivery = false end if attributes.key?(:'use_ups_ground_freight_pricing') self.use_ups_ground_freight_pricing = attributes[:'use_ups_ground_freight_pricing'] end if attributes.key?(:'freight_class') self.freight_class = attributes[:'freight_class'] else self.freight_class = 'null' end if attributes.key?(:'custom_field1') self.custom_field1 = attributes[:'custom_field1'] else self.custom_field1 = 'null' end if attributes.key?(:'custom_field2') self.custom_field2 = attributes[:'custom_field2'] else self.custom_field2 = 'null' end if attributes.key?(:'custom_field3') self.custom_field3 = attributes[:'custom_field3'] else self.custom_field3 = 'null' end if attributes.key?(:'collect_on_delivery') self.collect_on_delivery = attributes[:'collect_on_delivery'] end end
List of attributes with nullable: true
# File lib/ship_engine/models/advanced_shipment_options.rb, line 110 def self.openapi_nullable Set.new([ :'bill_to_account', :'bill_to_country_code', :'bill_to_party', :'bill_to_postal_code', :'dry_ice_weight', :'use_ups_ground_freight_pricing', :'freight_class', :'custom_field1', :'custom_field2', :'custom_field3', ]) end
Attribute type mapping.
# File lib/ship_engine/models/advanced_shipment_options.rb, line 88 def self.openapi_types { :'bill_to_account' => :'String', :'bill_to_country_code' => :'String', :'bill_to_party' => :'BillToParty', :'bill_to_postal_code' => :'String', :'contains_alcohol' => :'Boolean', :'delivered_duty_paid' => :'Boolean', :'dry_ice' => :'Boolean', :'dry_ice_weight' => :'Weight', :'non_machinable' => :'Boolean', :'saturday_delivery' => :'Boolean', :'use_ups_ground_freight_pricing' => :'Boolean', :'freight_class' => :'String', :'custom_field1' => :'String', :'custom_field2' => :'String', :'custom_field3' => :'String', :'collect_on_delivery' => :'CollectOnDelivery' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/ship_engine/models/advanced_shipment_options.rb, line 285 def ==(o) return true if self.equal?(o) self.class == o.class && bill_to_account == o.bill_to_account && bill_to_country_code == o.bill_to_country_code && bill_to_party == o.bill_to_party && bill_to_postal_code == o.bill_to_postal_code && contains_alcohol == o.contains_alcohol && delivered_duty_paid == o.delivered_duty_paid && dry_ice == o.dry_ice && dry_ice_weight == o.dry_ice_weight && non_machinable == o.non_machinable && saturday_delivery == o.saturday_delivery && use_ups_ground_freight_pricing == o.use_ups_ground_freight_pricing && freight_class == o.freight_class && custom_field1 == o.custom_field1 && custom_field2 == o.custom_field2 && custom_field3 == o.custom_field3 && collect_on_delivery == o.collect_on_delivery 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/ship_engine/models/advanced_shipment_options.rb, line 349 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 ShipEngine.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/ship_engine/models/advanced_shipment_options.rb, line 418 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/ship_engine/models/advanced_shipment_options.rb, line 328 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] custom_field1
Value to be assigned
# File lib/ship_engine/models/advanced_shipment_options.rb, line 255 def custom_field1=(custom_field1) if !custom_field1.nil? && custom_field1.to_s.length > 100 fail ArgumentError, 'invalid value for "custom_field1", the character length must be smaller than or equal to 100.' end @custom_field1 = custom_field1 end
Custom attribute writer method with validation @param [Object] custom_field2
Value to be assigned
# File lib/ship_engine/models/advanced_shipment_options.rb, line 265 def custom_field2=(custom_field2) if !custom_field2.nil? && custom_field2.to_s.length > 100 fail ArgumentError, 'invalid value for "custom_field2", the character length must be smaller than or equal to 100.' end @custom_field2 = custom_field2 end
Custom attribute writer method with validation @param [Object] custom_field3
Value to be assigned
# File lib/ship_engine/models/advanced_shipment_options.rb, line 275 def custom_field3=(custom_field3) if !custom_field3.nil? && custom_field3.to_s.length > 100 fail ArgumentError, 'invalid value for "custom_field3", the character length must be smaller than or equal to 100.' end @custom_field3 = custom_field3 end
@see the `==` method @param [Object] Object to be compared
# File lib/ship_engine/models/advanced_shipment_options.rb, line 308 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Integer] Hash code
# File lib/ship_engine/models/advanced_shipment_options.rb, line 314 def hash [bill_to_account, bill_to_country_code, bill_to_party, bill_to_postal_code, contains_alcohol, delivered_duty_paid, dry_ice, dry_ice_weight, non_machinable, saturday_delivery, use_ups_ground_freight_pricing, freight_class, custom_field1, custom_field2, custom_field3, collect_on_delivery].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/ship_engine/models/advanced_shipment_options.rb, line 227 def list_invalid_properties invalid_properties = Array.new if !@custom_field1.nil? && @custom_field1.to_s.length > 100 invalid_properties.push('invalid value for "custom_field1", the character length must be smaller than or equal to 100.') end if !@custom_field2.nil? && @custom_field2.to_s.length > 100 invalid_properties.push('invalid value for "custom_field2", the character length must be smaller than or equal to 100.') end if !@custom_field3.nil? && @custom_field3.to_s.length > 100 invalid_properties.push('invalid value for "custom_field3", the character length must be smaller than or equal to 100.') end invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/ship_engine/models/advanced_shipment_options.rb, line 400 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/ship_engine/models/advanced_shipment_options.rb, line 388 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/ship_engine/models/advanced_shipment_options.rb, line 246 def valid? return false if !@custom_field1.nil? && @custom_field1.to_s.length > 100 return false if !@custom_field2.nil? && @custom_field2.to_s.length > 100 return false if !@custom_field3.nil? && @custom_field3.to_s.length > 100 true end