Class: Io::Flow::V0::Models::ReservationError

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

Overview

Types of failed inventory reservation reasons

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ReservationError

Returns a new instance of ReservationError.



11810
11811
11812
11813
11814
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11810

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



11808
11809
11810
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11808

def code
  @code
end

Class Method Details

.from_json(hash) ⇒ Object



11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11824

def ReservationError.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  discriminator = HttpClient::Helper.symbolize_keys(hash)[:code].to_s.strip
  if discriminator.empty?
    raise "Union type[reservation_error] requires a field named 'code'"
  end
  case discriminator
    when Types::NO_INVENTORY_RESERVATION_ERROR; NoInventoryReservationError.new(hash)
    when Types::EXTERNAL_API_TIMEOUT_RESERVATION_ERROR; ExternalApiTimeoutReservationError.new(hash)
    when Types::GENERIC_RESERVATION_ERROR; GenericReservationError.new(hash)
    else ReservationErrorUndefinedType.new(:code => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



11816
11817
11818
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11816

def subtype_to_hash
  raise 'Cannot serialize an instance of reservation_error directly - must use one of the specific types: no_inventory_reservation_error, external_api_timeout_reservation_error, generic_reservation_error'
end

#to_hashObject



11820
11821
11822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11820

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