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.



51710
51711
51712
51713
51714
51715
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51710

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.



51708
51709
51710
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51708

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



51708
51709
51710
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51708

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



51721
51722
51723
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51721

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

#to_hashObject



51725
51726
51727
51728
51729
51730
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51725

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

#to_jsonObject



51717
51718
51719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51717

def to_json
  JSON.dump(to_hash)
end