Class: Io::Flow::V0::Models::DiscountOfferPercent

Inherits:
DiscountOffer
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Attributes inherited from DiscountOffer

#discriminator

Instance Method Summary collapse

Methods inherited from DiscountOffer

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ DiscountOfferPercent

Returns a new instance of DiscountOfferPercent.



35085
35086
35087
35088
35089
35090
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35085

def initialize(incoming={})
  super(:discriminator => DiscountOffer::Types::DISCOUNT_OFFER_PERCENT)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:percent], 'DiscountOfferPercent')
  @percent = HttpClient::Preconditions.assert_class('percent', HttpClient::Helper.to_big_decimal(opts.delete(:percent)), BigDecimal)
end

Instance Attribute Details

#percentObject (readonly)

Returns the value of attribute percent.



35083
35084
35085
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35083

def percent
  @percent
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35096
35097
35098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35096

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

#subtype_to_hashObject



35100
35101
35102
35103
35104
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35100

def subtype_to_hash
  {
    :percent => percent.to_f.to_s
  }
end

#to_jsonObject



35092
35093
35094
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35092

def to_json
  JSON.dump(to_hash)
end