Class: Io::Flow::V0::Models::DeliveryWindowComponent

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

Returns a new instance of DeliveryWindowComponent.



28706
28707
28708
28709
28710
28711
28712
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28706

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:from, :to, :source], 'DeliveryWindowComponent')
  @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)
  @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

#fromObject (readonly)

Returns the value of attribute from.



28704
28705
28706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28704

def from
  @from
end

#sourceObject (readonly)

Returns the value of attribute source.



28704
28705
28706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28704

def source
  @source
end

#toObject (readonly)

Returns the value of attribute to.



28704
28705
28706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28704

def to
  @to
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28718
28719
28720
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28718

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

#to_hashObject



28722
28723
28724
28725
28726
28727
28728
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28722

def to_hash
  {
    :from => from,
    :to => to,
    :source => source.value
  }
end

#to_jsonObject



28714
28715
28716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28714

def to_json
  JSON.dump(to_hash)
end