Class: Io::Flow::V0::Models::ReservationError
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ReservationError
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Types of failed inventory reservation reasons
Direct Known Subclasses
ExternalApiTimeoutReservationError, GenericReservationError, NoInventoryReservationError, ReservationErrorUndefinedType
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ ReservationError
constructor
A new instance of ReservationError.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ReservationError
Returns a new instance of ReservationError.
13967 13968 13969 13970 13971 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13967 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
#code ⇒ Object (readonly)
Returns the value of attribute code.
13965 13966 13967 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13965 def code @code end |
Class Method Details
.from_json(hash) ⇒ Object
13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13981 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_hash ⇒ Object
13973 13974 13975 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13973 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_hash ⇒ Object
13977 13978 13979 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13977 def to_hash subtype_to_hash.merge(:code => @code) end |