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 transferred to the carrier for shipping

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Manifest

Returns a new instance of Manifest.



45930
45931
45932
45933
45934
45935
45936
45937
45938
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45930

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :timestamp, :shipping_labels], 'Manifest')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @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.



45928
45929
45930
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45928

def id
  @id
end

#pdfObject (readonly)

Returns the value of attribute pdf.



45928
45929
45930
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45928

def pdf
  @pdf
end

#serviceObject (readonly)

Returns the value of attribute service.



45928
45929
45930
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45928

def service
  @service
end

#shipping_labelsObject (readonly)

Returns the value of attribute shipping_labels.



45928
45929
45930
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45928

def shipping_labels
  @shipping_labels
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



45928
45929
45930
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45928

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



45944
45945
45946
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45944

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

#to_hashObject



45948
45949
45950
45951
45952
45953
45954
45955
45956
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45948

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

#to_jsonObject



45940
45941
45942
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45940

def to_json
  JSON.dump(to_hash)
end