Class: Io::Flow::V0::Models::SyncDuration

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

Overview

Represents a duration of time with the ability to convert to a scala FiniteDuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ SyncDuration

Returns a new instance of SyncDuration.



61703
61704
61705
61706
61707
61708
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61703

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

Instance Attribute Details

#unitObject (readonly)

Returns the value of attribute unit.



61701
61702
61703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61701

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



61701
61702
61703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61701

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



61714
61715
61716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61714

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

#to_hashObject



61718
61719
61720
61721
61722
61723
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61718

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

#to_jsonObject



61710
61711
61712
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61710

def to_json
  JSON.dump(to_hash)
end