Class: UspsApi::ImageInfo
- Defined in:
- lib/usps_api/models/image_info.rb
Overview
Additional details used to determine how to generate the indicia image.
Instance Attribute Summary collapse
-
#image_type ⇒ ImageType2
The type of indicia image requested.
-
#label_type ⇒ LabelType2
Ability to select the indicia image size.
-
#receipt_option ⇒ ReceiptOption
Indicia & Receipt print out options: Enter ‘SEPARATE_PAGE` to print the Indicia and the Receipt on separate pages.
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(receipt_option: ReceiptOption::NONE, image_type: ImageType2::PDF, label_type: LabelType2::ENUM_2X15LABEL) ⇒ ImageInfo
constructor
A new instance of ImageInfo.
-
#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(receipt_option: ReceiptOption::NONE, image_type: ImageType2::PDF, label_type: LabelType2::ENUM_2X15LABEL) ⇒ ImageInfo
Returns a new instance of ImageInfo.
51 52 53 54 55 56 57 |
# File 'lib/usps_api/models/image_info.rb', line 51 def initialize(receipt_option: ReceiptOption::NONE, image_type: ImageType2::PDF, label_type: LabelType2::ENUM_2X15LABEL) @receipt_option = receipt_option unless receipt_option == SKIP @image_type = image_type unless image_type == SKIP @label_type = label_type unless label_type == SKIP end |
Instance Attribute Details
#image_type ⇒ ImageType2
The type of indicia image requested. If omitted then the default image type is PDF.
21 22 23 |
# File 'lib/usps_api/models/image_info.rb', line 21 def image_type @image_type end |
#label_type ⇒ LabelType2
Ability to select the indicia image size. If omitted then the default indicia size is 2X1.5LABEL.
26 27 28 |
# File 'lib/usps_api/models/image_info.rb', line 26 def label_type @label_type end |
#receipt_option ⇒ ReceiptOption
Indicia & Receipt print out options: Enter ‘SEPARATE_PAGE` to print the Indicia and the Receipt on separate pages. Enter `NONE` to print the Indicia only and no Receipt.
16 17 18 |
# File 'lib/usps_api/models/image_info.rb', line 16 def receipt_option @receipt_option end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/usps_api/models/image_info.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. receipt_option = hash['receiptOption'] ||= ReceiptOption::NONE image_type = hash['imageType'] ||= ImageType2::PDF label_type = hash['labelType'] ||= LabelType2::ENUM_2X15LABEL # Create object from extracted values. ImageInfo.new(receipt_option: receipt_option, image_type: image_type, label_type: label_type) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 |
# File 'lib/usps_api/models/image_info.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['receipt_option'] = 'receiptOption' @_hash['image_type'] = 'imageType' @_hash['label_type'] = 'labelType' @_hash end |
.nullables ⇒ Object
An array for nullable fields
47 48 49 |
# File 'lib/usps_api/models/image_info.rb', line 47 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
38 39 40 41 42 43 44 |
# File 'lib/usps_api/models/image_info.rb', line 38 def self.optionals %w[ receipt_option image_type label_type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
82 83 84 85 86 |
# File 'lib/usps_api/models/image_info.rb', line 82 def inspect class_name = self.class.name.split('::').last "<#{class_name} receipt_option: #{@receipt_option.inspect}, image_type:"\ " #{@image_type.inspect}, label_type: #{@label_type.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
75 76 77 78 79 |
# File 'lib/usps_api/models/image_info.rb', line 75 def to_s class_name = self.class.name.split('::').last "<#{class_name} receipt_option: #{@receipt_option}, image_type: #{@image_type}, label_type:"\ " #{@label_type}>" end |