Class: Vapi::ResponseObject

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/response_object.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, object:, created_at:, status:, output:, error: OMIT, additional_properties: nil) ⇒ Vapi::ResponseObject

Parameters:

  • id (String)

    Unique identifier for this Response

  • object (String)

    The object type

  • created_at (Float)

    Unix timestamp (in seconds) of when this Response was created

  • status (Vapi::ResponseObjectStatus)

    Status of the response

  • error (String) (defaults to: OMIT)

    Error message if the response failed

  • output (Array<Vapi::ResponseOutputMessage>)

    Output messages from the model

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_atFloat (readonly)

Returns Unix timestamp (in seconds) of when this Response was created.

Returns:

  • (Float)

    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

#errorString (readonly)

Returns Error message if the response failed.

Returns:

  • (String)

    Error message if the response failed



19
20
21
# File 'lib/vapi_server_sdk/types/response_object.rb', line 19

def error
  @error
end

#idString (readonly)

Returns Unique identifier for this Response.

Returns:

  • (String)

    Unique identifier for this Response



11
12
13
# File 'lib/vapi_server_sdk/types/response_object.rb', line 11

def id
  @id
end

#objectString (readonly)

Returns The object type.

Returns:

  • (String)

    The object type



13
14
15
# File 'lib/vapi_server_sdk/types/response_object.rb', line 13

def object
  @object
end

#outputArray<Vapi::ResponseOutputMessage> (readonly)

Returns Output messages from the model.

Returns:



21
22
23
# File 'lib/vapi_server_sdk/types/response_object.rb', line 21

def output
  @output
end

#statusVapi::ResponseObjectStatus (readonly)

Returns Status of the response.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


88
89
90
# File 'lib/vapi_server_sdk/types/response_object.rb', line 88

def to_json(*_args)
  @_field_set&.to_json
end