Class: UspsApi::LabelsPackageOptions2
- Defined in:
- lib/usps_api/models/labels_package_options2.rb
Overview
LabelsPackageOptions2 Model.
Instance Attribute Summary collapse
-
#non_delivery_option ⇒ NonDeliveryOption
Requested action in the case a package is undeliverable: - ‘RETURN` for package to be returned to `fromAddress`.
-
#omas ⇒ Omas
Fields specific to Official Mail Accounting System (OMAS).
-
#package_value ⇒ Float
The merchandise value of the package, in US dollars.
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.
Instance Method Summary collapse
-
#initialize(package_value: SKIP, non_delivery_option: SKIP, omas: SKIP, additional_properties: nil) ⇒ LabelsPackageOptions2
constructor
A new instance of LabelsPackageOptions2.
-
#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(package_value: SKIP, non_delivery_option: SKIP, omas: SKIP, additional_properties: nil) ⇒ LabelsPackageOptions2
Returns a new instance of LabelsPackageOptions2.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 63 def initialize(package_value: SKIP, non_delivery_option: SKIP, omas: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @package_value = package_value unless package_value == SKIP @non_delivery_option = non_delivery_option unless non_delivery_option == SKIP @omas = omas unless omas == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#non_delivery_option ⇒ NonDeliveryOption
Requested action in the case a package is undeliverable:
- `RETURN` for package to be returned to `fromAddress`.
- `REDIRECT` to return package to address specified in the
‘redirectAddress`.
- `ABANDON` to dispose of undeliverable package
Note:
* `REDIRECT` and `ABANDON` will not impact the domestic package
endpoint. Please use ancillary service endorsements instead.
* An address must be provided in `redirectAddress` when a value of
‘REDIRECT` is provided.
33 34 35 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 33 def non_delivery_option @non_delivery_option end |
#omas ⇒ Omas
Fields specific to Official Mail Accounting System (OMAS). Used for Federal Agencies.
38 39 40 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 38 def omas @omas end |
#package_value ⇒ Float
The merchandise value of the package, in US dollars. Used to calculate Insurance Fees if requested. Note:
* Requires extraServiceCode 910, 911, 912, 913, 921, 922, 923, 924, 925,
934, 955, 981 or extraServiceCode 930 with a packageValue greater than 500
* Package value is required when an 'extraServiceCode' value of '930' is
provided.
20 21 22 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 20 def package_value @package_value end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 75 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. package_value = hash.key?('packageValue') ? hash['packageValue'] : SKIP non_delivery_option = hash.key?('nonDeliveryOption') ? hash['nonDeliveryOption'] : SKIP omas = Omas.from_hash(hash['omas']) if hash['omas'] # 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. LabelsPackageOptions2.new(package_value: package_value, non_delivery_option: non_delivery_option, omas: omas, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['package_value'] = 'packageValue' @_hash['non_delivery_option'] = 'nonDeliveryOption' @_hash['omas'] = 'omas' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 59 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
50 51 52 53 54 55 56 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 50 def self.optionals %w[ package_value non_delivery_option omas ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
107 108 109 110 111 112 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 107 def inspect class_name = self.class.name.split('::').last "<#{class_name} package_value: #{@package_value.inspect}, non_delivery_option:"\ " #{@non_delivery_option.inspect}, omas: #{@omas.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
99 100 101 102 103 104 |
# File 'lib/usps_api/models/labels_package_options2.rb', line 99 def to_s class_name = self.class.name.split('::').last "<#{class_name} package_value: #{@package_value}, non_delivery_option:"\ " #{@non_delivery_option}, omas: #{@omas}, additional_properties:"\ " #{@additional_properties}>" end |