Class: Io::Flow::V0::Models::DiscountRuleOffer

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

Returns a new instance of DiscountRuleOffer.



40142
40143
40144
40145
40146
40147
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40142

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:discount, :entitlement], 'DiscountRuleOffer')
  @discount = (x = opts.delete(:discount); x.is_a?(::Io::Flow::V0::Models::DiscountOffer) ? x : ::Io::Flow::V0::Models::DiscountOffer.from_json(x))
  @entitlement = (x = opts.delete(:entitlement); x.is_a?(::Io::Flow::V0::Models::DiscountRuleEntitlement) ? x : ::Io::Flow::V0::Models::DiscountRuleEntitlement.from_json(x))
end

Instance Attribute Details

#discountObject (readonly)

Returns the value of attribute discount.



40140
40141
40142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40140

def discount
  @discount
end

#entitlementObject (readonly)

Returns the value of attribute entitlement.



40140
40141
40142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40140

def entitlement
  @entitlement
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40153
40154
40155
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40153

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

#to_hashObject



40157
40158
40159
40160
40161
40162
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40157

def to_hash
  {
    :discount => discount.to_hash,
    :entitlement => entitlement.to_hash
  }
end

#to_jsonObject



40149
40150
40151
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40149

def to_json
  JSON.dump(to_hash)
end