Module: Anthropic::Models::Messages::MessageBatchResult

Extended by:
Internal::Type::Union
Defined in:
lib/anthropic/models/messages/message_batch_result.rb

Overview

Processing result for this request.

Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

Class Method Summary collapse

Methods included from Internal::Type::Union

==, ===, coerce, derefed_variants, dump, hash, inspect, to_sorbet_type, variants

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Class Method Details

.new(type:, **args) ⇒ Anthropic::Models::Messages::MessageBatchSucceededResult, ...

Creates a new instance of the variant class whose type matches the given value, passing the remaining arguments to its constructor.

Parameters:

  • type (Symbol, String)
  • args (Hash{Symbol=>Object})

    Attributes for the chosen variant.

    @option args [Anthropic::Models::Message] :message

    @option args [Anthropic::Models::ErrorResponse] :error

Returns:

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/anthropic/models/messages/message_batch_result.rb', line 40

def self.new(type:, **args)
  case type.to_sym
  when :succeeded
    Anthropic::Messages::MessageBatchSucceededResult.new(**args)
  when :errored
    Anthropic::Messages::MessageBatchErroredResult.new(**args)
  when :canceled
    Anthropic::Messages::MessageBatchCanceledResult.new(**args)
  when :expired
    Anthropic::Messages::MessageBatchExpiredResult.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end