class Io::Flow::V0::Models::LocalizedLineItemDiscount

Represents the requested, base, and localized amounts for a discount on a given line item. It applies to the entire line regardless of quantity.

Attributes

amount[R]
base[R]
currency[R]
discount_label[R]
label[R]
requested[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 49195
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:amount, :currency], 'LocalizedLineItemDiscount')
  @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @label = (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, 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)))
  @requested = (x = opts.delete(:requested); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x)))
  @discount_label = (x = opts.delete(:discount_label); x.nil? ? nil : HttpClient::Preconditions.assert_class('discount_label', x, String))
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 49210
def copy(incoming={})
  LocalizedLineItemDiscount.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 49214
def to_hash
  {
    :amount => amount,
    :currency => currency,
    :label => label,
    :base => base.nil? ? nil : base.to_hash,
    :requested => requested.nil? ? nil : requested.to_hash,
    :discount_label => discount_label
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 49206
def to_json
  JSON.dump(to_hash)
end