Class: Io::Flow::V0::Models::PaymentCaptureOption

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

Returns a new instance of PaymentCaptureOption.



12258
12259
12260
12261
12262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12258

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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



12256
12257
12258
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12256

def type
  @type
end

Class Method Details

.from_json(hash) ⇒ Object



12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12272

def PaymentCaptureOption.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  discriminator = HttpClient::Helper.symbolize_keys(hash)[:type].to_s.strip
  if discriminator.empty?
    raise "Union type[payment_capture_option] requires a field named 'type'"
  end
  case discriminator
    when Types::PAYMENT_CAPTURE_OPTION_AUTOMATIC_IMMEDIATE; PaymentCaptureOptionAutomaticImmediate.new(hash)
    when Types::PAYMENT_CAPTURE_OPTION_MANUAL; PaymentCaptureOptionManual.new(hash)
    else PaymentCaptureOptionUndefinedType.new(:type => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



12264
12265
12266
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12264

def subtype_to_hash
  raise 'Cannot serialize an instance of payment_capture_option directly - must use one of the specific types: payment_capture_option_automatic_immediate, payment_capture_option_manual'
end

#to_hashObject



12268
12269
12270
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12268

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