Class: UspsApi::InternationalOptions
- Defined in:
- lib/usps_api/models/international_options.rb
Overview
Options specific to international shipments
Instance Attribute Summary collapse
-
#mail_class ⇒ MailClass4
The international mail service requested.
-
#rate_options ⇒ Array[InternationalRateOptions]
List of rate options.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(mail_class: SKIP, rate_options: SKIP) ⇒ InternationalOptions
constructor
A new instance of InternationalOptions.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(mail_class: SKIP, rate_options: SKIP) ⇒ InternationalOptions
Returns a new instance of InternationalOptions.
44 45 46 47 |
# File 'lib/usps_api/models/international_options.rb', line 44 def initialize(mail_class: SKIP, rate_options: SKIP) @mail_class = mail_class unless mail_class == SKIP @rate_options = unless == SKIP end |
Instance Attribute Details
#mail_class ⇒ MailClass4
The international mail service requested. Note:
-
‘GLOBAL_EXPRESS_GUARANTEED` - Global Express Guaranteed Service is
suspended as of September 29, 2024.
17 18 19 |
# File 'lib/usps_api/models/international_options.rb', line 17 def mail_class @mail_class end |
#rate_options ⇒ Array[InternationalRateOptions]
List of rate options
21 22 23 |
# File 'lib/usps_api/models/international_options.rb', line 21 def @rate_options end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/usps_api/models/international_options.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. mail_class = hash.key?('mailClass') ? hash['mailClass'] : SKIP # Parameter is an array, so we need to iterate through it = nil unless hash['rateOptions'].nil? = [] hash['rateOptions'].each do |structure| << (InternationalRateOptions.from_hash(structure) if structure) end end = SKIP unless hash.key?('rateOptions') # Create object from extracted values. InternationalOptions.new(mail_class: mail_class, rate_options: ) end |
.names ⇒ Object
A mapping from model property names to API property names.
24 25 26 27 28 29 |
# File 'lib/usps_api/models/international_options.rb', line 24 def self.names @_hash = {} if @_hash.nil? @_hash['mail_class'] = 'mailClass' @_hash['rate_options'] = 'rateOptions' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/usps_api/models/international_options.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
32 33 34 35 36 37 |
# File 'lib/usps_api/models/international_options.rb', line 32 def self.optionals %w[ mail_class rate_options ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
73 74 75 76 77 78 79 |
# File 'lib/usps_api/models/international_options.rb', line 73 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
88 89 90 91 92 |
# File 'lib/usps_api/models/international_options.rb', line 88 def inspect class_name = self.class.name.split('::').last "<#{class_name} mail_class: #{@mail_class.inspect}, rate_options:"\ " #{@rate_options.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
82 83 84 85 |
# File 'lib/usps_api/models/international_options.rb', line 82 def to_s class_name = self.class.name.split('::').last "<#{class_name} mail_class: #{@mail_class}, rate_options: #{@rate_options}>" end |