Class: UspsApi::IndiciaMetadata1
- Defined in:
- lib/usps_api/models/indicia_metadata1.rb
Overview
Metadata for the generated indicia.
Instance Attribute Summary collapse
-
#fees ⇒ Array[Fee2]
Fees associated to the mailpiece.
-
#indicia_imi ⇒ String
Base64 encoded string of the binary data used to create the Intelligent Mail Indicia (IMI) Data Matrix.
-
#postage ⇒ Float
Amount of postage required, does not include insurance or other extra service fees.
-
#sku ⇒ String
Pricing SKU.
-
#weight ⇒ Float
The mailpiece weight, in ounces.
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(sku: SKIP, postage: SKIP, fees: SKIP, weight: SKIP, indicia_imi: SKIP, additional_properties: nil) ⇒ IndiciaMetadata1
constructor
A new instance of IndiciaMetadata1.
-
#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(sku: SKIP, postage: SKIP, fees: SKIP, weight: SKIP, indicia_imi: SKIP, additional_properties: nil) ⇒ IndiciaMetadata1
Returns a new instance of IndiciaMetadata1.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 61 def initialize(sku: SKIP, postage: SKIP, fees: SKIP, weight: SKIP, indicia_imi: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @sku = sku unless sku == SKIP @postage = postage unless postage == SKIP @fees = fees unless fees == SKIP @weight = weight unless weight == SKIP @indicia_imi = indicia_imi unless indicia_imi == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#fees ⇒ Array[Fee2]
Fees associated to the mailpiece.
23 24 25 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 23 def fees @fees end |
#indicia_imi ⇒ String
Base64 encoded string of the binary data used to create the Intelligent Mail Indicia (IMI) Data Matrix.
32 33 34 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 32 def indicia_imi @indicia_imi end |
#postage ⇒ Float
Amount of postage required, does not include insurance or other extra service fees.
19 20 21 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 19 def postage @postage end |
#sku ⇒ String
Pricing SKU
14 15 16 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 14 def sku @sku end |
#weight ⇒ Float
The mailpiece weight, in ounces.
27 28 29 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 27 def weight @weight 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 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 75 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. sku = hash.key?('SKU') ? hash['SKU'] : SKIP postage = hash.key?('postage') ? hash['postage'] : SKIP # Parameter is an array, so we need to iterate through it fees = nil unless hash['fees'].nil? fees = [] hash['fees'].each do |structure| fees << (Fee2.from_hash(structure) if structure) end end fees = SKIP unless hash.key?('fees') weight = hash.key?('weight') ? hash['weight'] : SKIP indicia_imi = hash.key?('indiciaIMI') ? hash['indiciaIMI'] : 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. IndiciaMetadata1.new(sku: sku, postage: postage, fees: fees, weight: weight, indicia_imi: indicia_imi, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
35 36 37 38 39 40 41 42 43 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 35 def self.names @_hash = {} if @_hash.nil? @_hash['sku'] = 'SKU' @_hash['postage'] = 'postage' @_hash['fees'] = 'fees' @_hash['weight'] = 'weight' @_hash['indicia_imi'] = 'indiciaIMI' @_hash end |
.nullables ⇒ Object
An array for nullable fields
57 58 59 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 57 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
46 47 48 49 50 51 52 53 54 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 46 def self.optionals %w[ sku postage fees weight indicia_imi ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
118 119 120 121 122 123 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 118 def inspect class_name = self.class.name.split('::').last "<#{class_name} sku: #{@sku.inspect}, postage: #{@postage.inspect}, fees: #{@fees.inspect},"\ " weight: #{@weight.inspect}, indicia_imi: #{@indicia_imi.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
111 112 113 114 115 |
# File 'lib/usps_api/models/indicia_metadata1.rb', line 111 def to_s class_name = self.class.name.split('::').last "<#{class_name} sku: #{@sku}, postage: #{@postage}, fees: #{@fees}, weight: #{@weight},"\ " indicia_imi: #{@indicia_imi}, additional_properties: #{@additional_properties}>" end |