Class: Vapi::ResponseObject
- Inherits:
-
Object
- Object
- Vapi::ResponseObject
- Defined in:
- lib/vapi_server_sdk/types/response_object.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#created_at ⇒ Float
readonly
Unix timestamp (in seconds) of when this Response was created.
-
#error ⇒ String
readonly
Error message if the response failed.
-
#id ⇒ String
readonly
Unique identifier for this Response.
-
#object ⇒ String
readonly
The object type.
-
#output ⇒ Array<Vapi::ResponseOutputMessage>
readonly
Output messages from the model.
-
#status ⇒ Vapi::ResponseObjectStatus
readonly
Status of the response.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::ResponseObject
Deserialize a JSON object to an instance of ResponseObject.
-
.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(id:, object:, created_at:, status:, output:, error: OMIT, additional_properties: nil) ⇒ Vapi::ResponseObject constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of ResponseObject to a JSON object.
Constructor Details
#initialize(id:, object:, created_at:, status:, output:, error: OMIT, additional_properties: nil) ⇒ Vapi::ResponseObject
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 38 def initialize(id:, object:, created_at:, status:, output:, error: OMIT, additional_properties: nil) @id = id @object = object @created_at = created_at @status = status @error = error if error != OMIT @output = output @additional_properties = additional_properties @_field_set = { "id": id, "object": object, "created_at": created_at, "status": status, "error": error, "output": output }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
23 24 25 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 23 def additional_properties @additional_properties end |
#created_at ⇒ Float (readonly)
Returns Unix timestamp (in seconds) of when this Response was created.
15 16 17 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 15 def created_at @created_at end |
#error ⇒ String (readonly)
Returns Error message if the response failed.
19 20 21 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 19 def error @error end |
#id ⇒ String (readonly)
Returns Unique identifier for this Response.
11 12 13 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 11 def id @id end |
#object ⇒ String (readonly)
Returns The object type.
13 14 15 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 13 def object @object end |
#output ⇒ Array<Vapi::ResponseOutputMessage> (readonly)
Returns Output messages from the model.
21 22 23 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 21 def output @output end |
#status ⇒ Vapi::ResponseObjectStatus (readonly)
Returns Status of the response.
17 18 19 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 17 def status @status end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::ResponseObject
Deserialize a JSON object to an instance of ResponseObject
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 62 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] object = parsed_json["object"] created_at = parsed_json["created_at"] status = parsed_json["status"] error = parsed_json["error"] output = parsed_json["output"]&.map do |item| item = item.to_json Vapi::ResponseOutputMessage.from_json(json_object: item) end new( id: id, object: object, created_at: created_at, status: status, error: error, output: output, 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.
98 99 100 101 102 103 104 105 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 98 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.object.is_a?(String) != false || raise("Passed value for field obj.object is not the expected type, validation failed.") obj.created_at.is_a?(Float) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.status.is_a?(Vapi::ResponseObjectStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.error&.is_a?(String) != false || raise("Passed value for field obj.error is not the expected type, validation failed.") obj.output.is_a?(Array) != false || raise("Passed value for field obj.output is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of ResponseObject to a JSON object
88 89 90 |
# File 'lib/vapi_server_sdk/types/response_object.rb', line 88 def to_json(*_args) @_field_set&.to_json end |