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.



14112
14113
14114
14115
14116
14117
14118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14112

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.



14110
14111
14112
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14110

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



14110
14111
14112
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14110

def to
  @to
end

#unitObject (readonly)

Returns the value of attribute unit.



14110
14111
14112
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14110

def unit
  @unit
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14124
14125
14126
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14124

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

#to_hashObject



14128
14129
14130
14131
14132
14133
14134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14128

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

#to_jsonObject



14120
14121
14122
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14120

def to_json
  JSON.dump(to_hash)
end