Class: Io::Flow::V0::Models::DeliveryWindow

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

Overview

Flow’s estimate of when a shipment for this delivery will actually arrive at the final destination, taking into account a shipment estimate, center schedules, and carrier transit windows.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ DeliveryWindow

Returns a new instance of DeliveryWindow.



34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34282

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:from, :to], 'DeliveryWindow')
  @from = HttpClient::Preconditions.assert_class('from', HttpClient::Helper.to_date_time_iso8601(opts.delete(:from)), DateTime)
  @to = HttpClient::Preconditions.assert_class('to', HttpClient::Helper.to_date_time_iso8601(opts.delete(:to)), DateTime)
  @timezone = (x = opts.delete(:timezone); x.nil? ? nil : HttpClient::Preconditions.assert_class('timezone', x, String))
  @label = (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, String))
  @min_days = (x = opts.delete(:min_days); x.nil? ? nil : HttpClient::Preconditions.assert_class('min_days', x, Integer))
  @max_days = (x = opts.delete(:max_days); x.nil? ? nil : HttpClient::Preconditions.assert_class('max_days', x, Integer))
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



34280
34281
34282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34280

def from
  @from
end

#labelObject (readonly)

Returns the value of attribute label.



34280
34281
34282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34280

def label
  @label
end

#max_daysObject (readonly)

Returns the value of attribute max_days.



34280
34281
34282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34280

def max_days
  @max_days
end

#min_daysObject (readonly)

Returns the value of attribute min_days.



34280
34281
34282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34280

def min_days
  @min_days
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



34280
34281
34282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34280

def timezone
  @timezone
end

#toObject (readonly)

Returns the value of attribute to.



34280
34281
34282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34280

def to
  @to
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34297
34298
34299
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34297

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

#to_hashObject



34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34301

def to_hash
  {
    :from => from,
    :to => to,
    :timezone => timezone,
    :label => label,
    :min_days => min_days,
    :max_days => max_days
  }
end

#to_jsonObject



34293
34294
34295
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34293

def to_json
  JSON.dump(to_hash)
end