Class: UspsApi::Image
- Defined in:
- lib/usps_api/models/image.rb
Overview
Image Model.
Instance Attribute Summary collapse
-
#created_date_time ⇒ DateTime
The datetime that the image was created.
-
#image_data ⇒ String
The base64 image data associated with your image.
-
#image_name ⇒ String
The descriptor text that was optionally associated with the image when the image was created.
-
#image_uuid ⇒ String
UUID of the image.
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(image_uuid: SKIP, image_name: SKIP, created_date_time: SKIP, image_data: SKIP) ⇒ Image
constructor
A new instance of Image.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_date_time ⇒ Object
-
#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(image_uuid: SKIP, image_name: SKIP, created_date_time: SKIP, image_data: SKIP) ⇒ Image
Returns a new instance of Image.
56 57 58 59 60 61 62 |
# File 'lib/usps_api/models/image.rb', line 56 def initialize(image_uuid: SKIP, image_name: SKIP, created_date_time: SKIP, image_data: SKIP) @image_uuid = image_uuid unless image_uuid == SKIP @image_name = image_name unless image_name == SKIP @created_date_time = created_date_time unless created_date_time == SKIP @image_data = image_data unless image_data == SKIP end |
Instance Attribute Details
#created_date_time ⇒ DateTime
The datetime that the image was created.
25 26 27 |
# File 'lib/usps_api/models/image.rb', line 25 def created_date_time @created_date_time end |
#image_data ⇒ String
The base64 image data associated with your image.
29 30 31 |
# File 'lib/usps_api/models/image.rb', line 29 def image_data @image_data end |
#image_name ⇒ String
The descriptor text that was optionally associated with the image when the image was created.
21 22 23 |
# File 'lib/usps_api/models/image.rb', line 21 def image_name @image_name end |
#image_uuid ⇒ String
UUID of the image. Used in Domestic Labels and Return Labels requests to apply an image to a label.
16 17 18 |
# File 'lib/usps_api/models/image.rb', line 16 def image_uuid @image_uuid end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/usps_api/models/image.rb', line 65 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. image_uuid = hash.key?('imageUUID') ? hash['imageUUID'] : SKIP image_name = hash.key?('imageName') ? hash['imageName'] : SKIP created_date_time = if hash.key?('createdDateTime') (DateTimeHelper.from_rfc3339(hash['createdDateTime']) if hash['createdDateTime']) else SKIP end image_data = hash.key?('imageData') ? hash['imageData'] : SKIP # Create object from extracted values. Image.new(image_uuid: image_uuid, image_name: image_name, created_date_time: created_date_time, image_data: image_data) end |
.names ⇒ Object
A mapping from model property names to API property names.
32 33 34 35 36 37 38 39 |
# File 'lib/usps_api/models/image.rb', line 32 def self.names @_hash = {} if @_hash.nil? @_hash['image_uuid'] = 'imageUUID' @_hash['image_name'] = 'imageName' @_hash['created_date_time'] = 'createdDateTime' @_hash['image_data'] = 'imageData' @_hash end |
.nullables ⇒ Object
An array for nullable fields
52 53 54 |
# File 'lib/usps_api/models/image.rb', line 52 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
42 43 44 45 46 47 48 49 |
# File 'lib/usps_api/models/image.rb', line 42 def self.optionals %w[ image_uuid image_name created_date_time image_data ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
97 98 99 100 101 |
# File 'lib/usps_api/models/image.rb', line 97 def inspect class_name = self.class.name.split('::').last "<#{class_name} image_uuid: #{@image_uuid.inspect}, image_name: #{@image_name.inspect},"\ " created_date_time: #{@created_date_time.inspect}, image_data: #{@image_data.inspect}>" end |
#to_custom_created_date_time ⇒ Object
85 86 87 |
# File 'lib/usps_api/models/image.rb', line 85 def to_custom_created_date_time DateTimeHelper.to_rfc3339(created_date_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
90 91 92 93 94 |
# File 'lib/usps_api/models/image.rb', line 90 def to_s class_name = self.class.name.split('::').last "<#{class_name} image_uuid: #{@image_uuid}, image_name: #{@image_name}, created_date_time:"\ " #{@created_date_time}, image_data: #{@image_data}>" end |