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.



19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19636

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :type, :service, :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))
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::ServiceSummary) ? x : ::Io::Flow::V0::Models::ServiceSummary.new(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))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



19634
19635
19636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19634

def id
  @id
end

#pdfObject (readonly)

Returns the value of attribute pdf.



19634
19635
19636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19634

def pdf
  @pdf
end

#serviceObject (readonly)

Returns the value of attribute service.



19634
19635
19636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19634

def service
  @service
end

#shipping_labelsObject (readonly)

Returns the value of attribute shipping_labels.



19634
19635
19636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19634

def shipping_labels
  @shipping_labels
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



19634
19635
19636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19634

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



19634
19635
19636
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19634

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19651
19652
19653
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19651

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

#to_hashObject



19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19655

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

#to_jsonObject



19647
19648
19649
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19647

def to_json
  JSON.dump(to_hash)
end