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.



39265
39266
39267
39268
39269
39270
39271
39272
39273
39274
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39265

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.



39263
39264
39265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39263

def from
  @from
end

#labelObject (readonly)

Returns the value of attribute label.



39263
39264
39265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39263

def label
  @label
end

#max_daysObject (readonly)

Returns the value of attribute max_days.



39263
39264
39265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39263

def max_days
  @max_days
end

#min_daysObject (readonly)

Returns the value of attribute min_days.



39263
39264
39265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39263

def min_days
  @min_days
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



39263
39264
39265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39263

def timezone
  @timezone
end

#toObject (readonly)

Returns the value of attribute to.



39263
39264
39265
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39263

def to
  @to
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



39280
39281
39282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39280

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

#to_hashObject



39284
39285
39286
39287
39288
39289
39290
39291
39292
39293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39284

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

#to_jsonObject



39276
39277
39278
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39276

def to_json
  JSON.dump(to_hash)
end