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.



69512
69513
69514
69515
69516
69517
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69512

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.



69510
69511
69512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69510

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



69510
69511
69512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69510

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



69523
69524
69525
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69523

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

#to_hashObject



69527
69528
69529
69530
69531
69532
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69527

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

#to_jsonObject



69519
69520
69521
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69519

def to_json
  JSON.dump(to_hash)
end