class Io::Flow::V0::Models::DiscountForm

Attributes

label[R]
offer[R]
target[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 40032
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:offer], 'DiscountForm')
  @offer = (x = opts.delete(:offer); x.is_a?(::Io::Flow::V0::Models::DiscountOffer) ? x : ::Io::Flow::V0::Models::DiscountOffer.from_json(x))
  @target = (x = (x = opts.delete(:target); x.nil? ? "item" : x); x.is_a?(::Io::Flow::V0::Models::DiscountTarget) ? x : ::Io::Flow::V0::Models::DiscountTarget.apply(x))
  @label = (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, String))
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 40044
def copy(incoming={})
  DiscountForm.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 40048
def to_hash
  {
    :offer => offer.to_hash,
    :target => target.value,
    :label => label
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 40040
def to_json
  JSON.dump(to_hash)
end