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.



12053
12054
12055
12056
12057
12058
12059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12053

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

#from ⇒ Object (readonly)

Returns the value of attribute from.



12051
12052
12053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12051

def from
  @from
end

#to ⇒ Object (readonly)

Returns the value of attribute to.



12051
12052
12053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12051

def to
  @to
end

#unit ⇒ Object (readonly)

Returns the value of attribute unit.



12051
12052
12053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12051

def unit
  @unit
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12065
12066
12067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12065

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

#to_hash ⇒ Object



12069
12070
12071
12072
12073
12074
12075
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12069

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

#to_json ⇒ Object



12061
12062
12063
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12061

def to_json
  JSON.dump(to_hash)
end