Class: Io::Flow::V0::Models::AppliedPromotion

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

Returns a new instance of AppliedPromotion.



9478
9479
9480
9481
9482
9483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9478

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type, :value], 'AppliedPromotion')
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::AppliedPromotionType) ? x : ::Io::Flow::V0::Models::AppliedPromotionType.apply(x))
  @value = (x = opts.delete(:value); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
end

Instance Attribute Details

#type ⇒ Object (readonly)

Returns the value of attribute type.



9476
9477
9478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9476

def type
  @type
end

#value ⇒ Object (readonly)

Returns the value of attribute value.



9476
9477
9478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9476

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



9489
9490
9491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9489

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

#to_hash ⇒ Object



9493
9494
9495
9496
9497
9498
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9493

def to_hash
  {
    :type => type.value,
    :value => value.to_hash
  }
end

#to_json ⇒ Object



9485
9486
9487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9485

def to_json
  JSON.dump(to_hash)
end