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.



26085
26086
26087
26088
26089
26090
26091
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26085

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

#methodObject (readonly)

Returns the value of attribute method.



26083
26084
26085
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26083

def method
  @method
end

#typeObject (readonly)

Returns the value of attribute type.



26083
26084
26085
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26083

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



26083
26084
26085
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26083

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26097
26098
26099
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26097

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

#to_hashObject



26101
26102
26103
26104
26105
26106
26107
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26101

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

#to_jsonObject



26093
26094
26095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26093

def to_json
  JSON.dump(to_hash)
end