Class: Io::Flow::V0::Models::PriceDetailComponent

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

Returns a new instance of PriceDetailComponent.



15864
15865
15866
15867
15868
15869
15870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15864

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key, :amount, :label], 'PriceDetailComponent')
  @key = (x = opts.delete(:key); x.is_a?(::Io::Flow::V0::Models::PriceDetailComponentKey) ? x : ::Io::Flow::V0::Models::PriceDetailComponentKey.apply(x))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



15862
15863
15864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15862

def amount
  @amount
end

#keyObject (readonly)

Returns the value of attribute key.



15862
15863
15864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15862

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



15862
15863
15864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15862

def label
  @label
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



15876
15877
15878
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15876

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

#to_hashObject



15880
15881
15882
15883
15884
15885
15886
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15880

def to_hash
  {
    :key => key.value,
    :amount => amount,
    :label => label
  }
end

#to_jsonObject



15872
15873
15874
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15872

def to_json
  JSON.dump(to_hash)
end