Class: Io::Flow::V0::Models::TransitEstimate

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 = {}) ⇒ TransitEstimate

Returns a new instance of TransitEstimate.



71985
71986
71987
71988
71989
71990
71991
71992
71993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71985

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:origin, :destination, :min_date, :max_date, :source], 'TransitEstimate')
  @origin = (x = opts.delete(:origin); x.is_a?(::Io::Flow::V0::Models::DeliveryWindowLocation) ? x : ::Io::Flow::V0::Models::DeliveryWindowLocation.apply(x))
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::DeliveryWindowLocation) ? x : ::Io::Flow::V0::Models::DeliveryWindowLocation.apply(x))
  @min_date = HttpClient::Preconditions.assert_class('min_date', HttpClient::Helper.to_date_time_iso8601(opts.delete(:min_date)), DateTime)
  @max_date = HttpClient::Preconditions.assert_class('max_date', HttpClient::Helper.to_date_time_iso8601(opts.delete(:max_date)), DateTime)
  @source = (x = opts.delete(:source); x.is_a?(::Io::Flow::V0::Models::DeliveryWindowComponentSource) ? x : ::Io::Flow::V0::Models::DeliveryWindowComponentSource.apply(x))
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



71983
71984
71985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71983

def destination
  @destination
end

#max_dateObject (readonly)

Returns the value of attribute max_date.



71983
71984
71985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71983

def max_date
  @max_date
end

#min_dateObject (readonly)

Returns the value of attribute min_date.



71983
71984
71985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71983

def min_date
  @min_date
end

#originObject (readonly)

Returns the value of attribute origin.



71983
71984
71985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71983

def origin
  @origin
end

#sourceObject (readonly)

Returns the value of attribute source.



71983
71984
71985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71983

def source
  @source
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



71999
72000
72001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71999

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

#to_hashObject



72003
72004
72005
72006
72007
72008
72009
72010
72011
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 72003

def to_hash
  {
    :origin => origin.value,
    :destination => destination.value,
    :min_date => min_date,
    :max_date => max_date,
    :source => source.value
  }
end

#to_jsonObject



71995
71996
71997
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71995

def to_json
  JSON.dump(to_hash)
end