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



23263
23264
23265
23266
23267
23268
23269
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23263

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.



23261
23262
23263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23261

def from
  @from
end

#sourceObject (readonly)

Returns the value of attribute source.



23261
23262
23263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23261

def source
  @source
end

#toObject (readonly)

Returns the value of attribute to.



23261
23262
23263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23261

def to
  @to
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



23275
23276
23277
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23275

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

#to_hashObject



23279
23280
23281
23282
23283
23284
23285
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23279

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

#to_jsonObject



23271
23272
23273
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 23271

def to_json
  JSON.dump(to_hash)
end