Class: Io::Flow::V0::Models::EstimatedDimensions

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ EstimatedDimensions

Returns a new instance of EstimatedDimensions.



30832
30833
30834
30835
30836
30837
30838
30839
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30832

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:depth, :length, :weight, :width], 'EstimatedDimensions')
  @depth = (x = opts.delete(:depth); x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x))
  @length = (x = opts.delete(:length); x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x))
  @weight = (x = opts.delete(:weight); x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x))
  @width = (x = opts.delete(:width); x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x))
end

Instance Attribute Details

#depthObject (readonly)

Returns the value of attribute depth.



30830
30831
30832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30830

def depth
  @depth
end

#lengthObject (readonly)

Returns the value of attribute length.



30830
30831
30832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30830

def length
  @length
end

#weightObject (readonly)

Returns the value of attribute weight.



30830
30831
30832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30830

def weight
  @weight
end

#widthObject (readonly)

Returns the value of attribute width.



30830
30831
30832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30830

def width
  @width
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30845
30846
30847
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30845

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

#to_hashObject



30849
30850
30851
30852
30853
30854
30855
30856
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30849

def to_hash
  {
    :depth => depth.to_hash,
    :length => length.to_hash,
    :weight => weight.to_hash,
    :width => width.to_hash
  }
end

#to_jsonObject



30841
30842
30843
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30841

def to_json
  JSON.dump(to_hash)
end