Class: OpenapiClient::Batch
- Inherits:
-
Object
- Object
- OpenapiClient::Batch
- Defined in:
- lib/openapi_client/models/batch.rb
Overview
Batches are an advanced feature of ShipEngine designed for users who need to generate hundreds or thousands of labels at a time.
Direct Known Subclasses
CreateBatchResponseBody, GetBatchByExternalIdResponseBody, GetBatchByIdResponseBody
Instance Attribute Summary collapse
-
#batch_errors_url ⇒ Object
Link to batch errors endpoint.
-
#batch_id ⇒ Object
A string that uniquely identifies the batch.
-
#batch_labels_url ⇒ Object
Link to batch labels query.
-
#batch_notes ⇒ Object
Custom notes you can add for each created batch.
-
#batch_shipments_url ⇒ Object
The batch shipments endpoint.
-
#completed ⇒ Object
The number of labels generated in the batch.
-
#count ⇒ Object
The total of errors, warnings, and completed properties.
-
#created_at ⇒ Object
The date and time the batch was created in ShipEngine.
-
#errors ⇒ Object
The number of errors that occurred while generating the batch.
-
#external_batch_id ⇒ Object
A string that uniquely identifies the external batch.
-
#form_download ⇒ Object
The form download for any customs that are needed.
-
#forms ⇒ Object
The number of forms for customs that are available for download.
-
#label_download ⇒ Object
The label download for the batch.
-
#label_format ⇒ Object
Returns the value of attribute label_format.
-
#label_layout ⇒ Object
label layout.
-
#processed_at ⇒ Object
The date and time the batch was processed in ShipEngine.
-
#status ⇒ Object
Returns the value of attribute status.
-
#warnings ⇒ Object
The number of warnings that occurred while generating the batch.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Batch
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Batch
Initializes the object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/openapi_client/models/batch.rb', line 129 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Batch` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Batch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'label_layout') self.label_layout = attributes[:'label_layout'] end if attributes.key?(:'label_format') self.label_format = attributes[:'label_format'] end if attributes.key?(:'batch_id') self.batch_id = attributes[:'batch_id'] end if attributes.key?(:'external_batch_id') self.external_batch_id = attributes[:'external_batch_id'] end if attributes.key?(:'batch_notes') self.batch_notes = attributes[:'batch_notes'] else self.batch_notes = '' end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.key?(:'processed_at') self.processed_at = attributes[:'processed_at'] end if attributes.key?(:'errors') self.errors = attributes[:'errors'] end if attributes.key?(:'warnings') self.warnings = attributes[:'warnings'] end if attributes.key?(:'completed') self.completed = attributes[:'completed'] end if attributes.key?(:'forms') self.forms = attributes[:'forms'] end if attributes.key?(:'count') self.count = attributes[:'count'] end if attributes.key?(:'batch_shipments_url') self.batch_shipments_url = attributes[:'batch_shipments_url'] end if attributes.key?(:'batch_labels_url') self.batch_labels_url = attributes[:'batch_labels_url'] end if attributes.key?(:'batch_errors_url') self.batch_errors_url = attributes[:'batch_errors_url'] end if attributes.key?(:'label_download') self.label_download = attributes[:'label_download'] end if attributes.key?(:'form_download') self.form_download = attributes[:'form_download'] end if attributes.key?(:'status') self.status = attributes[:'status'] end end |
Instance Attribute Details
#batch_errors_url ⇒ Object
Link to batch errors endpoint
60 61 62 |
# File 'lib/openapi_client/models/batch.rb', line 60 def batch_errors_url @batch_errors_url end |
#batch_id ⇒ Object
A string that uniquely identifies the batch
24 25 26 |
# File 'lib/openapi_client/models/batch.rb', line 24 def batch_id @batch_id end |
#batch_labels_url ⇒ Object
Link to batch labels query
57 58 59 |
# File 'lib/openapi_client/models/batch.rb', line 57 def batch_labels_url @batch_labels_url end |
#batch_notes ⇒ Object
Custom notes you can add for each created batch
30 31 32 |
# File 'lib/openapi_client/models/batch.rb', line 30 def batch_notes @batch_notes end |
#batch_shipments_url ⇒ Object
The batch shipments endpoint
54 55 56 |
# File 'lib/openapi_client/models/batch.rb', line 54 def batch_shipments_url @batch_shipments_url end |
#completed ⇒ Object
The number of labels generated in the batch
45 46 47 |
# File 'lib/openapi_client/models/batch.rb', line 45 def completed @completed end |
#count ⇒ Object
The total of errors, warnings, and completed properties
51 52 53 |
# File 'lib/openapi_client/models/batch.rb', line 51 def count @count end |
#created_at ⇒ Object
The date and time the batch was created in ShipEngine
33 34 35 |
# File 'lib/openapi_client/models/batch.rb', line 33 def created_at @created_at end |
#errors ⇒ Object
The number of errors that occurred while generating the batch
39 40 41 |
# File 'lib/openapi_client/models/batch.rb', line 39 def errors @errors end |
#external_batch_id ⇒ Object
A string that uniquely identifies the external batch
27 28 29 |
# File 'lib/openapi_client/models/batch.rb', line 27 def external_batch_id @external_batch_id end |
#form_download ⇒ Object
The form download for any customs that are needed
66 67 68 |
# File 'lib/openapi_client/models/batch.rb', line 66 def form_download @form_download end |
#forms ⇒ Object
The number of forms for customs that are available for download
48 49 50 |
# File 'lib/openapi_client/models/batch.rb', line 48 def forms @forms end |
#label_download ⇒ Object
The label download for the batch
63 64 65 |
# File 'lib/openapi_client/models/batch.rb', line 63 def label_download @label_download end |
#label_format ⇒ Object
Returns the value of attribute label_format.
21 22 23 |
# File 'lib/openapi_client/models/batch.rb', line 21 def label_format @label_format end |
#label_layout ⇒ Object
label layout
19 20 21 |
# File 'lib/openapi_client/models/batch.rb', line 19 def label_layout @label_layout end |
#processed_at ⇒ Object
The date and time the batch was processed in ShipEngine
36 37 38 |
# File 'lib/openapi_client/models/batch.rb', line 36 def processed_at @processed_at end |
#status ⇒ Object
Returns the value of attribute status.
68 69 70 |
# File 'lib/openapi_client/models/batch.rb', line 68 def status @status end |
#warnings ⇒ Object
The number of warnings that occurred while generating the batch
42 43 44 |
# File 'lib/openapi_client/models/batch.rb', line 42 def warnings @warnings end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/openapi_client/models/batch.rb', line 71 def self.attribute_map { :'label_layout' => :'label_layout', :'label_format' => :'label_format', :'batch_id' => :'batch_id', :'external_batch_id' => :'external_batch_id', :'batch_notes' => :'batch_notes', :'created_at' => :'created_at', :'processed_at' => :'processed_at', :'errors' => :'errors', :'warnings' => :'warnings', :'completed' => :'completed', :'forms' => :'forms', :'count' => :'count', :'batch_shipments_url' => :'batch_shipments_url', :'batch_labels_url' => :'batch_labels_url', :'batch_errors_url' => :'batch_errors_url', :'label_download' => :'label_download', :'form_download' => :'form_download', :'status' => :'status' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
455 456 457 |
# File 'lib/openapi_client/models/batch.rb', line 455 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
119 120 121 122 123 124 125 |
# File 'lib/openapi_client/models/batch.rb', line 119 def self.openapi_nullable Set.new([ :'external_batch_id', :'batch_notes', :'processed_at', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/openapi_client/models/batch.rb', line 95 def self.openapi_types { :'label_layout' => :'LabelLayout', :'label_format' => :'LabelFormat', :'batch_id' => :'String', :'external_batch_id' => :'String', :'batch_notes' => :'String', :'created_at' => :'DateTime', :'processed_at' => :'DateTime', :'errors' => :'Integer', :'warnings' => :'Integer', :'completed' => :'Integer', :'forms' => :'Integer', :'count' => :'Integer', :'batch_shipments_url' => :'OptionalLink', :'batch_labels_url' => :'OptionalLink', :'batch_errors_url' => :'OptionalLink', :'label_download' => :'LabelDownload', :'form_download' => :'OptionalLink', :'status' => :'BatchStatus' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/openapi_client/models/batch.rb', line 417 def ==(o) return true if self.equal?(o) self.class == o.class && label_layout == o.label_layout && label_format == o.label_format && batch_id == o.batch_id && external_batch_id == o.external_batch_id && batch_notes == o.batch_notes && created_at == o.created_at && processed_at == o.processed_at && errors == o.errors && warnings == o.warnings && completed == o.completed && forms == o.forms && count == o.count && batch_shipments_url == o.batch_shipments_url && batch_labels_url == o.batch_labels_url && batch_errors_url == o.batch_errors_url && label_download == o.label_download && form_download == o.form_download && status == o.status end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/openapi_client/models/batch.rb', line 483 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model OpenapiClient.const_get(type).build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/openapi_client/models/batch.rb', line 552 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/openapi_client/models/batch.rb', line 462 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(o) ⇒ Boolean
442 443 444 |
# File 'lib/openapi_client/models/batch.rb', line 442 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
448 449 450 |
# File 'lib/openapi_client/models/batch.rb', line 448 def hash [label_layout, label_format, batch_id, external_batch_id, batch_notes, created_at, processed_at, errors, warnings, completed, forms, count, batch_shipments_url, batch_labels_url, batch_errors_url, label_download, form_download, status].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/openapi_client/models/batch.rb', line 219 def list_invalid_properties invalid_properties = Array.new if @label_layout.nil? invalid_properties.push('invalid value for "label_layout", label_layout cannot be nil.') end if @label_format.nil? invalid_properties.push('invalid value for "label_format", label_format cannot be nil.') end if @batch_id.nil? invalid_properties.push('invalid value for "batch_id", batch_id cannot be nil.') end if @external_batch_id.to_s.length < 0 invalid_properties.push('invalid value for "external_batch_id", the character length must be great than or equal to 0.') end if @created_at.nil? invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') end if @errors.nil? invalid_properties.push('invalid value for "errors", errors cannot be nil.') end if @errors < 0 invalid_properties.push('invalid value for "errors", must be greater than or equal to 0.') end if @warnings.nil? invalid_properties.push('invalid value for "warnings", warnings cannot be nil.') end if @warnings < 0 invalid_properties.push('invalid value for "warnings", must be greater than or equal to 0.') end if @completed.nil? invalid_properties.push('invalid value for "completed", completed cannot be nil.') end if @completed < 0 invalid_properties.push('invalid value for "completed", must be greater than or equal to 0.') end if @forms.nil? invalid_properties.push('invalid value for "forms", forms cannot be nil.') end if @forms < 0 invalid_properties.push('invalid value for "forms", must be greater than or equal to 0.') end if @count.nil? invalid_properties.push('invalid value for "count", count cannot be nil.') end if @count < 0 invalid_properties.push('invalid value for "count", must be greater than or equal to 0.') end if @batch_shipments_url.nil? invalid_properties.push('invalid value for "batch_shipments_url", batch_shipments_url cannot be nil.') end if @batch_labels_url.nil? invalid_properties.push('invalid value for "batch_labels_url", batch_labels_url cannot be nil.') end if @batch_errors_url.nil? invalid_properties.push('invalid value for "batch_errors_url", batch_errors_url cannot be nil.') end if @label_download.nil? invalid_properties.push('invalid value for "label_download", label_download cannot be nil.') end if @form_download.nil? invalid_properties.push('invalid value for "form_download", form_download cannot be nil.') end if @status.nil? invalid_properties.push('invalid value for "status", status cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
528 529 530 |
# File 'lib/openapi_client/models/batch.rb', line 528 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
534 535 536 537 538 539 540 541 542 543 544 545 546 |
# File 'lib/openapi_client/models/batch.rb', line 534 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
522 523 524 |
# File 'lib/openapi_client/models/batch.rb', line 522 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/openapi_client/models/batch.rb', line 310 def valid? return false if @label_layout.nil? return false if @label_format.nil? return false if @batch_id.nil? return false if @external_batch_id.to_s.length < 0 return false if @created_at.nil? return false if @errors.nil? return false if @errors < 0 return false if @warnings.nil? return false if @warnings < 0 return false if @completed.nil? return false if @completed < 0 return false if @forms.nil? return false if @forms < 0 return false if @count.nil? return false if @count < 0 return false if @batch_shipments_url.nil? return false if @batch_labels_url.nil? return false if @batch_errors_url.nil? return false if @label_download.nil? return false if @form_download.nil? return false if @status.nil? true end |