Class: Io::Flow::V0::Models::EstimatedWindow

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

Overview

Range of time given a from and to number and the unit. For example: 1-4 hours or 4-7 days

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ EstimatedWindow

Returns a new instance of EstimatedWindow.



17657
17658
17659
17660
17661
17662
17663
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17657

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:from, :to, :unit], 'EstimatedWindow')
  @from = HttpClient::Preconditions.assert_class('from', opts.delete(:from), Integer)
  @to = HttpClient::Preconditions.assert_class('to', opts.delete(:to), Integer)
  @unit = (x = opts.delete(:unit); x.is_a?(::Io::Flow::V0::Models::UnitOfTime) ? x : ::Io::Flow::V0::Models::UnitOfTime.apply(x))
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



17655
17656
17657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17655

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



17655
17656
17657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17655

def to
  @to
end

#unitObject (readonly)

Returns the value of attribute unit.



17655
17656
17657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17655

def unit
  @unit
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17669
17670
17671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17669

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

#to_hashObject



17673
17674
17675
17676
17677
17678
17679
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17673

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

#to_jsonObject



17665
17666
17667
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17665

def to_json
  JSON.dump(to_hash)
end