Class: Io::Flow::V0::Models::PriceWithBaseAndDetails

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

Returns a new instance of PriceWithBaseAndDetails.



60641
60642
60643
60644
60645
60646
60647
60648
60649
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60641

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:currency, :amount, :label], 'PriceWithBaseAndDetails')
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric)
  @label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String)
  @base = (x = opts.delete(:base); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)))
  @details = (x = opts.delete(:details); x.nil? ? nil : HttpClient::Preconditions.assert_class('details', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryOptionCostDetail) ? x : ::Io::Flow::V0::Models::DeliveryOptionCostDetail.new(x)) })
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



60639
60640
60641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60639

def amount
  @amount
end

#baseObject (readonly)

Returns the value of attribute base.



60639
60640
60641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60639

def base
  @base
end

#currencyObject (readonly)

Returns the value of attribute currency.



60639
60640
60641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60639

def currency
  @currency
end

#detailsObject (readonly)

Returns the value of attribute details.



60639
60640
60641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60639

def details
  @details
end

#labelObject (readonly)

Returns the value of attribute label.



60639
60640
60641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60639

def label
  @label
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



60655
60656
60657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60655

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

#to_hashObject



60659
60660
60661
60662
60663
60664
60665
60666
60667
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60659

def to_hash
  {
    :currency => currency,
    :amount => amount,
    :label => label,
    :base => base.nil? ? nil : base.to_hash,
    :details => details.nil? ? nil : details.map { |o| o.to_hash }
  }
end

#to_jsonObject



60651
60652
60653
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60651

def to_json
  JSON.dump(to_hash)
end