Class: Io::Flow::V0::Models::ShopifyLocalCartMetadata

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

Returns a new instance of ShopifyLocalCartMetadata.



37098
37099
37100
37101
37102
37103
37104
37105
37106
37107
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37098

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:total_price, :promotions, :subtotal], 'ShopifyLocalCartMetadata')
  @total_price = (x = opts.delete(:total_price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @promotions = (x = opts.delete(:promotions); x.is_a?(::Io::Flow::V0::Models::Promotions) ? x : ::Io::Flow::V0::Models::Promotions.new(x))
  @rules = (x = opts.delete(:rules); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderRulesSummary) ? x : ::Io::Flow::V0::Models::OrderRulesSummary.new(x)))
  @subtotal = (x = opts.delete(:subtotal); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @vat = (x = opts.delete(:vat); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
end

Instance Attribute Details

#dutyObject (readonly)

Returns the value of attribute duty.



37096
37097
37098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37096

def duty
  @duty
end

#promotionsObject (readonly)

Returns the value of attribute promotions.



37096
37097
37098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37096

def promotions
  @promotions
end

#rulesObject (readonly)

Returns the value of attribute rules.



37096
37097
37098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37096

def rules
  @rules
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



37096
37097
37098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37096

def subtotal
  @subtotal
end

#total_priceObject (readonly)

Returns the value of attribute total_price.



37096
37097
37098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37096

def total_price
  @total_price
end

#vatObject (readonly)

Returns the value of attribute vat.



37096
37097
37098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37096

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37113
37114
37115
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37113

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

#to_hashObject



37117
37118
37119
37120
37121
37122
37123
37124
37125
37126
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37117

def to_hash
  {
    :total_price => total_price.to_hash,
    :promotions => promotions.to_hash,
    :rules => rules.nil? ? nil : rules.to_hash,
    :subtotal => subtotal.to_hash,
    :vat => vat.nil? ? nil : vat.to_hash,
    :duty => duty.nil? ? nil : duty.to_hash
  }
end

#to_jsonObject



37109
37110
37111
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37109

def to_json
  JSON.dump(to_hash)
end