Class: Io::Flow::V0::Models::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Represents closeout of a group of labels that have been transfered to the carrier for shipping

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Manifest

Returns a new instance of Manifest.



20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20481

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :type, :timestamp, :shipping_labels], 'Manifest')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::ManifestType) ? x : ::Io::Flow::V0::Models::ManifestType.apply(x))
  @timestamp = HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(opts.delete(:timestamp)), DateTime)
  @shipping_labels = HttpClient::Preconditions.assert_class('shipping_labels', opts.delete(:shipping_labels), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShippingLabelSummary) ? x : ::Io::Flow::V0::Models::ShippingLabelSummary.new(x)) }
  @pdf = (x = opts.delete(:pdf); x.nil? ? nil : HttpClient::Preconditions.assert_class('pdf', x, String))
  @service = (x = opts.delete(:service); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ServiceSummary) ? x : ::Io::Flow::V0::Models::ServiceSummary.new(x)))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



20479
20480
20481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20479

def id
  @id
end

#pdfObject (readonly)

Returns the value of attribute pdf.



20479
20480
20481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20479

def pdf
  @pdf
end

#serviceObject (readonly)

Returns the value of attribute service.



20479
20480
20481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20479

def service
  @service
end

#shipping_labelsObject (readonly)

Returns the value of attribute shipping_labels.



20479
20480
20481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20479

def shipping_labels
  @shipping_labels
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



20479
20480
20481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20479

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



20479
20480
20481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20479

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20496
20497
20498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20496

def copy(incoming={})
  Manifest.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20500

def to_hash
  {
    :id => id,
    :type => type.value,
    :timestamp => timestamp,
    :shipping_labels => shipping_labels.map { |o| o.to_hash },
    :pdf => pdf,
    :service => service.nil? ? nil : service.to_hash
  }
end

#to_jsonObject



20492
20493
20494
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20492

def to_json
  JSON.dump(to_hash)
end