Class: Io::Flow::V0::Models::Margin

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 = {}) ⇒ Margin

Returns a new instance of Margin.



16035
16036
16037
16038
16039
16040
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16035

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

Instance Attribute Details

#type ⇒ Object (readonly)

Returns the value of attribute type.



16033
16034
16035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16033

def type
  @type
end

#value ⇒ Object (readonly)

Returns the value of attribute value.



16033
16034
16035
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16033

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16046
16047
16048
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16046

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

#to_hash ⇒ Object



16050
16051
16052
16053
16054
16055
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16050

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

#to_json ⇒ Object



16042
16043
16044
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16042

def to_json
  JSON.dump(to_hash)
end