Class: Io::Flow::V0::Models::ShopifyCartAddForm

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

Returns a new instance of ShopifyCartAddForm.



15627
15628
15629
15630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15627

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator) || 'shopify_cart_add_single_form', String)
end

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



15625
15626
15627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15625

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15640

def ShopifyCartAddForm.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[shopify_cart_add_form] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::SHOPIFY_CART_ADD_SINGLE_FORM; ShopifyCartAddSingleForm.new(hash)
    when Types::SHOPIFY_CART_ADD_MULTIPLE_FORM; ShopifyCartAddMultipleForm.new(hash)
    else ShopifyCartAddFormUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



15632
15633
15634
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15632

def subtype_to_hash
  raise 'Cannot serialize an instance of shopify_cart_add_form directly - must use one of the specific types: shopify_cart_add_single_form, shopify_cart_add_multiple_form'
end

#to_hashObject



15636
15637
15638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15636

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