Class: Io::Flow::V0::Models::Rounding

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Rounding

Returns a new instance of Rounding.



19687
19688
19689
19690
19691
19692
19693
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19687

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type, :method, :value], 'Rounding')
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::RoundingType) ? x : ::Io::Flow::V0::Models::RoundingType.apply(x))
  @method = (x = opts.delete(:method); x.is_a?(::Io::Flow::V0::Models::RoundingMethod) ? x : ::Io::Flow::V0::Models::RoundingMethod.apply(x))
  @value = HttpClient::Preconditions.assert_class('value', HttpClient::Helper.to_big_decimal(opts.delete(:value)), BigDecimal)
end

Instance Attribute Details

#method ⇒ Object (readonly)

Returns the value of attribute method.



19685
19686
19687
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19685

def method
  @method
end

#type ⇒ Object (readonly)

Returns the value of attribute type.



19685
19686
19687
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19685

def type
  @type
end

#value ⇒ Object (readonly)

Returns the value of attribute value.



19685
19686
19687
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19685

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



19699
19700
19701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19699

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

#to_hash ⇒ Object



19703
19704
19705
19706
19707
19708
19709
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19703

def to_hash
  {
    :type => type.value,
    :method => method.value,
    :value => value
  }
end

#to_json ⇒ Object



19695
19696
19697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19695

def to_json
  JSON.dump(to_hash)
end