Class: Io::Flow::V0::Models::OrderPromotionForm

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

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderPromotionForm

Returns a new instance of OrderPromotionForm.



13243
13244
13245
13246
13247
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13243

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:discriminator], 'OrderPromotionForm')
  @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String)
end

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



13241
13242
13243
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13241

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13257

def OrderPromotionForm.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip
  if discriminator.empty?
    raise "Union type[order_promotion_form] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::FREE_SHIPPING_ORDER_PROMOTION_FORM; FreeShippingOrderPromotionForm.new(hash)
    else OrderPromotionFormUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



13249
13250
13251
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13249

def subtype_to_hash
  raise 'Cannot serialize an instance of order_promotion_form directly - must use one of the specific types: free_shipping_order_promotion_form'
end

#to_hashObject



13253
13254
13255
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13253

def to_hash
  subtype_to_hash.merge(:discriminator => @discriminator)
end