Class: Io::Flow::V0::Models::EmailNotificationData

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

Returns a new instance of EmailNotificationData.



10921
10922
10923
10924
10925
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10921

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



10919
10920
10921
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10919

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10935

def EmailNotificationData.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[email_notification_data] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::EMAIL_NOTIFICATION_DATA_REFUND; EmailNotificationDataRefund.new(hash)
    when Types::EMAIL_NOTIFICATION_ABANDONED_ORDER; EmailNotificationAbandonedOrder.new(hash)
    else EmailNotificationDataUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



10927
10928
10929
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10927

def subtype_to_hash
  raise 'Cannot serialize an instance of email_notification_data directly - must use one of the specific types: email_notification_data_refund, email_notification_abandoned_order'
end

#to_hashObject



10931
10932
10933
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10931

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