Class: Vellum::VellumErrorRequest
- Inherits:
-
Object
- Object
- Vellum::VellumErrorRequest
- Defined in:
- lib/vellum_ai/types/vellum_error_request.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ VellumErrorRequest
Deserialize a JSON object to an instance of VellumErrorRequest.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(message:, code:, additional_properties: nil) ⇒ VellumErrorRequest constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of VellumErrorRequest to a JSON object.
Constructor Details
#initialize(message:, code:, additional_properties: nil) ⇒ VellumErrorRequest
14 15 16 17 18 19 20 21 |
# File 'lib/vellum_ai/types/vellum_error_request.rb', line 14 def initialize(message:, code:, additional_properties: nil) # @type [String] @message = # @type [VELLUM_ERROR_CODE_ENUM] @code = code # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
8 9 10 |
# File 'lib/vellum_ai/types/vellum_error_request.rb', line 8 def additional_properties @additional_properties end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/vellum_ai/types/vellum_error_request.rb', line 8 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/vellum_ai/types/vellum_error_request.rb', line 8 def @message end |
Class Method Details
.from_json(json_object:) ⇒ VellumErrorRequest
Deserialize a JSON object to an instance of VellumErrorRequest
27 28 29 30 31 32 33 |
# File 'lib/vellum_ai/types/vellum_error_request.rb', line 27 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) = struct. code = VELLUM_ERROR_CODE_ENUM.key(parsed_json["code"]) || parsed_json["code"] new(message: , code: code, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
46 47 48 49 |
# File 'lib/vellum_ai/types/vellum_error_request.rb', line 46 def self.validate_raw(obj:) obj..is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") obj.code.is_a?(VELLUM_ERROR_CODE_ENUM) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of VellumErrorRequest to a JSON object
38 39 40 |
# File 'lib/vellum_ai/types/vellum_error_request.rb', line 38 def to_json(*_args) { "message": @message, "code": VELLUM_ERROR_CODE_ENUM[@code] || @code }.to_json end |