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.



35138
35139
35140
35141
35142
35143
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35138

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.



35136
35137
35138
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35136

def discount
  @discount
end

#entitlementObject (readonly)

Returns the value of attribute entitlement.



35136
35137
35138
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35136

def entitlement
  @entitlement
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35149
35150
35151
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35149

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

#to_hashObject



35153
35154
35155
35156
35157
35158
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35153

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

#to_jsonObject



35145
35146
35147
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35145

def to_json
  JSON.dump(to_hash)
end