class OpenapiClient::Batch
Batches are an advanced feature of ShipEngine designed for users who need to generate hundreds or thousands of labels at a time.
Attributes
Link
to batch errors endpoint
A string that uniquely identifies the batch
Link
to batch labels query
Custom notes you can add for each created batch
The batch shipments endpoint
The number of labels generated in the batch
The total of errors, warnings, and completed properties
The date and time the batch was created in ShipEngine
The number of errors that occurred while generating the batch
A string that uniquely identifies the external batch
The form download for any customs that are needed
The number of forms for customs that are available for download
The label download for the batch
label layout
The date and time the batch was processed in ShipEngine
The number of warnings that occurred while generating the batch
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/openapi_client/models/batch.rb, line 455 def self.build_from_hash(attributes) new.build_from_hash(attributes) end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# 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
List of attributes with nullable: true
# File lib/openapi_client/models/batch.rb, line 119 def self.openapi_nullable Set.new([ :'external_batch_id', :'batch_notes', :'processed_at', ]) end
Attribute type mapping.
# 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
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# 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
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# 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
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# 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
Custom attribute writer method with validation @param [Object] completed Value to be assigned
# File lib/openapi_client/models/batch.rb, line 375 def completed=(completed) if completed.nil? fail ArgumentError, 'completed cannot be nil' end if completed < 0 fail ArgumentError, 'invalid value for "completed", must be greater than or equal to 0.' end @completed = completed end
Custom attribute writer method with validation @param [Object] count Value to be assigned
# File lib/openapi_client/models/batch.rb, line 403 def count=(count) if count.nil? fail ArgumentError, 'count cannot be nil' end if count < 0 fail ArgumentError, 'invalid value for "count", must be greater than or equal to 0.' end @count = count end
@see the `==` method @param [Object] Object to be compared
# File lib/openapi_client/models/batch.rb, line 442 def eql?(o) self == o end
Custom attribute writer method with validation @param [Object] errors Value to be assigned
# File lib/openapi_client/models/batch.rb, line 347 def errors=(errors) if errors.nil? fail ArgumentError, 'errors cannot be nil' end if errors < 0 fail ArgumentError, 'invalid value for "errors", must be greater than or equal to 0.' end @errors = errors end
Custom attribute writer method with validation @param [Object] external_batch_id
Value to be assigned
# File lib/openapi_client/models/batch.rb, line 337 def external_batch_id=(external_batch_id) if external_batch_id.to_s.length < 0 fail ArgumentError, 'invalid value for "external_batch_id", the character length must be great than or equal to 0.' end @external_batch_id = external_batch_id end
Custom attribute writer method with validation @param [Object] forms Value to be assigned
# File lib/openapi_client/models/batch.rb, line 389 def forms=(forms) if forms.nil? fail ArgumentError, 'forms cannot be nil' end if forms < 0 fail ArgumentError, 'invalid value for "forms", must be greater than or equal to 0.' end @forms = forms end
Calculates hash code according to all attributes. @return [Integer] Hash code
# 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
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# 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
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# 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
Returns the string representation of the object @return [String] String presentation of the object
# File lib/openapi_client/models/batch.rb, line 522 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# 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
Custom attribute writer method with validation @param [Object] warnings Value to be assigned
# File lib/openapi_client/models/batch.rb, line 361 def warnings=(warnings) if warnings.nil? fail ArgumentError, 'warnings cannot be nil' end if warnings < 0 fail ArgumentError, 'invalid value for "warnings", must be greater than or equal to 0.' end @warnings = warnings end